From 0c1f9529e00a5bde815a9dd59ff40d99a64dd2ff Mon Sep 17 00:00:00 2001 From: Skillz Date: Sun, 20 Sep 2020 19:45:34 -0400 Subject: [PATCH] import type fixes --- src/controllers/bans.ts | 5 +++-- src/controllers/cache.ts | 11 ++++++----- src/controllers/channels.ts | 8 +++++--- src/controllers/guilds.ts | 9 +++++---- src/controllers/members.ts | 11 ++++++----- src/controllers/messages.ts | 9 +++++---- src/controllers/misc.ts | 13 +++++++------ src/controllers/reactions.ts | 9 +++++---- src/controllers/roles.ts | 8 ++++++-- src/handlers/channel.ts | 15 ++++++++------- src/handlers/guild.ts | 29 +++++++++++++++-------------- src/handlers/member.ts | 26 +++++++++++++++----------- src/handlers/message.ts | 13 +++++++------ src/handlers/webhook.ts | 7 ++++--- src/module/basicShard.ts | 28 +++++++++++++--------------- src/module/client.ts | 9 +++++---- src/module/requestManager.ts | 27 ++++++++++++++------------- src/module/shard.ts | 19 ++++++++++--------- src/module/shardingManager.ts | 29 ++++++++++++++--------------- src/structures/channel.ts | 7 ++++--- src/structures/guild.ts | 9 +++++---- src/structures/member.ts | 4 ++-- src/structures/message.ts | 4 ++-- src/structures/role.ts | 4 ++-- src/types/activity.ts | 2 +- src/types/channel.ts | 4 ++-- src/types/discord.ts | 8 ++++---- src/types/fetch.ts | 15 +++++++-------- src/types/guild.ts | 14 +++++++------- src/types/member.ts | 2 +- src/types/message.ts | 8 ++++---- src/types/options.ts | 16 ++++++++-------- src/types/presence.ts | 2 +- src/types/webhook.ts | 4 ++-- src/utils/cache.ts | 10 ++++------ src/utils/cdn.ts | 2 +- src/utils/permissions.ts | 11 +++++------ src/utils/utils.ts | 3 ++- 38 files changed, 217 insertions(+), 197 deletions(-) diff --git a/src/controllers/bans.ts b/src/controllers/bans.ts index fca5c7f6f..2c84ad051 100644 --- a/src/controllers/bans.ts +++ b/src/controllers/bans.ts @@ -1,6 +1,7 @@ +import type { DiscordPayload } from "../types/discord.ts"; +import type { GuildBanPayload } from "../types/guild.ts"; + import { eventHandlers } from "../module/client.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { GuildBanPayload } from "../types/guild.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildBanAdd(data: DiscordPayload) { diff --git a/src/controllers/cache.ts b/src/controllers/cache.ts index 55829c14a..6e336faac 100644 --- a/src/controllers/cache.ts +++ b/src/controllers/cache.ts @@ -1,9 +1,10 @@ -import { Channel } from "../structures/channel.ts"; -import { Guild } from "../structures/guild.ts"; -import { Message } from "../structures/message.ts"; -import { PresenceUpdatePayload } from "../types/discord.ts"; +import type { Channel } from "../structures/channel.ts"; +import type { Guild } from "../structures/guild.ts"; +import type { Message } from "../structures/message.ts"; +import type { PresenceUpdatePayload } from "../types/discord.ts"; +import type { Collection } from "../utils/collection.ts"; + import { cache } from "../utils/cache.ts"; -import { Collection } from "../utils/collection.ts"; export type TableName = | "guilds" diff --git a/src/controllers/channels.ts b/src/controllers/channels.ts index 3d5fb30ee..bdd2cede3 100644 --- a/src/controllers/channels.ts +++ b/src/controllers/channels.ts @@ -1,7 +1,9 @@ -import { ChannelCreatePayload, ChannelTypes } from "../types/channel.ts"; -import { eventHandlers } from "../module/client.ts"; +import type { ChannelCreatePayload } from "../types/channel.ts"; +import type { DiscordPayload } from "../types/discord.ts"; + +import { ChannelTypes } from "../types/channel.ts"; import { structures } from "../structures/mod.ts"; -import { DiscordPayload } from "../types/discord.ts"; +import { eventHandlers } from "../module/client.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalChannelCreate(data: DiscordPayload) { diff --git a/src/controllers/guilds.ts b/src/controllers/guilds.ts index 014e5e0d6..824a62359 100644 --- a/src/controllers/guilds.ts +++ b/src/controllers/guilds.ts @@ -1,14 +1,15 @@ -import { cache } from "../utils/cache.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { +import type { DiscordPayload } from "../types/discord.ts"; +import type { GuildUpdateChange } from "../types/options.ts"; +import type { CreateGuildPayload, GuildDeletePayload, GuildEmojisUpdatePayload, UpdateGuildPayload, } from "../types/guild.ts"; + +import { cache } from "../utils/cache.ts"; import { structures } from "../structures/mod.ts"; import { eventHandlers } from "../module/client.ts"; -import { GuildUpdateChange } from "../types/options.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildCreate( diff --git a/src/controllers/members.ts b/src/controllers/members.ts index 1645beeca..099d1d11c 100644 --- a/src/controllers/members.ts +++ b/src/controllers/members.ts @@ -1,12 +1,13 @@ -import { eventHandlers } from "../module/client.ts"; -import { structures } from "../structures/mod.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { +import type { DiscordPayload } from "../types/discord.ts"; +import type { GuildBanPayload, GuildMemberAddPayload, GuildMemberChunkPayload, GuildMemberUpdatePayload, } from "../types/guild.ts"; + +import { eventHandlers } from "../module/client.ts"; +import { structures } from "../structures/mod.ts"; import { cache } from "../utils/cache.ts"; import { cacheHandlers } from "./cache.ts"; @@ -14,7 +15,7 @@ export async function handleInternalGuildMemberAdd(data: DiscordPayload) { if (data.t !== "GUILD_MEMBER_ADD") return; const payload = data.d as GuildMemberAddPayload; - const guild = await cacheHandlers.get("guilds", payload.guild_id) + const guild = await cacheHandlers.get("guilds", payload.guild_id); if (!guild) return; guild.memberCount++; diff --git a/src/controllers/messages.ts b/src/controllers/messages.ts index eab8a1e51..a805298ef 100644 --- a/src/controllers/messages.ts +++ b/src/controllers/messages.ts @@ -1,11 +1,12 @@ -import { eventHandlers } from "../module/client.ts"; -import { structures } from "../structures/mod.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { +import type { DiscordPayload } from "../types/discord.ts"; +import type { MessageCreateOptions, MessageDeletePayload, MessageDeleteBulkPayload, } from "../types/message.ts"; + +import { eventHandlers } from "../module/client.ts"; +import { structures } from "../structures/mod.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalMessageCreate(data: DiscordPayload) { diff --git a/src/controllers/misc.ts b/src/controllers/misc.ts index 67b2df6bf..7184a3584 100644 --- a/src/controllers/misc.ts +++ b/src/controllers/misc.ts @@ -1,8 +1,5 @@ -import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; -import { eventHandlers, setBotID } from "../module/client.ts"; -import { allowNextShard } from "../module/shardingManager.ts"; -import { structures } from "../structures/mod.ts"; -import { +import type { UserPayload } from "../types/guild.ts"; +import type { DiscordPayload, PresenceUpdatePayload, ReadyPayload, @@ -10,7 +7,11 @@ import { VoiceStateUpdatePayload, WebhookUpdatePayload, } from "../types/discord.ts"; -import { UserPayload } from "../types/guild.ts"; + +import { allowNextShard } from "../module/shardingManager.ts"; +import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; +import { eventHandlers, setBotID } from "../module/client.ts"; +import { structures } from "../structures/mod.ts"; import { cache } from "../utils/cache.ts"; import { cacheHandlers } from "./cache.ts"; diff --git a/src/controllers/reactions.ts b/src/controllers/reactions.ts index 3e867a9b8..e65d93f69 100644 --- a/src/controllers/reactions.ts +++ b/src/controllers/reactions.ts @@ -1,11 +1,12 @@ -import { botID, eventHandlers } from "../module/client.ts"; -import { structures } from "../structures/mod.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { +import type { DiscordPayload } from "../types/discord.ts"; +import type { BaseMessageReactionPayload, MessageReactionPayload, MessageReactionRemoveEmojiPayload, } from "../types/message.ts"; + +import { botID, eventHandlers } from "../module/client.ts"; +import { structures } from "../structures/mod.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalMessageReactionAdd(data: DiscordPayload) { diff --git a/src/controllers/roles.ts b/src/controllers/roles.ts index 695af4c61..6ac8527ac 100644 --- a/src/controllers/roles.ts +++ b/src/controllers/roles.ts @@ -1,7 +1,11 @@ +import type { DiscordPayload } from "../types/discord.ts"; +import type { + GuildRoleDeletePayload, + GuildRolePayload, +} from "../types/guild.ts"; + import { eventHandlers } from "../module/client.ts"; import { structures } from "../structures/mod.ts"; -import { DiscordPayload } from "../types/discord.ts"; -import { GuildRoleDeletePayload, GuildRolePayload } from "../types/guild.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildRoleCreate(data: DiscordPayload) { diff --git a/src/handlers/channel.ts b/src/handlers/channel.ts index add8509d6..1e8b56430 100644 --- a/src/handlers/channel.ts +++ b/src/handlers/channel.ts @@ -1,9 +1,4 @@ -import { Permissions } from "../types/permission.ts"; -import { botHasChannelPermissions } from "../utils/permissions.ts"; -import { Errors } from "../types/errors.ts"; -import { RequestManager } from "../module/requestManager.ts"; -import { endpoints } from "../constants/discord.ts"; -import { MessageCreateOptions } from "../types/message.ts"; +import type { MessageCreateOptions } from "../types/message.ts"; import { GetMessagesAfter, GetMessagesBefore, @@ -14,9 +9,15 @@ import { ChannelEditOptions, FollowedChannelPayload, } from "../types/channel.ts"; +import type { RawOverwrite } from "../types/guild.ts"; + import { logYellow } from "../utils/logger.ts"; +import { endpoints } from "../constants/discord.ts"; +import { RequestManager } from "../module/requestManager.ts"; +import { Errors } from "../types/errors.ts"; +import { Permissions } from "../types/permission.ts"; +import { botHasChannelPermissions } from "../utils/permissions.ts"; import { structures } from "../structures/mod.ts"; -import { RawOverwrite } from "../types/guild.ts"; /** Checks if a channel overwrite for a user id or a role id has permission in this channel */ export function channelOverwriteHasPermission( diff --git a/src/handlers/guild.ts b/src/handlers/guild.ts index 7492ecf57..de07a76d4 100644 --- a/src/handlers/guild.ts +++ b/src/handlers/guild.ts @@ -1,16 +1,10 @@ -import { Guild } from "../structures/guild.ts"; -import { formatImageURL } from "../utils/cdn.ts"; -import { botHasPermission } from "../utils/permissions.ts"; -import { RequestManager } from "../module/requestManager.ts"; -import { endpoints } from "../constants/discord.ts"; -import { Errors } from "../types/errors.ts"; -import { Permissions } from "../types/permission.ts"; +import type { Guild } from "../structures/guild.ts"; import { ChannelCreatePayload, ChannelTypes, } from "../types/channel.ts"; -import { ImageFormats, ImageSize } from "../types/cdn.ts"; -import { +import type { ImageFormats, ImageSize } from "../types/cdn.ts"; +import type { CreateEmojisOptions, PositionSwap, EditEmojisOptions, @@ -26,16 +20,23 @@ import { BannedUser, UserPayload, } from "../types/guild.ts"; -import { RoleData } from "../types/role.ts"; +import type { RoleData } from "../types/role.ts"; +import type { MemberCreatePayload } from "../types/member.ts"; +import type { Member } from "../structures/member.ts"; + +import { Collection } from "../utils/collection.ts"; +import { urlToBase64 } from "../utils/utils.ts"; import { Intents } from "../types/options.ts"; import { identifyPayload } from "../module/client.ts"; import { requestAllMembers } from "../module/shardingManager.ts"; -import { MemberCreatePayload } from "../types/member.ts"; -import { Member } from "../structures/member.ts"; -import { urlToBase64 } from "../utils/utils.ts"; -import { Collection } from "../utils/collection.ts"; +import { botHasPermission } from "../utils/permissions.ts"; +import { RequestManager } from "../module/requestManager.ts"; +import { endpoints } from "../constants/discord.ts"; +import { Errors } from "../types/errors.ts"; +import { Permissions } from "../types/permission.ts"; import { structures } from "../structures/mod.ts"; import { cacheHandlers } from "../controllers/cache.ts"; +import { formatImageURL } from "../utils/cdn.ts"; /** Gets an array of all the channels ids that are the children of this category. */ export function categoryChildrenIDs(guild: Guild, id: string) { diff --git a/src/handlers/member.ts b/src/handlers/member.ts index 54a2a963a..245e0fc49 100644 --- a/src/handlers/member.ts +++ b/src/handlers/member.ts @@ -1,21 +1,25 @@ -import { Member } from "../structures/member.ts"; -import { ImageSize, ImageFormats } from "../types/cdn.ts"; +import type { Member } from "../structures/member.ts"; +import type { ImageSize, ImageFormats } from "../types/cdn.ts"; +import type { + MessageContent, + DMChannelCreatePayload, +} from "../types/channel.ts"; +import type { EditMemberOptions } from "../types/member.ts"; + +import { sendMessage } from "./channel.ts"; +import { structures } from "../structures/mod.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; import { formatImageURL } from "../utils/cdn.ts"; import { endpoints } from "../constants/discord.ts"; +import { botID } from "../module/client.ts"; +import { Permissions } from "../types/permission.ts"; +import { Errors } from "../types/errors.ts"; +import { RequestManager } from "../module/requestManager.ts"; import { highestRole, higherRolePosition, botHasPermission, } from "../utils/permissions.ts"; -import { botID } from "../module/client.ts"; -import { Permissions } from "../types/permission.ts"; -import { Errors } from "../types/errors.ts"; -import { RequestManager } from "../module/requestManager.ts"; -import { MessageContent, DMChannelCreatePayload } from "../types/channel.ts"; -import { EditMemberOptions } from "../types/member.ts"; -import { sendMessage } from "./channel.ts"; -import { structures } from "../structures/mod.ts"; -import { cacheHandlers } from "../controllers/cache.ts"; /** The users custom avatar or the default avatar if you don't have a member object. */ export function rawAvatarURL( diff --git a/src/handlers/message.ts b/src/handlers/message.ts index 6d6758cd6..a1d95cdc9 100644 --- a/src/handlers/message.ts +++ b/src/handlers/message.ts @@ -1,16 +1,17 @@ -import { Message } from "../structures/message.ts"; +import type { Message } from "../structures/message.ts"; +import type { MessageContent } from "../types/channel.ts"; +import type { UserPayload } from "../types/guild.ts"; +import type { MessageCreateOptions } from "../types/message.ts"; + import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; +import { structures } from "../structures/mod.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; import { botID } from "../module/client.ts"; import { Permissions } from "../types/permission.ts"; import { Errors } from "../types/errors.ts"; import { RequestManager } from "../module/requestManager.ts"; import { endpoints } from "../constants/discord.ts"; import { botHasChannelPermissions } from "../utils/permissions.ts"; -import { MessageContent } from "../types/channel.ts"; -import { UserPayload } from "../types/guild.ts"; -import { MessageCreateOptions } from "../types/message.ts"; -import { structures } from "../structures/mod.ts"; -import { cacheHandlers } from "../controllers/cache.ts"; /** Delete a message */ export async function deleteMessage( diff --git a/src/handlers/webhook.ts b/src/handlers/webhook.ts index 4cfab57b0..2b139307e 100644 --- a/src/handlers/webhook.ts +++ b/src/handlers/webhook.ts @@ -1,14 +1,15 @@ -import { +import type { WebhookCreateOptions, WebhookPayload, ExecuteWebhookOptions, } from "../types/webhook.ts"; +import type { MessageCreateOptions } from "../types/message.ts"; + import { botHasChannelPermissions } from "../utils/permissions.ts"; import { Permissions } from "../types/permission.ts"; import { Errors } from "../types/errors.ts"; import { RequestManager } from "../module/requestManager.ts"; import { endpoints } from "../constants/discord.ts"; -import { MessageCreateOptions } from "../types/message.ts"; import { urlToBase64 } from "../utils/utils.ts"; import { structures } from "../structures/mod.ts"; @@ -102,5 +103,5 @@ export async function executeWebhook( } export function getWebhook(webhookID: string) { - return RequestManager.get(endpoints.WEBHOOK_ID(webhookID)) + return RequestManager.get(endpoints.WEBHOOK_ID(webhookID)); } diff --git a/src/module/basicShard.ts b/src/module/basicShard.ts index 4cf2cfc3e..8935ab09f 100644 --- a/src/module/basicShard.ts +++ b/src/module/basicShard.ts @@ -1,24 +1,22 @@ -import { - DiscordBotGatewayData, - GatewayOpcode, - ReadyPayload, -} from "../types/discord.ts"; -import { - eventHandlers, - botGatewayData, - IdentifyPayload, -} from "./client.ts"; -import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; +import type { DiscordBotGatewayData, ReadyPayload } from "../types/discord.ts"; +import type { IdentifyPayload } from "./client.ts"; import { connectWebSocket, isWebSocketCloseEvent, WebSocket, } from "https://deno.land/std@0.67.0/ws/mod.ts"; -import { DiscordHeartbeatPayload } from "../types/discord.ts"; -import { logRed } from "../utils/logger.ts"; +import type { DiscordHeartbeatPayload } from "../types/discord.ts"; +import type { FetchMembersOptions } from "../types/guild.ts"; +import type { BotStatusRequest } from "../utils/utils.ts"; + import { handleDiscordPayload } from "./shardingManager.ts"; -import { FetchMembersOptions } from "../types/guild.ts"; -import { BotStatusRequest } from "../utils/utils.ts"; +import { logRed } from "../utils/logger.ts"; +import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; +import { GatewayOpcode } from "../types/discord.ts"; +import { + eventHandlers, + botGatewayData, +} from "./client.ts"; const basicShards = new Map(); const heartbeating = new Set(); diff --git a/src/module/client.ts b/src/module/client.ts index a05d4f261..8a098bbaf 100644 --- a/src/module/client.ts +++ b/src/module/client.ts @@ -1,8 +1,9 @@ -import { endpoints } from "../constants/discord.ts"; -import { DiscordBotGatewayData } from "../types/discord.ts"; -import { ClientOptions, EventHandlers } from "../types/options.ts"; -import { RequestManager } from "./requestManager.ts"; +import type { ClientOptions, EventHandlers } from "../types/options.ts"; +import type { DiscordBotGatewayData } from "../types/discord.ts"; + import { spawnShards } from "./shardingManager.ts"; +import { endpoints } from "../constants/discord.ts"; +import { RequestManager } from "./requestManager.ts"; export let authorization = ""; export let botID = ""; diff --git a/src/module/requestManager.ts b/src/module/requestManager.ts index a7c3ebd9a..b79b06b33 100644 --- a/src/module/requestManager.ts +++ b/src/module/requestManager.ts @@ -1,10 +1,11 @@ -import { RequestMethod } from "../types/fetch.ts"; -import { authorization, eventHandlers } from "./client.ts"; -import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; -import { Errors } from "../types/errors.ts"; import { HttpResponseCode } from "../types/discord.ts"; -import { logRed } from "../utils/logger.ts"; +import { authorization, eventHandlers } from "./client.ts"; import { baseEndpoints } from "../constants/discord.ts"; +import type { RequestMethods } from "../types/fetch.ts"; + +import { Errors } from "../types/errors.ts"; +import { logRed } from "../utils/logger.ts"; +import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; const pathQueues: { [key: string]: QueuedRequest[] } = {}; const ratelimitedPaths = new Map(); @@ -121,23 +122,23 @@ processRateLimitedPaths(); export const RequestManager = { get: async (url: string, body?: unknown) => { - return runMethod(RequestMethod.Get, url, body); + return runMethod("get", url, body); }, post: (url: string, body?: unknown) => { - return runMethod(RequestMethod.Post, url, body); + return runMethod("post", url, body); }, delete: (url: string, body?: unknown) => { - return runMethod(RequestMethod.Delete, url, body); + return runMethod("delete", url, body); }, patch: (url: string, body?: unknown) => { - return runMethod(RequestMethod.Patch, url, body); + return runMethod("patch", url, body); }, put: (url: string, body?: unknown) => { - return runMethod(RequestMethod.Put, url, body); + return runMethod("put", url, body); }, }; -function createRequestBody(body: any, method: RequestMethod) { +function createRequestBody(body: any, method: RequestMethods) { const headers: { [key: string]: string } = { Authorization: authorization, "User-Agent": @@ -156,7 +157,7 @@ function createRequestBody(body: any, method: RequestMethod) { form.append("payload_json", JSON.stringify({ ...body, file: undefined })); body.file = form; } else if ( - body && ![RequestMethod.Get, RequestMethod.Delete].includes(method) + body && !["get", "delete"].includes(method) ) { headers["Content-Type"] = "application/json"; } @@ -184,7 +185,7 @@ async function checkRatelimits(url: string) { } async function runMethod( - method: RequestMethod, + method: RequestMethods, url: string, body?: unknown, retryCount = 0, diff --git a/src/module/shard.ts b/src/module/shard.ts index b65eb3b19..2b033db73 100644 --- a/src/module/shard.ts +++ b/src/module/shard.ts @@ -1,18 +1,19 @@ -import { - connectWebSocket, - isWebSocketCloseEvent, - WebSocket, -} from "https://deno.land/std@0.67.0/ws/mod.ts"; -import { - GatewayOpcode, +import type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts"; +import type { DiscordBotGatewayData, DiscordHeartbeatPayload, ReadyPayload, } from "../types/discord.ts"; +import type { FetchMembersOptions } from "../types/guild.ts"; +import type { DebugArg } from "../types/options.ts"; + +import { GatewayOpcode } from "../types/discord.ts"; import { logRed } from "../utils/logger.ts"; -import { FetchMembersOptions } from "../types/guild.ts"; import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; -import { DebugArg } from "../types/options.ts"; +import { + connectWebSocket, + isWebSocketCloseEvent, +} from "https://deno.land/std@0.67.0/ws/mod.ts"; let shardSocket: WebSocket; diff --git a/src/module/shardingManager.ts b/src/module/shardingManager.ts index 153e15065..815585e76 100644 --- a/src/module/shardingManager.ts +++ b/src/module/shardingManager.ts @@ -1,27 +1,26 @@ -import { +import type { IdentifyPayload } from "./client.ts"; +import type { Guild } from "../structures/guild.ts"; +import type { FetchMembersOptions } from "../types/guild.ts"; +import type { DiscordBotGatewayData, DiscordPayload, - GatewayOpcode, } from "../types/discord.ts"; -import { - eventHandlers, - botGatewayData, - identifyPayload, - IdentifyPayload, -} from "./client.ts"; -import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; -import { Guild } from "../structures/guild.ts"; -import { - FetchMembersOptions, -} from "../types/guild.ts"; +import type { BotStatusRequest } from "../utils/utils.ts"; + +import { controllers } from "../controllers/mod.ts"; import { cache } from "../utils/cache.ts"; import { createBasicShard, requestGuildMembers, botGatewayStatusRequest, } from "./basicShard.ts"; -import { BotStatusRequest } from "../utils/utils.ts"; -import { controllers } from "../controllers/mod.ts"; +import { + eventHandlers, + botGatewayData, + identifyPayload, +} from "./client.ts"; +import { GatewayOpcode } from "../types/discord.ts"; +import { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; let shardCounter = 0; let basicSharding = false; diff --git a/src/structures/channel.ts b/src/structures/channel.ts index 6ce23b6d4..31dd876c3 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -1,7 +1,8 @@ -import { ChannelCreatePayload } from "../types/channel.ts"; -import { calculatePermissions } from "../utils/permissions.ts"; +import type { ChannelCreatePayload } from "../types/channel.ts"; +import type { Unpromise } from "../types/misc.ts"; + import { cacheHandlers } from "../controllers/cache.ts"; -import { Unpromise } from "../types/misc.ts"; +import { calculatePermissions } from "../utils/permissions.ts"; export async function createChannel( data: ChannelCreatePayload, diff --git a/src/structures/guild.ts b/src/structures/guild.ts index 346ef4c78..74a7c7a2e 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -1,8 +1,9 @@ -import { CreateGuildPayload } from "../types/guild.ts"; -import { Collection } from "../utils/collection.ts"; +import type { CreateGuildPayload } from "../types/guild.ts"; +import type { Member } from "./member.ts"; +import type { Unpromise } from "../types/misc.ts"; + import { structures } from "./mod.ts"; -import { Member } from "./member.ts"; -import { Unpromise } from "../types/misc.ts"; +import { Collection } from "../utils/collection.ts"; export async function createGuild(data: CreateGuildPayload, shardID: number) { const { diff --git a/src/structures/member.ts b/src/structures/member.ts index 97e91e832..a62391876 100644 --- a/src/structures/member.ts +++ b/src/structures/member.ts @@ -1,5 +1,5 @@ -import { MemberCreatePayload } from "../types/member.ts"; -import { Unpromise } from "../types/misc.ts"; +import type { MemberCreatePayload } from "../types/member.ts"; +import type { Unpromise } from "../types/misc.ts"; export async function createMember(data: MemberCreatePayload, guildID: string) { const { diff --git a/src/structures/message.ts b/src/structures/message.ts index 4d56a3b9b..4c97ed728 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -1,5 +1,5 @@ -import { MessageCreateOptions } from "../types/message.ts"; -import { Unpromise } from "../types/misc.ts"; +import type { MessageCreateOptions } from "../types/message.ts"; +import type { Unpromise } from "../types/misc.ts"; export async function createMessage(data: MessageCreateOptions) { const { diff --git a/src/structures/role.ts b/src/structures/role.ts index 8f8f87e3d..6aaba4e5a 100644 --- a/src/structures/role.ts +++ b/src/structures/role.ts @@ -1,5 +1,5 @@ -import { Unpromise } from "../types/misc.ts"; -import { RoleData } from "../types/role.ts"; +import type { Unpromise } from "../types/misc.ts"; +import type { RoleData } from "../types/role.ts"; export async function createRole(data: RoleData) { return { diff --git a/src/types/activity.ts b/src/types/activity.ts index 08c660dea..81a180b4b 100644 --- a/src/types/activity.ts +++ b/src/types/activity.ts @@ -1,4 +1,4 @@ -import { Timestamps } from "./discord.ts"; +import type { Timestamps } from "./discord.ts"; export interface ActivityPayload { name: string; diff --git a/src/types/channel.ts b/src/types/channel.ts index c13288575..e7b7c1401 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -1,5 +1,5 @@ -import { RawOverwrite, Overwrite } from "./guild.ts"; -import { Embed } from "./message.ts"; +import type { RawOverwrite, Overwrite } from "./guild.ts"; +import type { Embed } from "./message.ts"; export interface ChannelEditOptions { /** 2-100 character channel name. All */ diff --git a/src/types/discord.ts b/src/types/discord.ts index ee6b34ee9..b063e1e67 100644 --- a/src/types/discord.ts +++ b/src/types/discord.ts @@ -1,7 +1,7 @@ -import { Activity } from "./message.ts"; -import { ClientStatusPayload } from "./presence.ts"; -import { PartialUser, UserPayload } from "./guild.ts"; -import { MemberCreatePayload } from "./member.ts"; +import type { Activity } from "./message.ts"; +import type { ClientStatusPayload } from "./presence.ts"; +import type { PartialUser, UserPayload } from "./guild.ts"; +import type { MemberCreatePayload } from "./member.ts"; export interface DiscordPayload { /** OP code for the payload */ diff --git a/src/types/fetch.ts b/src/types/fetch.ts index 6e92938e2..db9735204 100644 --- a/src/types/fetch.ts +++ b/src/types/fetch.ts @@ -1,8 +1,7 @@ -export const enum RequestMethod { - Get = "get", - Post = "post", - Put = "put", - Patch = "patch", - Head = "head", - Delete = "delete", -} +export type RequestMethods = + | "get" + | "post" + | "put" + | "patch" + | "head" + | "delete"; diff --git a/src/types/guild.ts b/src/types/guild.ts index dff9612e0..3be883ddf 100644 --- a/src/types/guild.ts +++ b/src/types/guild.ts @@ -1,10 +1,10 @@ -import { Emoji, StatusType } from "./discord.ts"; -import { Permission } from "./permission.ts"; -import { RoleData } from "./role.ts"; -import { MemberCreatePayload } from "./member.ts"; -import { Activity } from "./message.ts"; -import { ClientStatusPayload } from "./presence.ts"; -import { ChannelCreatePayload, ChannelTypes } from "./channel.ts"; +import type { Emoji, StatusType } from "./discord.ts"; +import type { Permission } from "./permission.ts"; +import type { RoleData } from "./role.ts"; +import type { MemberCreatePayload } from "./member.ts"; +import type { Activity } from "./message.ts"; +import type { ClientStatusPayload } from "./presence.ts"; +import type { ChannelCreatePayload, ChannelTypes } from "./channel.ts"; export interface GuildRolePayload { /** The id of the guild */ diff --git a/src/types/member.ts b/src/types/member.ts index 199e0fef5..a68f7c887 100644 --- a/src/types/member.ts +++ b/src/types/member.ts @@ -1,4 +1,4 @@ -import { UserPayload } from "./guild.ts"; +import type { UserPayload } from "./guild.ts"; export interface EditMemberOptions { /** Value to set users nickname to. Requires MANAGE_NICKNAMES permission. */ diff --git a/src/types/message.ts b/src/types/message.ts index 1fff0f9ba..66b082e5d 100644 --- a/src/types/message.ts +++ b/src/types/message.ts @@ -1,7 +1,7 @@ -import { UserPayload } from "./guild.ts"; -import { MemberCreatePayload } from "./member.ts"; -import { Channel } from "../structures/channel.ts"; -import { ChannelType } from "./channel.ts"; +import type { UserPayload } from "./guild.ts"; +import type { MemberCreatePayload } from "./member.ts"; +import type { Channel } from "../structures/channel.ts"; +import type { ChannelType } from "./channel.ts"; export interface MentionedUser extends UserPayload { member: MemberCreatePayload; diff --git a/src/types/options.ts b/src/types/options.ts index 6cec21fd6..a44519fee 100644 --- a/src/types/options.ts +++ b/src/types/options.ts @@ -1,4 +1,4 @@ -import { +import type { Properties, Emoji, DiscordPayload, @@ -6,9 +6,9 @@ import { TypingStartPayload, VoiceStateUpdatePayload, } from "./discord.ts"; -import { Role } from "../structures/role.ts"; -import { Message } from "../structures/message.ts"; -import { +import type { Role } from "../structures/role.ts"; +import type { Message } from "../structures/message.ts"; +import type { PartialMessage, ReactionPayload, BaseMessageReactionPayload, @@ -17,10 +17,10 @@ import { Attachment, MessageReactionUncachedPayload, } from "./message.ts"; -import { Channel } from "../structures/channel.ts"; -import { Guild } from "../structures/guild.ts"; -import { Member } from "../structures/member.ts"; -import { UserPayload } from "./guild.ts"; +import type { Channel } from "../structures/channel.ts"; +import type { Guild } from "../structures/guild.ts"; +import type { Member } from "../structures/member.ts"; +import type { UserPayload } from "./guild.ts"; export interface Fulfilled_Client_Options { token: string; diff --git a/src/types/presence.ts b/src/types/presence.ts index e2ebd6f73..1efc05220 100644 --- a/src/types/presence.ts +++ b/src/types/presence.ts @@ -1,4 +1,4 @@ -import { StatusType } from "./discord.ts"; +import type { StatusType } from "./discord.ts"; export interface ClientStatusPayload { /** The user's status set for an active desktop (Windows, Linux, Mac) application session */ diff --git a/src/types/webhook.ts b/src/types/webhook.ts index 8974e6575..81adb0c13 100644 --- a/src/types/webhook.ts +++ b/src/types/webhook.ts @@ -1,5 +1,5 @@ -import { UserPayload } from "./guild.ts"; -import { Embed } from "./message.ts"; +import type { UserPayload } from "./guild.ts"; +import type { Embed } from "./message.ts"; export interface WebhookPayload { /** The id of the webhook */ diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 0797c6769..7042b504e 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -1,8 +1,8 @@ import { Collection } from "./collection.ts"; -import { Message } from "../structures/message.ts"; -import { Guild } from "../structures/guild.ts"; -import { Channel } from "../structures/channel.ts"; -import { PresenceUpdatePayload } from "../types/discord.ts"; +import type { Message } from "../structures/message.ts"; +import type { Guild } from "../structures/guild.ts"; +import type { Channel } from "../structures/channel.ts"; +import type { PresenceUpdatePayload } from "../types/discord.ts"; export interface CacheData { isReady: boolean; @@ -23,5 +23,3 @@ export const cache: CacheData = { presences: new Collection(), fetchAllMembersProcessingRequests: new Collection(), }; - - diff --git a/src/utils/cdn.ts b/src/utils/cdn.ts index d93c5e1fe..ca4e2b22a 100644 --- a/src/utils/cdn.ts +++ b/src/utils/cdn.ts @@ -1,4 +1,4 @@ -import { ImageSize, ImageFormats } from "../types/cdn.ts"; +import type { ImageSize, ImageFormats } from "../types/cdn.ts"; export const formatImageURL = ( url: string, diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index 468025864..143aff73d 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -1,10 +1,9 @@ -import { - Permission, - Permissions, -} from "../types/permission.ts"; +import type { Permission } from "../types/permission.ts"; +import type { Role } from "../structures/role.ts"; +import type { Guild } from "../structures/guild.ts"; + +import { Permissions } from "../types/permission.ts"; import { botID } from "../module/client.ts"; -import { Role } from "../structures/role.ts"; -import { Guild } from "../structures/guild.ts"; import { cacheHandlers } from "../controllers/cache.ts"; /** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */ diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 26075b885..24d0a5183 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,4 +1,5 @@ -import { StatusType } from "../types/discord.ts"; +import type { StatusType } from "../types/discord.ts"; + import { ActivityType } from "../types/activity.ts"; import { sendGatewayCommand } from "../module/shardingManager.ts"; import { encode } from "https://deno.land/std@0.67.0/encoding/base64.ts";