mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
refactor!: organize directories and files (#268)
* refactor!: organize directory structure * fix: avoid stack overflow err * chore: swtch back to std/encoding for base64 * style: format source files
This commit is contained in:
@@ -1,8 +1 @@
|
|||||||
export { delay } from "https://deno.land/std@0.81.0/async/delay.ts";
|
|
||||||
export { encode } from "https://deno.land/std@0.81.0/encoding/base64.ts";
|
export { encode } from "https://deno.land/std@0.81.0/encoding/base64.ts";
|
||||||
export {
|
|
||||||
assert,
|
|
||||||
assertArrayIncludes,
|
|
||||||
assertEquals,
|
|
||||||
} from "https://deno.land/std@0.81.0/testing/asserts.ts";
|
|
||||||
export { decompress_with as inflate } from "https://unpkg.com/@evan/wasm@0.0.25/target/zlib/deno.js";
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { DiscordPayload, GuildBanPayload } from "../types/types.ts";
|
import { DiscordPayload, GuildBanPayload } from "../../types/types.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalGuildBanAdd(data: DiscordPayload) {
|
export async function handleInternalGuildBanAdd(data: DiscordPayload) {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Channel, Guild, Member, Message } from "../structures/structures.ts";
|
import { Channel, Guild, Member, Message } from "../structures/structures.ts";
|
||||||
import { PresenceUpdatePayload } from "../types/types.ts";
|
import { PresenceUpdatePayload } from "../../types/types.ts";
|
||||||
import { cache } from "../utils/cache.ts";
|
import { cache } from "../../util/cache.ts";
|
||||||
import { Collection } from "../utils/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
|
|
||||||
export type TableName =
|
export type TableName =
|
||||||
| "guilds"
|
| "guilds"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
ChannelCreatePayload,
|
ChannelCreatePayload,
|
||||||
ChannelTypes,
|
ChannelTypes,
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalChannelCreate(data: DiscordPayload) {
|
export async function handleInternalChannelCreate(data: DiscordPayload) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
CreateGuildPayload,
|
CreateGuildPayload,
|
||||||
@@ -7,8 +7,8 @@ import {
|
|||||||
GuildEmojisUpdatePayload,
|
GuildEmojisUpdatePayload,
|
||||||
GuildUpdateChange,
|
GuildUpdateChange,
|
||||||
UpdateGuildPayload,
|
UpdateGuildPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cache } from "../utils/cache.ts";
|
import { cache } from "../../util/cache.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalGuildCreate(
|
export async function handleInternalGuildCreate(
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
GuildMemberAddPayload,
|
GuildMemberAddPayload,
|
||||||
GuildMemberChunkPayload,
|
GuildMemberChunkPayload,
|
||||||
GuildMemberUpdatePayload,
|
GuildMemberUpdatePayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cache } from "../utils/cache.ts";
|
import { cache } from "../../util/cache.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalGuildMemberAdd(data: DiscordPayload) {
|
export async function handleInternalGuildMemberAdd(data: DiscordPayload) {
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
MessageCreateOptions,
|
MessageCreateOptions,
|
||||||
MessageDeleteBulkPayload,
|
MessageDeleteBulkPayload,
|
||||||
MessageDeletePayload,
|
MessageDeletePayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalMessageCreate(data: DiscordPayload) {
|
export async function handleInternalMessageCreate(data: DiscordPayload) {
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import { delay } from "../../deps.ts";
|
import {
|
||||||
import { initialMemberLoadQueue } from "../../mod.ts";
|
initialMemberLoadQueue,
|
||||||
import { eventHandlers, setBotID } from "../module/client.ts";
|
structures,
|
||||||
import { allowNextShard } from "../module/shardingManager.ts";
|
} from "../structures/structures.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { eventHandlers, setBotID } from "../../bot.ts";
|
||||||
|
import { allowNextShard } from "../../ws/shard_manager.ts";
|
||||||
import {
|
import {
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
PresenceUpdatePayload,
|
PresenceUpdatePayload,
|
||||||
@@ -11,8 +12,9 @@ import {
|
|||||||
UserPayload,
|
UserPayload,
|
||||||
VoiceStateUpdatePayload,
|
VoiceStateUpdatePayload,
|
||||||
WebhookUpdatePayload,
|
WebhookUpdatePayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cache } from "../utils/cache.ts";
|
import { cache } from "../../util/cache.ts";
|
||||||
|
import { delay } from "../../util/utils.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalReady(
|
export async function handleInternalReady(
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { botID, eventHandlers } from "../module/client.ts";
|
import { botID, eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
BaseMessageReactionPayload,
|
BaseMessageReactionPayload,
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
MessageReactionPayload,
|
MessageReactionPayload,
|
||||||
MessageReactionRemoveEmojiPayload,
|
MessageReactionRemoveEmojiPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalMessageReactionAdd(data: DiscordPayload) {
|
export async function handleInternalMessageReactionAdd(data: DiscordPayload) {
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { eventHandlers } from "../module/client.ts";
|
import { eventHandlers } from "../../bot.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
GuildRoleDeletePayload,
|
GuildRoleDeletePayload,
|
||||||
GuildRolePayload,
|
GuildRolePayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { cacheHandlers } from "./cache.ts";
|
import { cacheHandlers } from "./cache.ts";
|
||||||
|
|
||||||
export async function handleInternalGuildRoleCreate(data: DiscordPayload) {
|
export async function handleInternalGuildRoleCreate(data: DiscordPayload) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { RequestManager } from "../module/requestManager.ts";
|
import { RequestManager } from "../../rest/mod.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
ChannelEditOptions,
|
ChannelEditOptions,
|
||||||
@@ -17,12 +17,12 @@ import {
|
|||||||
Permissions,
|
Permissions,
|
||||||
RawOverwrite,
|
RawOverwrite,
|
||||||
WebhookPayload,
|
WebhookPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { endpoints } from "../utils/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import {
|
import {
|
||||||
botHasChannelPermissions,
|
botHasChannelPermissions,
|
||||||
calculateBits,
|
calculateBits,
|
||||||
} from "../utils/permissions.ts";
|
} from "../../util/permissions.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(
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { identifyPayload } from "../module/client.ts";
|
import { identifyPayload } from "../../bot.ts";
|
||||||
import { RequestManager } from "../module/requestManager.ts";
|
import { RequestManager } from "../../rest/mod.ts";
|
||||||
import { requestAllMembers } from "../module/shardingManager.ts";
|
import { requestAllMembers } from "../../ws/shard_manager.ts";
|
||||||
import {
|
import {
|
||||||
Guild,
|
Guild,
|
||||||
Member,
|
Member,
|
||||||
@@ -39,12 +39,12 @@ import {
|
|||||||
RoleData,
|
RoleData,
|
||||||
UpdateGuildPayload,
|
UpdateGuildPayload,
|
||||||
UserPayload,
|
UserPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { formatImageURL } from "../utils/cdn.ts";
|
import { formatImageURL } from "../../util/cdn.ts";
|
||||||
import { Collection } from "../utils/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
import { endpoints } from "../utils/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import { botHasPermission, calculateBits } from "../utils/permissions.ts";
|
import { botHasPermission, calculateBits } from "../../util/permissions.ts";
|
||||||
import { urlToBase64 } from "../utils/utils.ts";
|
import { urlToBase64 } from "../../util/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 async function createServer(options: CreateServerOptions) {
|
export async function createServer(options: CreateServerOptions) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { botID } from "../module/client.ts";
|
import { botID } from "../../bot.ts";
|
||||||
import { RequestManager } from "../module/requestManager.ts";
|
import { RequestManager } from "../../rest/mod.ts";
|
||||||
import { Member, structures } from "../structures/structures.ts";
|
import { Member, structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
DMChannelCreatePayload,
|
DMChannelCreatePayload,
|
||||||
@@ -9,15 +9,15 @@ import {
|
|||||||
ImageFormats,
|
ImageFormats,
|
||||||
ImageSize,
|
ImageSize,
|
||||||
MessageContent,
|
MessageContent,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { formatImageURL } from "../utils/cdn.ts";
|
import { formatImageURL } from "../../util/cdn.ts";
|
||||||
import { endpoints } from "../utils/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import {
|
import {
|
||||||
botHasPermission,
|
botHasPermission,
|
||||||
higherRolePosition,
|
higherRolePosition,
|
||||||
highestRole,
|
highestRole,
|
||||||
} from "../utils/permissions.ts";
|
} from "../../util/permissions.ts";
|
||||||
import { urlToBase64 } from "../utils/utils.ts";
|
import { urlToBase64 } from "../../util/utils.ts";
|
||||||
import { sendMessage } from "./channel.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. */
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
import { delay } from "../../deps.ts";
|
|
||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { botID } from "../module/client.ts";
|
import { botID } from "../../bot.ts";
|
||||||
import { RequestManager } from "../module/requestManager.ts";
|
import { RequestManager } from "../../rest/mod.ts";
|
||||||
import { Message, structures } from "../structures/structures.ts";
|
import { Message, structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
Errors,
|
Errors,
|
||||||
MessageContent,
|
MessageContent,
|
||||||
MessageCreateOptions,
|
MessageCreateOptions,
|
||||||
UserPayload,
|
UserPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { endpoints } from "../utils/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import { botHasChannelPermissions } from "../utils/permissions.ts";
|
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||||
|
import { delay } from "../../util/utils.ts";
|
||||||
|
|
||||||
/** Delete a message with the channel id and message id only. */
|
/** Delete a message with the channel id and message id only. */
|
||||||
export async function deleteMessageByID(
|
export async function deleteMessageByID(
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RequestManager } from "../module/requestManager.ts";
|
import { RequestManager } from "../../rest/mod.ts";
|
||||||
import { structures } from "../structures/structures.ts";
|
import { structures } from "../structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
EditWebhookMessageOptions,
|
EditWebhookMessageOptions,
|
||||||
@@ -7,10 +7,10 @@ import {
|
|||||||
MessageCreateOptions,
|
MessageCreateOptions,
|
||||||
WebhookCreateOptions,
|
WebhookCreateOptions,
|
||||||
WebhookPayload,
|
WebhookPayload,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { endpoints } from "../utils/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import { botHasChannelPermissions } from "../utils/permissions.ts";
|
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||||
import { urlToBase64 } from "../utils/utils.ts";
|
import { urlToBase64 } from "../../util/utils.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:
|
||||||
*
|
*
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { ChannelCreatePayload, Unpromise } from "../types/types.ts";
|
import { ChannelCreatePayload, Unpromise } from "../../types/types.ts";
|
||||||
|
|
||||||
export async function createChannel(
|
export async function createChannel(
|
||||||
data: ChannelCreatePayload,
|
data: ChannelCreatePayload,
|
||||||
@@ -2,8 +2,8 @@ import {
|
|||||||
CreateGuildPayload,
|
CreateGuildPayload,
|
||||||
MemberCreatePayload,
|
MemberCreatePayload,
|
||||||
Unpromise,
|
Unpromise,
|
||||||
} from "../types/types.ts";
|
} from "../../types/types.ts";
|
||||||
import { Collection } from "../utils/collection.ts";
|
import { Collection } from "../../util/collection.ts";
|
||||||
import { structures } from "./mod.ts";
|
import { structures } from "./mod.ts";
|
||||||
|
|
||||||
export const initialMemberLoadQueue = new Map<string, MemberCreatePayload[]>();
|
export const initialMemberLoadQueue = new Map<string, MemberCreatePayload[]>();
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../controllers/cache.ts";
|
||||||
import { GuildMember, MemberCreatePayload, Unpromise } from "../types/types.ts";
|
import {
|
||||||
import { Collection } from "../utils/collection.ts";
|
GuildMember,
|
||||||
|
MemberCreatePayload,
|
||||||
|
Unpromise,
|
||||||
|
} from "../../types/types.ts";
|
||||||
|
import { Collection } from "../../util/collection.ts";
|
||||||
|
|
||||||
export async function createMember(data: MemberCreatePayload, guildID: string) {
|
export async function createMember(data: MemberCreatePayload, guildID: string) {
|
||||||
const {
|
const {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { MessageCreateOptions, Unpromise } from "../types/types.ts";
|
import { MessageCreateOptions, Unpromise } from "../../types/types.ts";
|
||||||
|
|
||||||
export async function createMessage(data: MessageCreateOptions) {
|
export async function createMessage(data: MessageCreateOptions) {
|
||||||
const {
|
const {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RoleData, Unpromise } from "../types/types.ts";
|
import { RoleData, Unpromise } from "../../types/types.ts";
|
||||||
|
|
||||||
export async function createRole(data: RoleData) {
|
export async function createRole(data: RoleData) {
|
||||||
const { tags, ...rest } = data;
|
const { tags, ...rest } = data;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GuildTemplate } from "../types/types.ts";
|
import { GuildTemplate } from "../../types/types.ts";
|
||||||
|
|
||||||
export function createTemplate(
|
export function createTemplate(
|
||||||
data: GuildTemplate,
|
data: GuildTemplate,
|
||||||
@@ -2,10 +2,10 @@ import {
|
|||||||
ClientOptions,
|
ClientOptions,
|
||||||
DiscordBotGatewayData,
|
DiscordBotGatewayData,
|
||||||
EventHandlers,
|
EventHandlers,
|
||||||
} from "../types/types.ts";
|
} from "./types/types.ts";
|
||||||
import { baseEndpoints, endpoints } from "../utils/constants.ts";
|
import { baseEndpoints, endpoints } from "./util/constants.ts";
|
||||||
import { RequestManager } from "./requestManager.ts";
|
import { RequestManager } from "./rest/mod.ts";
|
||||||
import { spawnShards } from "./shardingManager.ts";
|
import { spawnShards } from "./ws/shard_manager.ts";
|
||||||
|
|
||||||
export let authorization = "";
|
export let authorization = "";
|
||||||
export let botID = "";
|
export let botID = "";
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { delay } from "../../deps.ts";
|
|
||||||
import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts";
|
import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts";
|
||||||
import { baseEndpoints, discordAPIURLS } from "../utils/constants.ts";
|
import { baseEndpoints, discordAPIURLS } from "../util/constants.ts";
|
||||||
import { authorization, eventHandlers } from "./client.ts";
|
import { delay } from "../util/utils.ts";
|
||||||
|
import { authorization, eventHandlers } from "../bot.ts";
|
||||||
|
|
||||||
const pathQueues: { [key: string]: QueuedRequest[] } = {};
|
const pathQueues: { [key: string]: QueuedRequest[] } = {};
|
||||||
const ratelimitedPaths = new Map<string, RateLimitedPath>();
|
const ratelimitedPaths = new Map<string, RateLimitedPath>();
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { Guild } from "../structures/structures.ts";
|
import { Guild } from "../api/structures/structures.ts";
|
||||||
import { ChannelCreatePayload, ChannelTypes } from "./channel.ts";
|
import { ChannelCreatePayload, ChannelTypes } from "./channel.ts";
|
||||||
import { Emoji, StatusType } from "./discord.ts";
|
import { Emoji, StatusType } from "./discord.ts";
|
||||||
import { MemberCreatePayload } from "./member.ts";
|
import { MemberCreatePayload } from "./member.ts";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Channel } from "../structures/structures.ts";
|
import { Channel } from "../api/structures/structures.ts";
|
||||||
import { ChannelType } from "./channel.ts";
|
import { ChannelType } from "./channel.ts";
|
||||||
import { UserPayload } from "./guild.ts";
|
import { UserPayload } from "./guild.ts";
|
||||||
import { MemberCreatePayload } from "./member.ts";
|
import { MemberCreatePayload } from "./member.ts";
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
Member,
|
Member,
|
||||||
Message,
|
Message,
|
||||||
Role,
|
Role,
|
||||||
} from "../structures/structures.ts";
|
} from "../api/structures/structures.ts";
|
||||||
import {
|
import {
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
Emoji,
|
Emoji,
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { Channel, Guild, Member, Message } from "../structures/structures.ts";
|
import {
|
||||||
|
Channel,
|
||||||
|
Guild,
|
||||||
|
Member,
|
||||||
|
Message,
|
||||||
|
} from "../api/structures/structures.ts";
|
||||||
import { PresenceUpdatePayload } from "../types/types.ts";
|
import { PresenceUpdatePayload } from "../types/types.ts";
|
||||||
import { Collection } from "./collection.ts";
|
import { Collection } from "./collection.ts";
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cacheHandlers } from "../controllers/cache.ts";
|
import { cacheHandlers } from "../api/controllers/cache.ts";
|
||||||
import { botID } from "../module/client.ts";
|
import { botID } from "../bot.ts";
|
||||||
import { Guild, Role } from "../structures/structures.ts";
|
import { Guild, Role } from "../api/structures/structures.ts";
|
||||||
import { Permission, Permissions, RawOverwrite } from "../types/types.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. */
|
/** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { encode } from "../../deps.ts";
|
import { sendGatewayCommand } from "../ws/shard_manager.ts";
|
||||||
import { sendGatewayCommand } from "../module/shardingManager.ts";
|
|
||||||
import { ActivityType, StatusType } from "../types/types.ts";
|
import { ActivityType, StatusType } from "../types/types.ts";
|
||||||
|
import { encode } from "../../deps.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));
|
||||||
@@ -32,3 +32,11 @@ export async function urlToBase64(url: string) {
|
|||||||
const type = url.substring(url.lastIndexOf(".") + 1);
|
const type = url.substring(url.lastIndexOf(".") + 1);
|
||||||
return `data:image/${type};base64,${imageStr}`;
|
return `data:image/${type};base64,${imageStr}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function delay(ms: number): Promise<void> {
|
||||||
|
return new Promise((res): number =>
|
||||||
|
setTimeout((): void => {
|
||||||
|
res();
|
||||||
|
}, ms)
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { decompress_with as decompressWith } from "https://unpkg.com/@evan/wasm@0.0.22/target/zlib/deno.js";
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { delay, inflate } from "../../deps.ts";
|
import { botGatewayData, eventHandlers } from "../bot.ts";
|
||||||
import { eventHandlers } from "../../mod.ts";
|
|
||||||
import {
|
import {
|
||||||
DiscordBotGatewayData,
|
DiscordBotGatewayData,
|
||||||
DiscordHeartbeatPayload,
|
DiscordHeartbeatPayload,
|
||||||
@@ -7,9 +6,10 @@ import {
|
|||||||
GatewayOpcode,
|
GatewayOpcode,
|
||||||
ReadyPayload,
|
ReadyPayload,
|
||||||
} from "../types/types.ts";
|
} from "../types/types.ts";
|
||||||
import { BotStatusRequest } from "../utils/utils.ts";
|
import { BotStatusRequest, delay } from "../util/utils.ts";
|
||||||
import { botGatewayData, IdentifyPayload, proxyWSURL } from "./client.ts";
|
import { IdentifyPayload, proxyWSURL } from "../bot.ts";
|
||||||
import { handleDiscordPayload } from "./shardingManager.ts";
|
import { handleDiscordPayload } from "./shard_manager.ts";
|
||||||
|
import { decompressWith } from "./deps.ts";
|
||||||
|
|
||||||
const basicShards = new Map<number, BasicShard>();
|
const basicShards = new Map<number, BasicShard>();
|
||||||
const heartbeating = new Map<number, boolean>();
|
const heartbeating = new Map<number, boolean>();
|
||||||
@@ -73,7 +73,7 @@ export async function createShard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message instanceof Uint8Array) {
|
if (message instanceof Uint8Array) {
|
||||||
message = inflate(
|
message = decompressWith(
|
||||||
message,
|
message,
|
||||||
0,
|
0,
|
||||||
(slice: Uint8Array) => utf8decoder.decode(slice),
|
(slice: Uint8Array) => utf8decoder.decode(slice),
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
import { delay } from "../../deps.ts";
|
import { controllers } from "../api/controllers/mod.ts";
|
||||||
import { controllers } from "../controllers/mod.ts";
|
import { Guild } from "../api/structures/structures.ts";
|
||||||
import { Guild } from "../structures/structures.ts";
|
|
||||||
import {
|
import {
|
||||||
DiscordBotGatewayData,
|
DiscordBotGatewayData,
|
||||||
DiscordPayload,
|
DiscordPayload,
|
||||||
FetchMembersOptions,
|
FetchMembersOptions,
|
||||||
GatewayOpcode,
|
GatewayOpcode,
|
||||||
} from "../types/types.ts";
|
} from "../types/types.ts";
|
||||||
import { cache } from "../utils/cache.ts";
|
import { cache } from "../util/cache.ts";
|
||||||
import { BotStatusRequest } from "../utils/utils.ts";
|
import { BotStatusRequest, delay } from "../util/utils.ts";
|
||||||
import {
|
import {
|
||||||
botGatewayStatusRequest,
|
botGatewayStatusRequest,
|
||||||
createShard,
|
createShard,
|
||||||
requestGuildMembers,
|
requestGuildMembers,
|
||||||
} from "./shard.ts";
|
} from "./mod.ts";
|
||||||
import { eventHandlers, IdentifyPayload } from "./client.ts";
|
import { eventHandlers, IdentifyPayload } from "../bot.ts";
|
||||||
|
|
||||||
let createNextShard = true;
|
let createNextShard = true;
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export {
|
||||||
|
assert,
|
||||||
|
assertArrayIncludes,
|
||||||
|
assertEquals,
|
||||||
|
} from "https://deno.land/std@0.81.0/testing/asserts.ts";
|
||||||
Reference in New Issue
Block a user