rename to mod.ts

This commit is contained in:
Skillz
2020-12-26 19:30:32 -05:00
parent 0cfdb5fd43
commit 189dc150f2
29 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { DiscordPayload, GuildBanPayload } from "../../types/types.ts"; import { DiscordPayload, GuildBanPayload } from "../../types/mod.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalGuildBanAdd(data: DiscordPayload) { export async function handleInternalGuildBanAdd(data: DiscordPayload) {
+1 -1
View File
@@ -1,4 +1,4 @@
import { PresenceUpdatePayload } from "../../types/types.ts"; import { PresenceUpdatePayload } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { Channel, Guild, Member, Message } from "../structures/structures.ts"; import { Channel, Guild, Member, Message } from "../structures/structures.ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import {
ChannelCreatePayload, ChannelCreatePayload,
ChannelTypes, ChannelTypes,
DiscordPayload, DiscordPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -1
View File
@@ -6,7 +6,7 @@ import {
GuildEmojisUpdatePayload, GuildEmojisUpdatePayload,
GuildUpdateChange, GuildUpdateChange,
UpdateGuildPayload, UpdateGuildPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -4
View File
@@ -1,8 +1,5 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { import { DiscordPayload, InteractionCommandPayload } from "../../types/mod.ts";
DiscordPayload,
InteractionCommandPayload,
} from "../../types/types.ts";
import { structures } from "../structures/mod.ts"; import { structures } from "../structures/mod.ts";
export async function handleInternalInteractionsCreate(data: DiscordPayload) { export async function handleInternalInteractionsCreate(data: DiscordPayload) {
+1 -1
View File
@@ -5,7 +5,7 @@ import {
GuildMemberAddPayload, GuildMemberAddPayload,
GuildMemberChunkPayload, GuildMemberChunkPayload,
GuildMemberUpdatePayload, GuildMemberUpdatePayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -1
View File
@@ -4,7 +4,7 @@ import {
MessageCreateOptions, MessageCreateOptions,
MessageDeleteBulkPayload, MessageDeleteBulkPayload,
MessageDeletePayload, MessageDeletePayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -1
View File
@@ -7,7 +7,7 @@ import {
UserPayload, UserPayload,
VoiceStateUpdatePayload, VoiceStateUpdatePayload,
WebhookUpdatePayload, WebhookUpdatePayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { delay } from "../../util/utils.ts"; import { delay } from "../../util/utils.ts";
import { allowNextShard } from "../../ws/shard_manager.ts"; import { allowNextShard } from "../../ws/shard_manager.ts";
+1 -1
View File
@@ -4,7 +4,7 @@ import {
DiscordPayload, DiscordPayload,
MessageReactionPayload, MessageReactionPayload,
MessageReactionRemoveEmojiPayload, MessageReactionRemoveEmojiPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import {
DiscordPayload, DiscordPayload,
GuildRoleDeletePayload, GuildRoleDeletePayload,
GuildRolePayload, GuildRolePayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { structures } from "../structures/structures.ts"; import { structures } from "../structures/structures.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+1 -1
View File
@@ -15,7 +15,7 @@ import {
Permissions, Permissions,
RawOverwrite, RawOverwrite,
WebhookPayload, WebhookPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { import {
botHasChannelPermissions, botHasChannelPermissions,
+3 -3
View File
@@ -31,7 +31,7 @@ import {
RoleData, RoleData,
UpdateGuildPayload, UpdateGuildPayload,
UserPayload, UserPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { botHasPermission, calculateBits } from "../../util/permissions.ts"; import { botHasPermission, calculateBits } from "../../util/permissions.ts";
@@ -416,9 +416,9 @@ export async function pruneMembers(guildID: string, options: PruneOptions) {
); );
} }
/** /**
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get() * ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
* *
* ADVANCED: * ADVANCED:
* Highly recommended to use this function to fetch members instead of getMember from REST. * Highly recommended to use this function to fetch members instead of getMember from REST.
* REST: 50/s global(across all shards) rate limit with ALL requests this included * REST: 50/s global(across all shards) rate limit with ALL requests this included
+1 -1
View File
@@ -7,7 +7,7 @@ import {
ImageFormats, ImageFormats,
ImageSize, ImageSize,
MessageContent, MessageContent,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { import {
botHasPermission, botHasPermission,
+1 -1
View File
@@ -5,7 +5,7 @@ import {
MessageContent, MessageContent,
MessageCreateOptions, MessageCreateOptions,
UserPayload, UserPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { botHasChannelPermissions } from "../../util/permissions.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts";
import { delay } from "../../util/utils.ts"; import { delay } from "../../util/utils.ts";
+3 -3
View File
@@ -12,7 +12,7 @@ import {
UpsertSlashCommandOptions, UpsertSlashCommandOptions,
WebhookCreateOptions, WebhookCreateOptions,
WebhookPayload, WebhookPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { botHasChannelPermissions } from "../../util/permissions.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts";
@@ -186,7 +186,7 @@ export function deleteWebhookMessage(
* - Your app **cannot** have two guild commands within the same name **on the same guild** * - Your app **cannot** have two guild commands within the same name **on the same guild**
* - Your app **can** have a global and guild command with the same name * - Your app **can** have a global and guild command with the same name
* - Multiple apps **can** have commands with the same names * - Multiple apps **can** have commands with the same names
* *
* Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour. * Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour.
* Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use. * Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use.
*/ */
@@ -257,7 +257,7 @@ export function deleteSlashCommand(id: string, guildID?: string) {
/** /**
* Send a response to a users slash command. The command data will have the id and token necessary to respond. * Send a response to a users slash command. The command data will have the id and token necessary to respond.
* Interaction `tokens` are valid for **15 minutes** and can be used to send followup messages. * Interaction `tokens` are valid for **15 minutes** and can be used to send followup messages.
* *
* NOTE: By default we will suppress mentions. To enable mentions, just pass any mentions object. * NOTE: By default we will suppress mentions. To enable mentions, just pass any mentions object.
*/ */
export function executeSlashCommand( export function executeSlashCommand(
+5 -5
View File
@@ -2,7 +2,7 @@ import {
ChannelCreatePayload, ChannelCreatePayload,
ChannelType, ChannelType,
RawOverwrite, RawOverwrite,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
@@ -93,15 +93,15 @@ export interface Channel {
// GETTERS // GETTERS
/** /**
* Gets the guild object for this channel. * Gets the guild object for this channel.
* *
* ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async. * ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async.
*/ */
guild?: Guild; guild?: Guild;
/** /**
* Gets the messages from cache that were sent in this channel * Gets the messages from cache that were sent in this channel
* *
* ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async. * ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async.
*/ */
messages: Collection<string, Message>; messages: Collection<string, Message>;
+11 -7
View File
@@ -1,6 +1,7 @@
import { botID } from "../../bot.ts"; import { botID } from "../../bot.ts";
import { import {
BannedUser, BannedUser,
ChannelCreatePayload,
CreateGuildPayload, CreateGuildPayload,
Emoji, Emoji,
GetAuditLogsOptions, GetAuditLogsOptions,
@@ -11,8 +12,9 @@ import {
ImageSize, ImageSize,
MemberCreatePayload, MemberCreatePayload,
Presence, Presence,
RoleData,
VoiceState, VoiceState,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
@@ -133,11 +135,13 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) {
} = data; } = data;
const roles = await Promise.all( const roles = await Promise.all(
data.roles.map((r) => structures.createRole(r)), data.roles.map((r: RoleData) => structures.createRole(r)),
); ) as Role[];
await Promise.all( await Promise.all(
channels.map((c) => structures.createChannel(c, data.id)), channels.map((c: ChannelCreatePayload) =>
structures.createChannel(c, data.id)
),
); );
const restProps: Record<string, ReturnType<typeof createNewProp>> = {}; const restProps: Record<string, ReturnType<typeof createNewProp>> = {};
@@ -170,14 +174,14 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) {
premiumTier: createNewProp(premiumTier), premiumTier: createNewProp(premiumTier),
premiumSubscriptionCount: createNewProp(premiumSubscriptionCount), premiumSubscriptionCount: createNewProp(premiumSubscriptionCount),
preferredLocale: createNewProp(preferredLocale), preferredLocale: createNewProp(preferredLocale),
roles: createNewProp(new Collection(roles.map((r) => [r.id, r]))), roles: createNewProp(new Collection(roles.map((r: Role) => [r.id, r]))),
joinedAt: createNewProp(Date.parse(joinedAt)), joinedAt: createNewProp(Date.parse(joinedAt)),
presences: createNewProp( presences: createNewProp(
new Collection(data.presences.map((p) => [p.user.id, p])), new Collection(data.presences.map((p: Presence) => [p.user.id, p])),
), ),
memberCount: createNewProp(memberCount || 0), memberCount: createNewProp(memberCount || 0),
voiceStates: createNewProp( voiceStates: createNewProp(
new Collection(voiceStates.map((vs) => [vs.user_id, { new Collection(voiceStates.map((vs: VoiceState) => [vs.user_id, {
...vs, ...vs,
guildID: vs.guild_id, guildID: vs.guild_id,
channelID: vs.channel_id, channelID: vs.channel_id,
+1 -1
View File
@@ -4,7 +4,7 @@ import {
GuildMember, GuildMember,
MemberCreatePayload, MemberCreatePayload,
MessageContent, MessageContent,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
+1 -1
View File
@@ -10,7 +10,7 @@ import {
Reaction, Reaction,
Reference, Reference,
UserPayload, UserPayload,
} from "../../types/types.ts"; } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
import { sendMessage } from "../handlers/channel.ts"; import { sendMessage } from "../handlers/channel.ts";
+1 -1
View File
@@ -1,4 +1,4 @@
import { CreateRoleOptions, RoleData } from "../../types/types.ts"; import { CreateRoleOptions, RoleData } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { Collection } from "../../util/collection.ts"; import { Collection } from "../../util/collection.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
+1 -1
View File
@@ -1,4 +1,4 @@
import { GuildTemplate, UserPayload } from "../../types/types.ts"; import { GuildTemplate, UserPayload } from "../../types/mod.ts";
import { cache } from "../../util/cache.ts"; import { cache } from "../../util/cache.ts";
import { createNewProp } from "../../util/utils.ts"; import { createNewProp } from "../../util/utils.ts";
import { Guild } from "./guild.ts"; import { Guild } from "./guild.ts";
+1 -1
View File
@@ -3,7 +3,7 @@ import {
BotConfig, BotConfig,
DiscordBotGatewayData, DiscordBotGatewayData,
EventHandlers, EventHandlers,
} from "./types/types.ts"; } from "./types/mod.ts";
import { baseEndpoints, endpoints, GATEWAY_VERSION } from "./util/constants.ts"; import { baseEndpoints, endpoints, GATEWAY_VERSION } from "./util/constants.ts";
import { spawnShards } from "./ws/shard_manager.ts"; import { spawnShards } from "./ws/shard_manager.ts";
+1 -1
View File
@@ -1,5 +1,5 @@
import { authorization, eventHandlers } from "../bot.ts"; import { authorization, eventHandlers } from "../bot.ts";
import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts"; import { Errors, HttpResponseCode, RequestMethods } from "../types/mod.ts";
import { import {
API_VERSION, API_VERSION,
BASE_URL, BASE_URL,
-1
View File
@@ -8,7 +8,6 @@ export * from "./guild.ts";
export * from "./interactions.ts"; export * from "./interactions.ts";
export * from "./member.ts"; export * from "./member.ts";
export * from "./message.ts"; export * from "./message.ts";
export * from "./misc.ts";
export * from "./options.ts"; export * from "./options.ts";
export * from "./permission.ts"; export * from "./permission.ts";
export * from "./presence.ts"; export * from "./presence.ts";
+1 -1
View File
@@ -4,7 +4,7 @@ import {
Member, Member,
Message, Message,
} from "../api/structures/structures.ts"; } from "../api/structures/structures.ts";
import { PresenceUpdatePayload } from "../types/types.ts"; import { PresenceUpdatePayload } from "../types/mod.ts";
import { Collection } from "./collection.ts"; import { Collection } from "./collection.ts";
export interface CacheData { export interface CacheData {
+1 -1
View File
@@ -1,7 +1,7 @@
import { cacheHandlers } from "../api/controllers/cache.ts"; import { cacheHandlers } from "../api/controllers/cache.ts";
import { Guild, Role } from "../api/structures/structures.ts"; import { Guild, Role } from "../api/structures/structures.ts";
import { botID } from "../bot.ts"; import { botID } from "../bot.ts";
import { Permission, Permissions, RawOverwrite } from "../types/types.ts"; import { Permission, Permissions, RawOverwrite } from "../types/mod.ts";
/** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */ /** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */
export async function memberIDHasPermission( export async function memberIDHasPermission(
+1 -1
View File
@@ -4,7 +4,7 @@ import {
ImageFormats, ImageFormats,
ImageSize, ImageSize,
StatusType, StatusType,
} from "../types/types.ts"; } from "../types/mod.ts";
import { sendGatewayCommand } from "../ws/shard_manager.ts"; import { sendGatewayCommand } from "../ws/shard_manager.ts";
export const sleep = (timeout: number) => { export const sleep = (timeout: number) => {
+1 -1
View File
@@ -10,7 +10,7 @@ import {
FetchMembersOptions, FetchMembersOptions,
GatewayOpcode, GatewayOpcode,
ReadyPayload, ReadyPayload,
} from "../types/types.ts"; } from "../types/mod.ts";
import { BotStatusRequest, delay } from "../util/utils.ts"; import { BotStatusRequest, delay } from "../util/utils.ts";
import { decompressWith } from "./deps.ts"; import { decompressWith } from "./deps.ts";
import { handleDiscordPayload } from "./shard_manager.ts"; import { handleDiscordPayload } from "./shard_manager.ts";
+1 -1
View File
@@ -6,7 +6,7 @@ import {
DiscordPayload, DiscordPayload,
FetchMembersOptions, FetchMembersOptions,
GatewayOpcode, GatewayOpcode,
} from "../types/types.ts"; } from "../types/mod.ts";
import { cache } from "../util/cache.ts"; import { cache } from "../util/cache.ts";
import { BotStatusRequest, delay } from "../util/utils.ts"; import { BotStatusRequest, delay } from "../util/utils.ts";
import { import {