From 189dc150f2b39e9f34cf6249195aaa5ba3248aa1 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sat, 26 Dec 2020 19:30:32 -0500 Subject: [PATCH] rename to mod.ts --- src/api/controllers/bans.ts | 2 +- src/api/controllers/cache.ts | 2 +- src/api/controllers/channels.ts | 2 +- src/api/controllers/guilds.ts | 2 +- src/api/controllers/interactions.ts | 5 +---- src/api/controllers/members.ts | 2 +- src/api/controllers/messages.ts | 2 +- src/api/controllers/misc.ts | 2 +- src/api/controllers/reactions.ts | 2 +- src/api/controllers/roles.ts | 2 +- src/api/handlers/channel.ts | 2 +- src/api/handlers/guild.ts | 6 +++--- src/api/handlers/member.ts | 2 +- src/api/handlers/message.ts | 2 +- src/api/handlers/webhook.ts | 6 +++--- src/api/structures/channel.ts | 10 +++++----- src/api/structures/guild.ts | 18 +++++++++++------- src/api/structures/member.ts | 2 +- src/api/structures/message.ts | 2 +- src/api/structures/role.ts | 2 +- src/api/structures/template.ts | 2 +- src/bot.ts | 2 +- src/rest/request_manager.ts | 2 +- src/types/{types.ts => mod.ts} | 1 - src/util/cache.ts | 2 +- src/util/permissions.ts | 2 +- src/util/utils.ts | 2 +- src/ws/shard.ts | 2 +- src/ws/shard_manager.ts | 2 +- 29 files changed, 46 insertions(+), 46 deletions(-) rename src/types/{types.ts => mod.ts} (94%) diff --git a/src/api/controllers/bans.ts b/src/api/controllers/bans.ts index 22039f053..5e6a323b6 100644 --- a/src/api/controllers/bans.ts +++ b/src/api/controllers/bans.ts @@ -1,5 +1,5 @@ import { eventHandlers } from "../../bot.ts"; -import { DiscordPayload, GuildBanPayload } from "../../types/types.ts"; +import { DiscordPayload, GuildBanPayload } from "../../types/mod.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildBanAdd(data: DiscordPayload) { diff --git a/src/api/controllers/cache.ts b/src/api/controllers/cache.ts index 5e82b398e..b91d45ba7 100644 --- a/src/api/controllers/cache.ts +++ b/src/api/controllers/cache.ts @@ -1,4 +1,4 @@ -import { PresenceUpdatePayload } from "../../types/types.ts"; +import { PresenceUpdatePayload } from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { Collection } from "../../util/collection.ts"; import { Channel, Guild, Member, Message } from "../structures/structures.ts"; diff --git a/src/api/controllers/channels.ts b/src/api/controllers/channels.ts index 79f34f0af..cc0f3b7bf 100644 --- a/src/api/controllers/channels.ts +++ b/src/api/controllers/channels.ts @@ -3,7 +3,7 @@ import { ChannelCreatePayload, ChannelTypes, DiscordPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/controllers/guilds.ts b/src/api/controllers/guilds.ts index c277e9b60..2f8029c95 100644 --- a/src/api/controllers/guilds.ts +++ b/src/api/controllers/guilds.ts @@ -6,7 +6,7 @@ import { GuildEmojisUpdatePayload, GuildUpdateChange, UpdateGuildPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/controllers/interactions.ts b/src/api/controllers/interactions.ts index bcb4b6b64..c0df8e1e0 100644 --- a/src/api/controllers/interactions.ts +++ b/src/api/controllers/interactions.ts @@ -1,8 +1,5 @@ import { eventHandlers } from "../../bot.ts"; -import { - DiscordPayload, - InteractionCommandPayload, -} from "../../types/types.ts"; +import { DiscordPayload, InteractionCommandPayload } from "../../types/mod.ts"; import { structures } from "../structures/mod.ts"; export async function handleInternalInteractionsCreate(data: DiscordPayload) { diff --git a/src/api/controllers/members.ts b/src/api/controllers/members.ts index 26c8c1235..f57f942fd 100644 --- a/src/api/controllers/members.ts +++ b/src/api/controllers/members.ts @@ -5,7 +5,7 @@ import { GuildMemberAddPayload, GuildMemberChunkPayload, GuildMemberUpdatePayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/controllers/messages.ts b/src/api/controllers/messages.ts index 170981986..db9ac2f7b 100644 --- a/src/api/controllers/messages.ts +++ b/src/api/controllers/messages.ts @@ -4,7 +4,7 @@ import { MessageCreateOptions, MessageDeleteBulkPayload, MessageDeletePayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/controllers/misc.ts b/src/api/controllers/misc.ts index 7896d4b00..a59c021f0 100644 --- a/src/api/controllers/misc.ts +++ b/src/api/controllers/misc.ts @@ -7,7 +7,7 @@ import { UserPayload, VoiceStateUpdatePayload, WebhookUpdatePayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { delay } from "../../util/utils.ts"; import { allowNextShard } from "../../ws/shard_manager.ts"; diff --git a/src/api/controllers/reactions.ts b/src/api/controllers/reactions.ts index beb3f6982..da3c33fe7 100644 --- a/src/api/controllers/reactions.ts +++ b/src/api/controllers/reactions.ts @@ -4,7 +4,7 @@ import { DiscordPayload, MessageReactionPayload, MessageReactionRemoveEmojiPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/controllers/roles.ts b/src/api/controllers/roles.ts index 57a3bf424..16dda7e1c 100644 --- a/src/api/controllers/roles.ts +++ b/src/api/controllers/roles.ts @@ -3,7 +3,7 @@ import { DiscordPayload, GuildRoleDeletePayload, GuildRolePayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/api/handlers/channel.ts b/src/api/handlers/channel.ts index 340d452b0..c608c30d8 100644 --- a/src/api/handlers/channel.ts +++ b/src/api/handlers/channel.ts @@ -15,7 +15,7 @@ import { Permissions, RawOverwrite, WebhookPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions, diff --git a/src/api/handlers/guild.ts b/src/api/handlers/guild.ts index 22f002881..597a14094 100644 --- a/src/api/handlers/guild.ts +++ b/src/api/handlers/guild.ts @@ -31,7 +31,7 @@ import { RoleData, UpdateGuildPayload, UserPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.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() - * + * * ADVANCED: * 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 diff --git a/src/api/handlers/member.ts b/src/api/handlers/member.ts index 020203bd7..dd4508af1 100644 --- a/src/api/handlers/member.ts +++ b/src/api/handlers/member.ts @@ -7,7 +7,7 @@ import { ImageFormats, ImageSize, MessageContent, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasPermission, diff --git a/src/api/handlers/message.ts b/src/api/handlers/message.ts index deb9bbf2c..0a12a8d55 100644 --- a/src/api/handlers/message.ts +++ b/src/api/handlers/message.ts @@ -5,7 +5,7 @@ import { MessageContent, MessageCreateOptions, UserPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts"; import { delay } from "../../util/utils.ts"; diff --git a/src/api/handlers/webhook.ts b/src/api/handlers/webhook.ts index dfa3c4f91..c08fa8099 100644 --- a/src/api/handlers/webhook.ts +++ b/src/api/handlers/webhook.ts @@ -12,7 +12,7 @@ import { UpsertSlashCommandOptions, WebhookCreateOptions, WebhookPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { endpoints } from "../../util/constants.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 **can** have a global and guild command with the same name * - 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. * 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. * 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. */ export function executeSlashCommand( diff --git a/src/api/structures/channel.ts b/src/api/structures/channel.ts index 5c8bcfb6e..12d69ceb0 100644 --- a/src/api/structures/channel.ts +++ b/src/api/structures/channel.ts @@ -2,7 +2,7 @@ import { ChannelCreatePayload, ChannelType, RawOverwrite, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { Collection } from "../../util/collection.ts"; import { createNewProp } from "../../util/utils.ts"; @@ -93,15 +93,15 @@ export interface Channel { // GETTERS - /** + /** * 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. */ guild?: Guild; - /** + /** * 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. */ messages: Collection; diff --git a/src/api/structures/guild.ts b/src/api/structures/guild.ts index 71b4a60c8..2759890e7 100644 --- a/src/api/structures/guild.ts +++ b/src/api/structures/guild.ts @@ -1,6 +1,7 @@ import { botID } from "../../bot.ts"; import { BannedUser, + ChannelCreatePayload, CreateGuildPayload, Emoji, GetAuditLogsOptions, @@ -11,8 +12,9 @@ import { ImageSize, MemberCreatePayload, Presence, + RoleData, VoiceState, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { Collection } from "../../util/collection.ts"; import { createNewProp } from "../../util/utils.ts"; @@ -133,11 +135,13 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) { } = data; 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( - channels.map((c) => structures.createChannel(c, data.id)), + channels.map((c: ChannelCreatePayload) => + structures.createChannel(c, data.id) + ), ); const restProps: Record> = {}; @@ -170,14 +174,14 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) { premiumTier: createNewProp(premiumTier), premiumSubscriptionCount: createNewProp(premiumSubscriptionCount), 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)), 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), voiceStates: createNewProp( - new Collection(voiceStates.map((vs) => [vs.user_id, { + new Collection(voiceStates.map((vs: VoiceState) => [vs.user_id, { ...vs, guildID: vs.guild_id, channelID: vs.channel_id, diff --git a/src/api/structures/member.ts b/src/api/structures/member.ts index 584db9090..78c1a6afd 100644 --- a/src/api/structures/member.ts +++ b/src/api/structures/member.ts @@ -4,7 +4,7 @@ import { GuildMember, MemberCreatePayload, MessageContent, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { Collection } from "../../util/collection.ts"; import { createNewProp } from "../../util/utils.ts"; diff --git a/src/api/structures/message.ts b/src/api/structures/message.ts index a307cefc9..633ba46e1 100644 --- a/src/api/structures/message.ts +++ b/src/api/structures/message.ts @@ -10,7 +10,7 @@ import { Reaction, Reference, UserPayload, -} from "../../types/types.ts"; +} from "../../types/mod.ts"; import { cache } from "../../util/cache.ts"; import { createNewProp } from "../../util/utils.ts"; import { sendMessage } from "../handlers/channel.ts"; diff --git a/src/api/structures/role.ts b/src/api/structures/role.ts index f3bacba3d..49bbb01bc 100644 --- a/src/api/structures/role.ts +++ b/src/api/structures/role.ts @@ -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 { Collection } from "../../util/collection.ts"; import { createNewProp } from "../../util/utils.ts"; diff --git a/src/api/structures/template.ts b/src/api/structures/template.ts index cf76a1efd..faafdda83 100644 --- a/src/api/structures/template.ts +++ b/src/api/structures/template.ts @@ -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 { createNewProp } from "../../util/utils.ts"; import { Guild } from "./guild.ts"; diff --git a/src/bot.ts b/src/bot.ts index 4ada5ec2b..90f4ab0e7 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -3,7 +3,7 @@ import { BotConfig, DiscordBotGatewayData, EventHandlers, -} from "./types/types.ts"; +} from "./types/mod.ts"; import { baseEndpoints, endpoints, GATEWAY_VERSION } from "./util/constants.ts"; import { spawnShards } from "./ws/shard_manager.ts"; diff --git a/src/rest/request_manager.ts b/src/rest/request_manager.ts index 8b09589ee..bce07eee5 100644 --- a/src/rest/request_manager.ts +++ b/src/rest/request_manager.ts @@ -1,5 +1,5 @@ import { authorization, eventHandlers } from "../bot.ts"; -import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts"; +import { Errors, HttpResponseCode, RequestMethods } from "../types/mod.ts"; import { API_VERSION, BASE_URL, diff --git a/src/types/types.ts b/src/types/mod.ts similarity index 94% rename from src/types/types.ts rename to src/types/mod.ts index 52fd33dca..edcb4c0f4 100644 --- a/src/types/types.ts +++ b/src/types/mod.ts @@ -8,7 +8,6 @@ export * from "./guild.ts"; export * from "./interactions.ts"; export * from "./member.ts"; export * from "./message.ts"; -export * from "./misc.ts"; export * from "./options.ts"; export * from "./permission.ts"; export * from "./presence.ts"; diff --git a/src/util/cache.ts b/src/util/cache.ts index fe6f7fe03..e372e32a5 100644 --- a/src/util/cache.ts +++ b/src/util/cache.ts @@ -4,7 +4,7 @@ import { Member, Message, } from "../api/structures/structures.ts"; -import { PresenceUpdatePayload } from "../types/types.ts"; +import { PresenceUpdatePayload } from "../types/mod.ts"; import { Collection } from "./collection.ts"; export interface CacheData { diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 8cc9dfe5f..2dd777025 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../api/controllers/cache.ts"; import { Guild, Role } from "../api/structures/structures.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. */ export async function memberIDHasPermission( diff --git a/src/util/utils.ts b/src/util/utils.ts index f274492a1..38a2b9bb7 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -4,7 +4,7 @@ import { ImageFormats, ImageSize, StatusType, -} from "../types/types.ts"; +} from "../types/mod.ts"; import { sendGatewayCommand } from "../ws/shard_manager.ts"; export const sleep = (timeout: number) => { diff --git a/src/ws/shard.ts b/src/ws/shard.ts index 6678f02cd..b21f48655 100644 --- a/src/ws/shard.ts +++ b/src/ws/shard.ts @@ -10,7 +10,7 @@ import { FetchMembersOptions, GatewayOpcode, ReadyPayload, -} from "../types/types.ts"; +} from "../types/mod.ts"; import { BotStatusRequest, delay } from "../util/utils.ts"; import { decompressWith } from "./deps.ts"; import { handleDiscordPayload } from "./shard_manager.ts"; diff --git a/src/ws/shard_manager.ts b/src/ws/shard_manager.ts index 263aed283..4acfcc319 100644 --- a/src/ws/shard_manager.ts +++ b/src/ws/shard_manager.ts @@ -6,7 +6,7 @@ import { DiscordPayload, FetchMembersOptions, GatewayOpcode, -} from "../types/types.ts"; +} from "../types/mod.ts"; import { cache } from "../util/cache.ts"; import { BotStatusRequest, delay } from "../util/utils.ts"; import {