From 8e3fab74115c402ce9d8fa30b971890e1799e072 Mon Sep 17 00:00:00 2001 From: ayntee Date: Thu, 24 Dec 2020 17:59:15 +0400 Subject: [PATCH] fix: remove util/cdn export --- mod.ts | 7 +++---- src/api/controllers/cache.ts | 2 +- src/api/controllers/channels.ts | 2 +- src/api/controllers/guilds.ts | 2 +- src/api/controllers/interactions.ts | 6 ++++-- src/api/controllers/members.ts | 2 +- src/api/controllers/messages.ts | 2 +- src/api/controllers/misc.ts | 10 +++++----- src/api/controllers/mod.ts | 8 ++++---- src/api/controllers/reactions.ts | 2 +- src/api/controllers/roles.ts | 2 +- src/api/handlers/channel.ts | 4 ++-- src/api/handlers/guild.ts | 19 +++++++++---------- src/api/handlers/member.ts | 7 +++---- src/api/handlers/message.ts | 4 ++-- src/api/handlers/webhook.ts | 6 +++--- src/api/structures/channel.ts | 2 +- src/api/structures/member.ts | 2 +- src/interactions/types/interactions.ts | 2 +- src/interactions/types/mod.ts | 2 +- src/rest/request_manager.ts | 2 +- src/types/types.ts | 2 +- src/util/permissions.ts | 2 +- src/ws/shard_manager.ts | 2 +- 24 files changed, 50 insertions(+), 51 deletions(-) diff --git a/mod.ts b/mod.ts index 8dfbc97a0..544dac3bb 100644 --- a/mod.ts +++ b/mod.ts @@ -13,15 +13,14 @@ export * from "./src/api/handlers/guild.ts"; export * from "./src/api/handlers/member.ts"; export * from "./src/api/handlers/message.ts"; export * from "./src/api/handlers/webhook.ts"; -export * from "./src/bot.ts"; -export * from "./src/rest/mod.ts"; -export * from "./src/ws/mod.ts"; export * from "./src/api/structures/channel.ts"; export * from "./src/api/structures/guild.ts"; export * from "./src/api/structures/member.ts"; export * from "./src/api/structures/message.ts"; export * from "./src/api/structures/mod.ts"; export * from "./src/api/structures/role.ts"; +export * from "./src/bot.ts"; +export * from "./src/rest/mod.ts"; export * from "./src/types/activity.ts"; export * from "./src/types/cdn.ts"; export * from "./src/types/channel.ts"; @@ -36,7 +35,7 @@ export * from "./src/types/permission.ts"; export * from "./src/types/presence.ts"; export * from "./src/types/role.ts"; export * from "./src/util/cache.ts"; -export * from "./src/util/cdn.ts"; export * from "./src/util/collection.ts"; export * from "./src/util/permissions.ts"; export * from "./src/util/utils.ts"; +export * from "./src/ws/mod.ts"; diff --git a/src/api/controllers/cache.ts b/src/api/controllers/cache.ts index 10edc18ba..5e82b398e 100644 --- a/src/api/controllers/cache.ts +++ b/src/api/controllers/cache.ts @@ -1,7 +1,7 @@ -import { Channel, Guild, Member, Message } from "../structures/structures.ts"; import { PresenceUpdatePayload } from "../../types/types.ts"; import { cache } from "../../util/cache.ts"; import { Collection } from "../../util/collection.ts"; +import { Channel, Guild, Member, Message } from "../structures/structures.ts"; export type TableName = | "guilds" diff --git a/src/api/controllers/channels.ts b/src/api/controllers/channels.ts index f967c1830..79f34f0af 100644 --- a/src/api/controllers/channels.ts +++ b/src/api/controllers/channels.ts @@ -1,10 +1,10 @@ import { eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { ChannelCreatePayload, ChannelTypes, DiscordPayload, } from "../../types/types.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalChannelCreate(data: DiscordPayload) { diff --git a/src/api/controllers/guilds.ts b/src/api/controllers/guilds.ts index c8c2d41fe..c277e9b60 100644 --- a/src/api/controllers/guilds.ts +++ b/src/api/controllers/guilds.ts @@ -1,5 +1,4 @@ import { eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { CreateGuildPayload, DiscordPayload, @@ -9,6 +8,7 @@ import { UpdateGuildPayload, } from "../../types/types.ts"; import { cache } from "../../util/cache.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildCreate( diff --git a/src/api/controllers/interactions.ts b/src/api/controllers/interactions.ts index 7e99e3a5b..bcb4b6b64 100644 --- a/src/api/controllers/interactions.ts +++ b/src/api/controllers/interactions.ts @@ -1,7 +1,9 @@ -import { DiscordPayload } from "../../types/types.ts"; import { eventHandlers } from "../../bot.ts"; +import { + DiscordPayload, + InteractionCommandPayload, +} from "../../types/types.ts"; import { structures } from "../structures/mod.ts"; -import { InteractionCommandPayload } from "../../types/types.ts"; export async function handleInternalInteractionsCreate(data: DiscordPayload) { if (data.t !== "INTERACTION_CREATE") return; diff --git a/src/api/controllers/members.ts b/src/api/controllers/members.ts index 1e7983ca8..26c8c1235 100644 --- a/src/api/controllers/members.ts +++ b/src/api/controllers/members.ts @@ -1,5 +1,4 @@ import { eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { DiscordPayload, GuildBanPayload, @@ -8,6 +7,7 @@ import { GuildMemberUpdatePayload, } from "../../types/types.ts"; import { cache } from "../../util/cache.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildMemberAdd(data: DiscordPayload) { diff --git a/src/api/controllers/messages.ts b/src/api/controllers/messages.ts index 5a2d62ae6..170981986 100644 --- a/src/api/controllers/messages.ts +++ b/src/api/controllers/messages.ts @@ -1,11 +1,11 @@ import { eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { DiscordPayload, MessageCreateOptions, MessageDeleteBulkPayload, MessageDeletePayload, } from "../../types/types.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalMessageCreate(data: DiscordPayload) { diff --git a/src/api/controllers/misc.ts b/src/api/controllers/misc.ts index bf23d8966..7896d4b00 100644 --- a/src/api/controllers/misc.ts +++ b/src/api/controllers/misc.ts @@ -1,9 +1,4 @@ -import { - initialMemberLoadQueue, - structures, -} from "../structures/structures.ts"; import { eventHandlers, setBotID } from "../../bot.ts"; -import { allowNextShard } from "../../ws/shard_manager.ts"; import { DiscordPayload, PresenceUpdatePayload, @@ -15,6 +10,11 @@ import { } from "../../types/types.ts"; import { cache } from "../../util/cache.ts"; import { delay } from "../../util/utils.ts"; +import { allowNextShard } from "../../ws/shard_manager.ts"; +import { + initialMemberLoadQueue, + structures, +} from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalReady( diff --git a/src/api/controllers/mod.ts b/src/api/controllers/mod.ts index bdd216388..c4137f31b 100644 --- a/src/api/controllers/mod.ts +++ b/src/api/controllers/mod.ts @@ -13,6 +13,10 @@ import { handleInternalGuildEmojisUpdate, handleInternalGuildUpdate, } from "./guilds.ts"; +import { + handleInternalInteractionsCommandCreate, + handleInternalInteractionsCreate, +} from "./interactions.ts"; import { handleInternalGuildMemberAdd, handleInternalGuildMemberRemove, @@ -44,10 +48,6 @@ import { handleInternalGuildRoleDelete, handleInternalGuildRoleUpdate, } from "./roles.ts"; -import { - handleInternalInteractionsCommandCreate, - handleInternalInteractionsCreate, -} from "./interactions.ts"; export let controllers = { READY: handleInternalReady, diff --git a/src/api/controllers/reactions.ts b/src/api/controllers/reactions.ts index d0a19fc9d..beb3f6982 100644 --- a/src/api/controllers/reactions.ts +++ b/src/api/controllers/reactions.ts @@ -1,11 +1,11 @@ import { botID, eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { BaseMessageReactionPayload, DiscordPayload, MessageReactionPayload, MessageReactionRemoveEmojiPayload, } from "../../types/types.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalMessageReactionAdd(data: DiscordPayload) { diff --git a/src/api/controllers/roles.ts b/src/api/controllers/roles.ts index 95a8f439a..57a3bf424 100644 --- a/src/api/controllers/roles.ts +++ b/src/api/controllers/roles.ts @@ -1,10 +1,10 @@ import { eventHandlers } from "../../bot.ts"; -import { structures } from "../structures/structures.ts"; import { DiscordPayload, GuildRoleDeletePayload, GuildRolePayload, } from "../../types/types.ts"; +import { structures } from "../structures/structures.ts"; import { cacheHandlers } from "./cache.ts"; export async function handleInternalGuildRoleCreate(data: DiscordPayload) { diff --git a/src/api/handlers/channel.ts b/src/api/handlers/channel.ts index 205882d00..340d452b0 100644 --- a/src/api/handlers/channel.ts +++ b/src/api/handlers/channel.ts @@ -1,6 +1,4 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { RequestManager } from "../../rest/mod.ts"; -import { structures } from "../structures/structures.ts"; import { ChannelEditOptions, ChannelTypes, @@ -23,6 +21,8 @@ import { botHasChannelPermissions, calculateBits, } from "../../util/permissions.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; +import { structures } from "../structures/structures.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/api/handlers/guild.ts b/src/api/handlers/guild.ts index 69a1f3193..22f002881 100644 --- a/src/api/handlers/guild.ts +++ b/src/api/handlers/guild.ts @@ -1,13 +1,5 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { identifyPayload } from "../../bot.ts"; import { RequestManager } from "../../rest/mod.ts"; -import { requestAllMembers } from "../../ws/shard_manager.ts"; -import { - Guild, - Member, - structures, - Template, -} from "../structures/structures.ts"; import { AuditLogs, BannedUser, @@ -40,11 +32,18 @@ import { UpdateGuildPayload, UserPayload, } from "../../types/types.ts"; -import { formatImageURL } from "../../util/cdn.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasPermission, calculateBits } from "../../util/permissions.ts"; -import { urlToBase64 } from "../../util/utils.ts"; +import { formatImageURL, urlToBase64 } from "../../util/utils.ts"; +import { requestAllMembers } from "../../ws/shard_manager.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; +import { + Guild, + Member, + structures, + Template, +} from "../structures/structures.ts"; /** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */ export async function createServer(options: CreateServerOptions) { diff --git a/src/api/handlers/member.ts b/src/api/handlers/member.ts index 7abb1840b..71965e557 100644 --- a/src/api/handlers/member.ts +++ b/src/api/handlers/member.ts @@ -1,7 +1,5 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { botID } from "../../bot.ts"; import { RequestManager } from "../../rest/mod.ts"; -import { Member, structures } from "../structures/structures.ts"; import { DMChannelCreatePayload, EditMemberOptions, @@ -10,14 +8,15 @@ import { ImageSize, MessageContent, } from "../../types/types.ts"; -import { formatImageURL } from "../../util/cdn.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasPermission, higherRolePosition, highestRole, } from "../../util/permissions.ts"; -import { urlToBase64 } from "../../util/utils.ts"; +import { formatImageURL, urlToBase64 } from "../../util/utils.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; +import { Member, structures } from "../structures/structures.ts"; import { sendMessage } from "./channel.ts"; /** The users custom avatar or the default avatar if you don't have a member object. */ diff --git a/src/api/handlers/message.ts b/src/api/handlers/message.ts index 855266069..deb9bbf2c 100644 --- a/src/api/handlers/message.ts +++ b/src/api/handlers/message.ts @@ -1,7 +1,5 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { botID } from "../../bot.ts"; import { RequestManager } from "../../rest/mod.ts"; -import { Message, structures } from "../structures/structures.ts"; import { Errors, MessageContent, @@ -11,6 +9,8 @@ import { import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts"; import { delay } from "../../util/utils.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; +import { Message, structures } from "../structures/structures.ts"; /** Delete a message with the channel id and message id only. */ export async function deleteMessageByID( diff --git a/src/api/handlers/webhook.ts b/src/api/handlers/webhook.ts index ce42683c0..dfa3c4f91 100644 --- a/src/api/handlers/webhook.ts +++ b/src/api/handlers/webhook.ts @@ -1,5 +1,5 @@ +import { botID } from "../../bot.ts"; import { RequestManager } from "../../rest/mod.ts"; -import { structures } from "../structures/structures.ts"; import { CreateSlashCommandOptions, EditSlashCommandOptions, @@ -13,11 +13,11 @@ import { WebhookCreateOptions, WebhookPayload, } from "../../types/types.ts"; +import { cache } from "../../util/cache.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts"; import { urlToBase64 } from "../../util/utils.ts"; -import { botID } from "../../bot.ts"; -import { cache } from "../../util/cache.ts"; +import { structures } from "../structures/structures.ts"; /** Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations: * diff --git a/src/api/structures/channel.ts b/src/api/structures/channel.ts index f9742faca..d050f3cf4 100644 --- a/src/api/structures/channel.ts +++ b/src/api/structures/channel.ts @@ -1,5 +1,5 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { ChannelCreatePayload, Unpromise } from "../../types/types.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; export async function createChannel( data: ChannelCreatePayload, diff --git a/src/api/structures/member.ts b/src/api/structures/member.ts index 7303950a9..58dee1832 100644 --- a/src/api/structures/member.ts +++ b/src/api/structures/member.ts @@ -1,10 +1,10 @@ -import { cacheHandlers } from "../controllers/cache.ts"; import { GuildMember, MemberCreatePayload, Unpromise, } from "../../types/types.ts"; import { Collection } from "../../util/collection.ts"; +import { cacheHandlers } from "../controllers/cache.ts"; export async function createMember(data: MemberCreatePayload, guildID: string) { const { diff --git a/src/interactions/types/interactions.ts b/src/interactions/types/interactions.ts index 26fe43230..8b7d0a68c 100644 --- a/src/interactions/types/interactions.ts +++ b/src/interactions/types/interactions.ts @@ -1,6 +1,6 @@ import { Embed } from "./embed.ts"; -import { AllowedMentions } from "./misc.ts"; import { MemberCreatePayload } from "./member.ts"; +import { AllowedMentions } from "./misc.ts"; export interface Interaction { /** The id of the interaction */ diff --git a/src/interactions/types/mod.ts b/src/interactions/types/mod.ts index 051324f1a..973213611 100644 --- a/src/interactions/types/mod.ts +++ b/src/interactions/types/mod.ts @@ -1,6 +1,6 @@ export * from "./embed.ts"; export * from "./interactions.ts"; +export * from "./member.ts"; export * from "./misc.ts"; export * from "./slash.ts"; -export * from "./member.ts"; export * from "./webhook.ts"; diff --git a/src/rest/request_manager.ts b/src/rest/request_manager.ts index e722f9a9b..9aa6bd382 100644 --- a/src/rest/request_manager.ts +++ b/src/rest/request_manager.ts @@ -1,7 +1,7 @@ +import { authorization, eventHandlers } from "../bot.ts"; import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts"; import { baseEndpoints, discordAPIURLS } from "../util/constants.ts"; import { delay } from "../util/utils.ts"; -import { authorization, eventHandlers } from "../bot.ts"; const pathQueues: { [key: string]: QueuedRequest[] } = {}; const ratelimitedPaths = new Map(); diff --git a/src/types/types.ts b/src/types/types.ts index 6268302ed..52fd33dca 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -5,6 +5,7 @@ export * from "./discord.ts"; export * from "./errors.ts"; export * from "./fetch.ts"; export * from "./guild.ts"; +export * from "./interactions.ts"; export * from "./member.ts"; export * from "./message.ts"; export * from "./misc.ts"; @@ -13,4 +14,3 @@ export * from "./permission.ts"; export * from "./presence.ts"; export * from "./role.ts"; export * from "./webhook.ts"; -export * from "./interactions.ts"; diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 919464584..a6f7720ed 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../api/controllers/cache.ts"; -import { botID } from "../bot.ts"; import { Guild, Role } from "../api/structures/structures.ts"; +import { botID } from "../bot.ts"; import { Permission, Permissions, RawOverwrite } from "../types/types.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/ws/shard_manager.ts b/src/ws/shard_manager.ts index 8236d561a..263aed283 100644 --- a/src/ws/shard_manager.ts +++ b/src/ws/shard_manager.ts @@ -1,5 +1,6 @@ import { controllers } from "../api/controllers/mod.ts"; import { Guild } from "../api/structures/structures.ts"; +import { eventHandlers, IdentifyPayload } from "../bot.ts"; import { DiscordBotGatewayData, DiscordPayload, @@ -13,7 +14,6 @@ import { createShard, requestGuildMembers, } from "./mod.ts"; -import { eventHandlers, IdentifyPayload } from "../bot.ts"; let createNextShard = true;