Organize imports (#127)

* Organize imports

* Organize imports
This commit is contained in:
chroventer
2020-10-02 01:35:48 -07:00
committed by GitHub
parent 93c57dd4a8
commit 3fab966208
32 changed files with 186 additions and 203 deletions
+3 -4
View File
@@ -1,11 +1,10 @@
export type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts";
export { encode } from "https://deno.land/std@0.67.0/encoding/base64.ts";
export { delay } from "https://deno.land/std@0.67.0/async/delay.ts"; export { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
export { inflate } from "https://deno.land/x/zlib.es@v1.0.0/mod.ts"; export { encode } from "https://deno.land/std@0.67.0/encoding/base64.ts";
export { export {
connectWebSocket, connectWebSocket,
isWebSocketCloseEvent, isWebSocketCloseEvent,
isWebSocketPingEvent, isWebSocketPingEvent,
isWebSocketPongEvent, isWebSocketPongEvent,
} from "https://deno.land/std@0.67.0/ws/mod.ts"; } from "https://deno.land/std@0.67.0/ws/mod.ts";
export type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts";
export { inflate } from "https://deno.land/x/zlib.es@v1.0.0/mod.ts";
+10 -15
View File
@@ -1,6 +1,5 @@
import createClient from "./src/module/client.ts"; import createClient from "./src/module/client.ts";
export * from "./src/controllers/mod.ts";
export * from "./src/controllers/bans.ts"; export * from "./src/controllers/bans.ts";
export * from "./src/controllers/cache.ts"; export * from "./src/controllers/cache.ts";
export * from "./src/controllers/channels.ts"; export * from "./src/controllers/channels.ts";
@@ -8,26 +7,23 @@ export * from "./src/controllers/guilds.ts";
export * from "./src/controllers/members.ts"; export * from "./src/controllers/members.ts";
export * from "./src/controllers/messages.ts"; export * from "./src/controllers/messages.ts";
export * from "./src/controllers/misc.ts"; export * from "./src/controllers/misc.ts";
export * from "./src/controllers/mod.ts";
export * from "./src/controllers/reactions.ts"; export * from "./src/controllers/reactions.ts";
export * from "./src/controllers/roles.ts"; export * from "./src/controllers/roles.ts";
export * from "./src/module/client.ts";
export * from "./src/module/requestManager.ts";
export * from "./src/module/shardingManager.ts";
export * from "./src/structures/mod.ts";
export * from "./src/structures/channel.ts";
export * from "./src/structures/guild.ts";
export * from "./src/structures/member.ts";
export * from "./src/structures/message.ts";
export * from "./src/structures/role.ts";
export * from "./src/handlers/channel.ts"; export * from "./src/handlers/channel.ts";
export * from "./src/handlers/guild.ts"; export * from "./src/handlers/guild.ts";
export * from "./src/handlers/member.ts"; export * from "./src/handlers/member.ts";
export * from "./src/handlers/message.ts"; export * from "./src/handlers/message.ts";
export * from "./src/handlers/webhook.ts"; export * from "./src/handlers/webhook.ts";
export * from "./src/module/client.ts";
export * from "./src/module/requestManager.ts";
export * from "./src/module/shardingManager.ts";
export * from "./src/structures/channel.ts";
export * from "./src/structures/guild.ts";
export * from "./src/structures/member.ts";
export * from "./src/structures/message.ts";
export * from "./src/structures/mod.ts";
export * from "./src/structures/role.ts";
export * from "./src/types/activity.ts"; export * from "./src/types/activity.ts";
export * from "./src/types/cdn.ts"; export * from "./src/types/cdn.ts";
export * from "./src/types/channel.ts"; export * from "./src/types/channel.ts";
@@ -41,7 +37,6 @@ export * from "./src/types/options.ts";
export * from "./src/types/permission.ts"; export * from "./src/types/permission.ts";
export * from "./src/types/presence.ts"; export * from "./src/types/presence.ts";
export * from "./src/types/role.ts"; export * from "./src/types/role.ts";
export * from "./src/utils/cache.ts"; export * from "./src/utils/cache.ts";
export * from "./src/utils/cdn.ts"; export * from "./src/utils/cdn.ts";
export * from "./src/utils/collection.ts"; export * from "./src/utils/collection.ts";
+1 -2
View File
@@ -1,7 +1,6 @@
import { eventHandlers } from "../module/client.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { GuildBanPayload } from "../types/guild.ts"; import type { GuildBanPayload } from "../types/guild.ts";
import { eventHandlers } from "../module/client.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalGuildBanAdd(data: DiscordPayload) { export async function handleInternalGuildBanAdd(data: DiscordPayload) {
+1 -2
View File
@@ -2,9 +2,8 @@ import type { Channel } from "../structures/channel.ts";
import type { Guild } from "../structures/guild.ts"; import type { Guild } from "../structures/guild.ts";
import type { Message } from "../structures/message.ts"; import type { Message } from "../structures/message.ts";
import type { PresenceUpdatePayload } from "../types/discord.ts"; import type { PresenceUpdatePayload } from "../types/discord.ts";
import type { Collection } from "../utils/collection.ts";
import { cache } from "../utils/cache.ts"; import { cache } from "../utils/cache.ts";
import type { Collection } from "../utils/collection.ts";
export type TableName = export type TableName =
| "guilds" | "guilds"
+4 -5
View File
@@ -1,9 +1,8 @@
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 { eventHandlers } from "../module/client.ts"; import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { ChannelCreatePayload } from "../types/channel.ts";
import { ChannelTypes } from "../types/channel.ts";
import type { DiscordPayload } from "../types/discord.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalChannelCreate(data: DiscordPayload) { export async function handleInternalChannelCreate(data: DiscordPayload) {
+3 -4
View File
@@ -1,15 +1,14 @@
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { GuildUpdateChange } from "../types/options.ts";
import type { import type {
CreateGuildPayload, CreateGuildPayload,
GuildDeletePayload, GuildDeletePayload,
GuildEmojisUpdatePayload, GuildEmojisUpdatePayload,
UpdateGuildPayload, UpdateGuildPayload,
} from "../types/guild.ts"; } from "../types/guild.ts";
import type { GuildUpdateChange } from "../types/options.ts";
import { cache } from "../utils/cache.ts"; import { cache } from "../utils/cache.ts";
import { structures } from "../structures/mod.ts";
import { eventHandlers } from "../module/client.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalGuildCreate( export async function handleInternalGuildCreate(
+2 -3
View File
@@ -1,3 +1,5 @@
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { import type {
GuildBanPayload, GuildBanPayload,
@@ -5,9 +7,6 @@ import type {
GuildMemberChunkPayload, GuildMemberChunkPayload,
GuildMemberUpdatePayload, GuildMemberUpdatePayload,
} from "../types/guild.ts"; } from "../types/guild.ts";
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import { cache } from "../utils/cache.ts"; import { cache } from "../utils/cache.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+5 -5
View File
@@ -1,12 +1,12 @@
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { import type {
MessageCreateOptions, MessageCreateOptions,
MessageDeletePayload,
MessageDeleteBulkPayload,
} from "../types/message.ts";
import { eventHandlers } from "../module/client.ts"; MessageDeleteBulkPayload,
import { structures } from "../structures/mod.ts"; MessageDeletePayload,
} from "../types/message.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalMessageCreate(data: DiscordPayload) { export async function handleInternalMessageCreate(data: DiscordPayload) {
+5 -6
View File
@@ -1,4 +1,7 @@
import type { UserPayload } from "../types/guild.ts"; import { delay } from "../../deps.ts";
import { eventHandlers, setBotID } from "../module/client.ts";
import { allowNextShard } from "../module/shardingManager.ts";
import { structures } from "../structures/mod.ts";
import type { import type {
DiscordPayload, DiscordPayload,
PresenceUpdatePayload, PresenceUpdatePayload,
@@ -7,11 +10,7 @@ import type {
VoiceStateUpdatePayload, VoiceStateUpdatePayload,
WebhookUpdatePayload, WebhookUpdatePayload,
} from "../types/discord.ts"; } from "../types/discord.ts";
import type { UserPayload } from "../types/guild.ts";
import { allowNextShard } from "../module/shardingManager.ts";
import { delay } from "../../deps.ts";
import { eventHandlers, setBotID } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import { cache } from "../utils/cache.ts"; import { cache } from "../utils/cache.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
+2 -3
View File
@@ -1,12 +1,11 @@
import { botID, eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { import type {
BaseMessageReactionPayload, BaseMessageReactionPayload,
MessageReactionPayload, MessageReactionPayload,
MessageReactionRemoveEmojiPayload, MessageReactionRemoveEmojiPayload,
} from "../types/message.ts"; } from "../types/message.ts";
import { botID, eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalMessageReactionAdd(data: DiscordPayload) { export async function handleInternalMessageReactionAdd(data: DiscordPayload) {
+2 -3
View File
@@ -1,11 +1,10 @@
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import type { DiscordPayload } from "../types/discord.ts"; import type { DiscordPayload } from "../types/discord.ts";
import type { import type {
GuildRoleDeletePayload, GuildRoleDeletePayload,
GuildRolePayload, GuildRolePayload,
} from "../types/guild.ts"; } from "../types/guild.ts";
import { eventHandlers } from "../module/client.ts";
import { structures } from "../structures/mod.ts";
import { cacheHandlers } from "./cache.ts"; import { cacheHandlers } from "./cache.ts";
export async function handleInternalGuildRoleCreate(data: DiscordPayload) { export async function handleInternalGuildRoleCreate(data: DiscordPayload) {
+13 -14
View File
@@ -1,22 +1,21 @@
import type { MessageCreateOptions } from "../types/message.ts";
import type {
GetMessagesAfter,
GetMessagesBefore,
GetMessagesAround,
GetMessages,
MessageContent,
CreateInviteOptions,
ChannelEditOptions,
FollowedChannelPayload,
} from "../types/channel.ts";
import type { RawOverwrite } from "../types/guild.ts";
import { endpoints } from "../constants/discord.ts"; import { endpoints } from "../constants/discord.ts";
import { RequestManager } from "../module/requestManager.ts"; import { RequestManager } from "../module/requestManager.ts";
import { structures } from "../structures/mod.ts";
import type {
ChannelEditOptions,
CreateInviteOptions,
FollowedChannelPayload,
GetMessages,
GetMessagesAfter,
GetMessagesAround,
GetMessagesBefore,
MessageContent,
} from "../types/channel.ts";
import { Errors } from "../types/errors.ts"; import { Errors } from "../types/errors.ts";
import type { RawOverwrite } from "../types/guild.ts";
import type { MessageCreateOptions } from "../types/message.ts";
import { Permissions } from "../types/permission.ts"; import { Permissions } from "../types/permission.ts";
import { botHasChannelPermissions } from "../utils/permissions.ts"; import { botHasChannelPermissions } from "../utils/permissions.ts";
import { structures } from "../structures/mod.ts";
/** Checks if a channel overwrite for a user id or a role id has permission in this channel */ /** Checks if a channel overwrite for a user id or a role id has permission in this channel */
export function channelOverwriteHasPermission( export function channelOverwriteHasPermission(
+29 -23
View File
@@ -1,43 +1,49 @@
import { endpoints } from "../constants/discord.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { identifyPayload } from "../module/client.ts";
import { RequestManager } from "../module/requestManager.ts";
import { requestAllMembers } from "../module/shardingManager.ts";
import type { Guild } from "../structures/guild.ts"; import type { Guild } from "../structures/guild.ts";
import type { Member } from "../structures/member.ts";
import { structures } from "../structures/mod.ts";
import type { ImageFormats, ImageSize } from "../types/cdn.ts";
import { import {
ChannelCreatePayload, ChannelCreatePayload,
ChannelTypes, ChannelTypes,
} from "../types/channel.ts"; } from "../types/channel.ts";
import type { ImageFormats, ImageSize } from "../types/cdn.ts"; import { Errors } from "../types/errors.ts";
import type { import type {
BannedUser,
BanOptions,
ChannelCreateOptions,
CreateEmojisOptions, CreateEmojisOptions,
PositionSwap,
EditEmojisOptions,
CreateRoleOptions, CreateRoleOptions,
CreateServerOptions,
EditEmojisOptions,
EditIntegrationOptions,
FetchMembersOptions, FetchMembersOptions,
GetAuditLogsOptions, GetAuditLogsOptions,
EditIntegrationOptions,
BanOptions,
GuildEditOptions, GuildEditOptions,
PositionSwap,
PruneOptions, PruneOptions,
PrunePayload, PrunePayload,
ChannelCreateOptions,
BannedUser,
UserPayload,
CreateServerOptions,
} from "../types/guild.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"; UserPayload,
import { urlToBase64 } from "../utils/utils.ts"; } from "../types/guild.ts";
import type { MemberCreatePayload } from "../types/member.ts";
import { Intents } from "../types/options.ts"; import { Intents } from "../types/options.ts";
import { identifyPayload } from "../module/client.ts";
import { requestAllMembers } from "../module/shardingManager.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 { Permissions } from "../types/permission.ts";
import { structures } from "../structures/mod.ts"; import type { RoleData } from "../types/role.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { formatImageURL } from "../utils/cdn.ts"; import { formatImageURL } from "../utils/cdn.ts";
import { Collection } from "../utils/collection.ts";
import { botHasPermission } from "../utils/permissions.ts";
import { urlToBase64 } from "../utils/utils.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. */ /** 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 function createServer(options: CreateServerOptions) { export function createServer(options: CreateServerOptions) {
+15 -16
View File
@@ -1,25 +1,24 @@
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 { endpoints } from "../constants/discord.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { botID } from "../module/client.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 { RequestManager } from "../module/requestManager.ts";
import type { Member } from "../structures/member.ts";
import { structures } from "../structures/mod.ts";
import type { ImageFormats, ImageSize } from "../types/cdn.ts";
import type {
DMChannelCreatePayload,
MessageContent,
} from "../types/channel.ts";
import { Errors } from "../types/errors.ts";
import type { EditMemberOptions } from "../types/member.ts";
import { Permissions } from "../types/permission.ts";
import { formatImageURL } from "../utils/cdn.ts";
import { import {
highestRole,
higherRolePosition,
botHasPermission, botHasPermission,
higherRolePosition,
highestRole,
} from "../utils/permissions.ts"; } from "../utils/permissions.ts";
import { sendMessage } from "./channel.ts";
/** The users custom avatar or the default avatar if you don't have a member object. */ /** The users custom avatar or the default avatar if you don't have a member object. */
export function rawAvatarURL( export function rawAvatarURL(
+8 -9
View File
@@ -1,16 +1,15 @@
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 "../../deps.ts"; import { delay } from "../../deps.ts";
import { structures } from "../structures/mod.ts"; import { endpoints } from "../constants/discord.ts";
import { cacheHandlers } from "../controllers/cache.ts"; import { cacheHandlers } from "../controllers/cache.ts";
import { botID } from "../module/client.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 { RequestManager } from "../module/requestManager.ts";
import { endpoints } from "../constants/discord.ts"; import type { Message } from "../structures/message.ts";
import { structures } from "../structures/mod.ts";
import type { MessageContent } from "../types/channel.ts";
import { Errors } from "../types/errors.ts";
import type { UserPayload } from "../types/guild.ts";
import type { MessageCreateOptions } from "../types/message.ts";
import { Permissions } from "../types/permission.ts";
import { botHasChannelPermissions } from "../utils/permissions.ts"; import { botHasChannelPermissions } from "../utils/permissions.ts";
/** Delete a message with the channel id and message id only. */ /** Delete a message with the channel id and message id only. */
+7 -8
View File
@@ -1,17 +1,16 @@
import { endpoints } from "../constants/discord.ts";
import { RequestManager } from "../module/requestManager.ts";
import { structures } from "../structures/mod.ts";
import { Errors } from "../types/errors.ts";
import type { MessageCreateOptions } from "../types/message.ts";
import { Permissions } from "../types/permission.ts";
import type { import type {
ExecuteWebhookOptions,
WebhookCreateOptions, WebhookCreateOptions,
WebhookPayload, WebhookPayload,
ExecuteWebhookOptions,
} from "../types/webhook.ts"; } from "../types/webhook.ts";
import type { MessageCreateOptions } from "../types/message.ts";
import { botHasChannelPermissions } from "../utils/permissions.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 { urlToBase64 } from "../utils/utils.ts"; import { urlToBase64 } from "../utils/utils.ts";
import { structures } from "../structures/mod.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: /** 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:
* *
+11 -9
View File
@@ -1,24 +1,26 @@
import type { DiscordBotGatewayData, ReadyPayload } from "../types/discord.ts";
import type { IdentifyPayload } from "./client.ts";
import { import {
connectWebSocket, connectWebSocket,
delay,
inflate,
isWebSocketCloseEvent, isWebSocketCloseEvent,
isWebSocketPingEvent, isWebSocketPingEvent,
isWebSocketPongEvent, isWebSocketPongEvent,
WebSocket, WebSocket,
} from "../../deps.ts"; } from "../../deps.ts";
import type { DiscordHeartbeatPayload } from "../types/discord.ts"; import type {
DiscordBotGatewayData,
DiscordHeartbeatPayload,
ReadyPayload,
} from "../types/discord.ts";
import { GatewayOpcode } from "../types/discord.ts";
import type { FetchMembersOptions } from "../types/guild.ts"; import type { FetchMembersOptions } from "../types/guild.ts";
import type { BotStatusRequest } from "../utils/utils.ts"; import type { BotStatusRequest } from "../utils/utils.ts";
import type { IdentifyPayload } from "./client.ts";
import { handleDiscordPayload } from "./shardingManager.ts";
import { GatewayOpcode } from "../types/discord.ts";
import { import {
eventHandlers,
botGatewayData, botGatewayData,
eventHandlers,
} from "./client.ts"; } from "./client.ts";
import { delay } from "../../deps.ts"; import { handleDiscordPayload } from "./shardingManager.ts";
import { inflate } from "../../deps.ts";
const basicShards = new Map<number, BasicShard>(); const basicShards = new Map<number, BasicShard>();
const heartbeating = new Set<number>(); const heartbeating = new Set<number>();
+3 -4
View File
@@ -1,9 +1,8 @@
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 { endpoints } from "../constants/discord.ts";
import type { DiscordBotGatewayData } from "../types/discord.ts";
import type { ClientOptions, EventHandlers } from "../types/options.ts";
import { RequestManager } from "./requestManager.ts"; import { RequestManager } from "./requestManager.ts";
import { spawnShards } from "./shardingManager.ts";
export let authorization = ""; export let authorization = "";
export let botID = ""; export let botID = "";
+5 -6
View File
@@ -1,10 +1,9 @@
import { HttpResponseCode } from "../types/discord.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 { delay } from "../../deps.ts"; import { delay } from "../../deps.ts";
import { baseEndpoints } from "../constants/discord.ts";
import { HttpResponseCode } from "../types/discord.ts";
import { Errors } from "../types/errors.ts";
import type { RequestMethods } from "../types/fetch.ts";
import { authorization, eventHandlers } from "./client.ts";
const pathQueues: { [key: string]: QueuedRequest[] } = {}; const pathQueues: { [key: string]: QueuedRequest[] } = {};
const ratelimitedPaths = new Map<string, RateLimitedPath>(); const ratelimitedPaths = new Map<string, RateLimitedPath>();
+2 -7
View File
@@ -1,19 +1,14 @@
import type { WebSocket } from "../../deps.ts"; import type { WebSocket } from "../../deps.ts";
import { connectWebSocket, delay, isWebSocketCloseEvent } from "../../deps.ts";
import type { import type {
DiscordBotGatewayData, DiscordBotGatewayData,
DiscordHeartbeatPayload, DiscordHeartbeatPayload,
ReadyPayload, ReadyPayload,
} from "../types/discord.ts"; } from "../types/discord.ts";
import { GatewayOpcode } from "../types/discord.ts";
import type { FetchMembersOptions } from "../types/guild.ts"; import type { FetchMembersOptions } from "../types/guild.ts";
import type { DebugArg } from "../types/options.ts"; import type { DebugArg } from "../types/options.ts";
import { GatewayOpcode } from "../types/discord.ts";
import { delay } from "../../deps.ts";
import {
connectWebSocket,
isWebSocketCloseEvent,
} from "../../deps.ts";
let shardSocket: WebSocket; let shardSocket: WebSocket;
/** The session id is needed for RESUME functionality when discord disconnects randomly. */ /** The session id is needed for RESUME functionality when discord disconnects randomly. */
+9 -9
View File
@@ -1,26 +1,26 @@
import type { IdentifyPayload } from "./client.ts"; import { delay } from "../../deps.ts";
import { controllers } from "../controllers/mod.ts";
import type { Guild } from "../structures/guild.ts"; import type { Guild } from "../structures/guild.ts";
import type { FetchMembersOptions } from "../types/guild.ts";
import type { import type {
DiscordBotGatewayData, DiscordBotGatewayData,
DiscordPayload, DiscordPayload,
} from "../types/discord.ts"; } from "../types/discord.ts";
import type { BotStatusRequest } from "../utils/utils.ts"; import { GatewayOpcode } from "../types/discord.ts";
import type { FetchMembersOptions } from "../types/guild.ts";
import { controllers } from "../controllers/mod.ts";
import { cache } from "../utils/cache.ts"; import { cache } from "../utils/cache.ts";
import type { BotStatusRequest } from "../utils/utils.ts";
import { import {
botGatewayStatusRequest,
createBasicShard, createBasicShard,
requestGuildMembers, requestGuildMembers,
botGatewayStatusRequest,
} from "./basicShard.ts"; } from "./basicShard.ts";
import type { IdentifyPayload } from "./client.ts";
import { import {
eventHandlers,
botGatewayData, botGatewayData,
eventHandlers,
identifyPayload, identifyPayload,
} from "./client.ts"; } from "./client.ts";
import { GatewayOpcode } from "../types/discord.ts";
import { delay } from "../../deps.ts";
let shardCounter = 0; let shardCounter = 0;
let basicSharding = false; let basicSharding = false;
+1 -2
View File
@@ -1,7 +1,6 @@
import { cacheHandlers } from "../controllers/cache.ts";
import type { ChannelCreatePayload } from "../types/channel.ts"; import type { ChannelCreatePayload } from "../types/channel.ts";
import type { Unpromise } from "../types/misc.ts"; import type { Unpromise } from "../types/misc.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { calculatePermissions } from "../utils/permissions.ts"; import { calculatePermissions } from "../utils/permissions.ts";
export async function createChannel( export async function createChannel(
+2 -3
View File
@@ -1,9 +1,8 @@
import type { CreateGuildPayload } from "../types/guild.ts"; import type { CreateGuildPayload } from "../types/guild.ts";
import type { Member } from "./member.ts";
import type { Unpromise } from "../types/misc.ts"; import type { Unpromise } from "../types/misc.ts";
import { structures } from "./mod.ts";
import { Collection } from "../utils/collection.ts"; import { Collection } from "../utils/collection.ts";
import type { Member } from "./member.ts";
import { structures } from "./mod.ts";
export async function createGuild(data: CreateGuildPayload, shardID: number) { export async function createGuild(data: CreateGuildPayload, shardID: number) {
const { const {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { RawOverwrite, Overwrite } from "./guild.ts"; import type { Overwrite, RawOverwrite } from "./guild.ts";
import type { Embed } from "./message.ts"; import type { Embed } from "./message.ts";
export interface ChannelEditOptions { export interface ChannelEditOptions {
+2 -2
View File
@@ -1,7 +1,7 @@
import type { Activity } from "./message.ts";
import type { ClientStatusPayload } from "./presence.ts";
import type { PartialUser, UserPayload } from "./guild.ts"; import type { PartialUser, UserPayload } from "./guild.ts";
import type { MemberCreatePayload } from "./member.ts"; import type { MemberCreatePayload } from "./member.ts";
import type { Activity } from "./message.ts";
import type { ClientStatusPayload } from "./presence.ts";
export interface DiscordPayload { export interface DiscordPayload {
/** OP code for the payload */ /** OP code for the payload */
+3 -3
View File
@@ -1,10 +1,10 @@
import type { ChannelCreatePayload, ChannelTypes } from "./channel.ts";
import type { Emoji, StatusType } from "./discord.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 { MemberCreatePayload } from "./member.ts";
import type { Activity } from "./message.ts"; import type { Activity } from "./message.ts";
import type { Permission } from "./permission.ts";
import type { ClientStatusPayload } from "./presence.ts"; import type { ClientStatusPayload } from "./presence.ts";
import type { ChannelCreatePayload, ChannelTypes } from "./channel.ts"; import type { RoleData } from "./role.ts";
export interface GuildRolePayload { export interface GuildRolePayload {
/** The id of the guild */ /** The id of the guild */
+2 -2
View File
@@ -1,7 +1,7 @@
import type { UserPayload } from "./guild.ts";
import type { MemberCreatePayload } from "./member.ts";
import type { Channel } from "../structures/channel.ts"; import type { Channel } from "../structures/channel.ts";
import type { ChannelType } from "./channel.ts"; import type { ChannelType } from "./channel.ts";
import type { UserPayload } from "./guild.ts";
import type { MemberCreatePayload } from "./member.ts";
export interface MentionedUser extends UserPayload { export interface MentionedUser extends UserPayload {
member: MemberCreatePayload; member: MemberCreatePayload;
+23 -19
View File
@@ -1,26 +1,30 @@
import type {
Properties,
Emoji,
DiscordPayload,
PresenceUpdatePayload,
TypingStartPayload,
VoiceStateUpdatePayload,
} from "./discord.ts";
import type { Role } from "../structures/role.ts";
import type { Message } from "../structures/message.ts";
import type {
PartialMessage,
ReactionPayload,
BaseMessageReactionPayload,
MessageReactionRemoveEmojiPayload,
Embed,
Attachment,
MessageReactionUncachedPayload,
} from "./message.ts";
import type { Channel } from "../structures/channel.ts"; import type { Channel } from "../structures/channel.ts";
import type { Guild } from "../structures/guild.ts"; import type { Guild } from "../structures/guild.ts";
import type { Member } from "../structures/member.ts"; import type { Member } from "../structures/member.ts";
import type { Message } from "../structures/message.ts";
import type { Role } from "../structures/role.ts";
import type {
DiscordPayload,
Emoji,
PresenceUpdatePayload,
Properties,
TypingStartPayload,
VoiceStateUpdatePayload,
} from "./discord.ts";
import type { UserPayload } from "./guild.ts"; import type { UserPayload } from "./guild.ts";
import type {
Attachment,
BaseMessageReactionPayload,
Embed,
MessageReactionRemoveEmojiPayload,
MessageReactionUncachedPayload,
PartialMessage,
ReactionPayload,
} from "./message.ts";
export interface Fulfilled_Client_Options { export interface Fulfilled_Client_Options {
token: string; token: string;
+3 -3
View File
@@ -1,8 +1,8 @@
import { Collection } from "./collection.ts";
import type { Message } from "../structures/message.ts";
import type { Guild } from "../structures/guild.ts";
import type { Channel } from "../structures/channel.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 { PresenceUpdatePayload } from "../types/discord.ts";
import { Collection } from "./collection.ts";
export interface CacheData { export interface CacheData {
isReady: boolean; isReady: boolean;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ImageSize, ImageFormats } from "../types/cdn.ts"; import type { ImageFormats, ImageSize } from "../types/cdn.ts";
export const formatImageURL = ( export const formatImageURL = (
url: string, url: string,
+5 -6
View File
@@ -1,10 +1,9 @@
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 { cacheHandlers } from "../controllers/cache.ts"; import { cacheHandlers } from "../controllers/cache.ts";
import { botID } from "../module/client.ts";
import type { Guild } from "../structures/guild.ts";
import type { Role } from "../structures/role.ts";
import type { Permission } from "../types/permission.ts";
import { Permissions } from "../types/permission.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(
+3 -4
View File
@@ -1,8 +1,7 @@
import type { StatusType } from "../types/discord.ts";
import { ActivityType } from "../types/activity.ts";
import { sendGatewayCommand } from "../module/shardingManager.ts";
import { encode } from "../../deps.ts"; import { encode } from "../../deps.ts";
import { sendGatewayCommand } from "../module/shardingManager.ts";
import { ActivityType } from "../types/activity.ts";
import type { StatusType } from "../types/discord.ts";
export const sleep = (timeout: number) => { export const sleep = (timeout: number) => {
return new Promise((resolve) => setTimeout(resolve, timeout)); return new Promise((resolve) => setTimeout(resolve, timeout));