diff --git a/src/handlers/channels/THREAD_DELETE.ts b/src/handlers/channels/THREAD_DELETE.ts index 7efc6a17f..171230943 100644 --- a/src/handlers/channels/THREAD_DELETE.ts +++ b/src/handlers/channels/THREAD_DELETE.ts @@ -6,12 +6,9 @@ import { snowflakeToBigint } from "../../util/bigint.ts"; export async function handleThreadDelete(data: DiscordGatewayPayload) { // const payload = data.d as Channel; - // const cachedChannel = await cacheHandlers.get("threads", snowflakeToBigint(payload.id)); // if (!cachedChannel) return; - // await cacheHandlers.delete("threads", snowflakeToBigint(payload.id)); // await cacheHandlers.forEach("DELETE_MESSAGES_FROM_CHANNEL", { channelId: snowflakeToBigint(payload.id) }); - // eventHandlers.threadDelete?.(cachedChannel); } diff --git a/src/handlers/channels/THREAD_LIST_SYNC.ts b/src/handlers/channels/THREAD_LIST_SYNC.ts index 35006162b..167ae9349 100644 --- a/src/handlers/channels/THREAD_LIST_SYNC.ts +++ b/src/handlers/channels/THREAD_LIST_SYNC.ts @@ -9,16 +9,13 @@ import { Collection } from "../../util/collection.ts"; export async function handleThreadListSync(data: DiscordGatewayPayload) { // const payload = data.d as ThreadListSync; - // const threads = await Promise.all( // payload.threads.map(async (thread) => { // const threadData = channelToThread(thread); // await cacheHandlers.set("threads", threadData.id, threadData); - // return threadData; // }) // ); - // eventHandlers.threadListSync?.( // new Collection(threads.map((t) => [t.id, t])), // payload.members.map((member) => threadMemberModified(member)), diff --git a/src/handlers/channels/THREAD_MEMBERS_UPDATE.ts b/src/handlers/channels/THREAD_MEMBERS_UPDATE.ts index 85c935cfd..4a7030097 100644 --- a/src/handlers/channels/THREAD_MEMBERS_UPDATE.ts +++ b/src/handlers/channels/THREAD_MEMBERS_UPDATE.ts @@ -6,12 +6,10 @@ import { snowflakeToBigint } from "../../util/bigint.ts"; // import { threadMembersUpdateModified } from "../../util/transformers/thread_members_update_modified.ts"; export async function handleThreadMembersUpdate(data: DiscordGatewayPayload) { -// const payload = data.d as ThreadMembersUpdate; -// const thread = await cacheHandlers.get("threads", snowflakeToBigint(payload.id)); -// if (!thread) return; - -// thread.memberCount = payload.memberCount; -// await cacheHandlers.set("threads", thread.id, thread); - -// eventHandlers.threadMembersUpdate?.(threadMembersUpdateModified(payload)); + // const payload = data.d as ThreadMembersUpdate; + // const thread = await cacheHandlers.get("threads", snowflakeToBigint(payload.id)); + // if (!thread) return; + // thread.memberCount = payload.memberCount; + // await cacheHandlers.set("threads", thread.id, thread); + // eventHandlers.threadMembersUpdate?.(threadMembersUpdateModified(payload)); } diff --git a/src/handlers/channels/THREAD_MEMBER_UPDATE.ts b/src/handlers/channels/THREAD_MEMBER_UPDATE.ts index 7ba5521ee..fce3dfd92 100644 --- a/src/handlers/channels/THREAD_MEMBER_UPDATE.ts +++ b/src/handlers/channels/THREAD_MEMBER_UPDATE.ts @@ -9,16 +9,13 @@ export async function handleThreadMemberUpdate(data: DiscordGatewayPayload) { // // The id field is omitted from the thread member dispatched within the GUILD_CREATE gateway event. // const thread = await cacheHandlers.get("threads", snowflakeToBigint(payload.id!)); // if (!thread) return; - // thread.botIsMember = true; // await cacheHandlers.set("threads", thread.id, thread); - // const member = { // ...payload, // id: snowflakeToBigint(payload.id!), // userId: snowflakeToBigint(payload.userId!), // joinTimestamp: Date.parse(payload.joinTimestamp), // }; - // eventHandlers.threadMemberUpdate?.(member, thread); } diff --git a/src/handlers/channels/THREAD_UPDATE.ts b/src/handlers/channels/THREAD_UPDATE.ts index cba001139..ee772ce85 100644 --- a/src/handlers/channels/THREAD_UPDATE.ts +++ b/src/handlers/channels/THREAD_UPDATE.ts @@ -9,9 +9,7 @@ export async function handleThreadUpdate(data: DiscordGatewayPayload) { // const payload = data.d as Channel; // const oldThread = await cacheHandlers.get("threads", snowflakeToBigint(payload.id)); // if (!oldThread) return; - // const thread = channelToThread(payload); // await cacheHandlers.set("threads", thread.id, thread); - // eventHandlers.threadUpdate?.(thread, oldThread); } diff --git a/src/helpers/channels/threads/edit_thread.ts b/src/helpers/channels/threads/edit_thread.ts index 363f22598..76e3b2194 100644 --- a/src/helpers/channels/threads/edit_thread.ts +++ b/src/helpers/channels/threads/edit_thread.ts @@ -5,9 +5,7 @@ import type { Bot } from "../../../bot.ts"; /** Update a thread's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */ export async function editThread(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) { // const thread = await cacheHandlers.get("threads", threadId); - // TODO: permission checking - // const result = await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.CHANNEL_BASE(threadId), { // name: options.name, // archived: options.archived, @@ -16,6 +14,5 @@ export async function editThread(bot: Bot, threadId: bigint, options: ModifyThre // rate_limit_per_user: options.rateLimitPerUser, // reason, // }); - // return channelToThread(result); } diff --git a/src/helpers/channels/threads/get_active_threads.ts b/src/helpers/channels/threads/get_active_threads.ts index 87a75a092..7fb73520c 100644 --- a/src/helpers/channels/threads/get_active_threads.ts +++ b/src/helpers/channels/threads/get_active_threads.ts @@ -6,21 +6,18 @@ import { Collection } from "../../../util/collection.ts"; /** Returns all active threads in the channel, including public and private threads. Threads are ordered by their id, in descending order. Requires the VIEW_CHANNEL permission. */ export async function getActiveThreads(bot: Bot, channelId: bigint) { // await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]); - // // TODO: pagination // const result = (await bot.rest.runMethod( // bot.rest, // "get", // bot.constants.endpoints.THREAD_ACTIVE(channelId) // )) as ListActiveThreads; - // const threads = new Collection( // result.threads.map((t) => { // const ddThread = channelToThread(t); // return [ddThread.id, ddThread]; // }) // ); - // for (const member of result.members) { // const thread = threads.get(bot.transformers.snowflake(member.id!)); // thread?.members.set(bot.transformers.snowflake(member.userId!), { @@ -29,6 +26,5 @@ export async function getActiveThreads(bot: Bot, channelId: bigint) { // joinTimestamp: Date.parse(member.joinTimestamp), // }); // } - // return threads; } diff --git a/src/helpers/channels/threads/get_archived_threads.ts b/src/helpers/channels/threads/get_archived_threads.ts index 9e5d100b7..02bfa0ae6 100644 --- a/src/helpers/channels/threads/get_archived_threads.ts +++ b/src/helpers/channels/threads/get_archived_threads.ts @@ -15,11 +15,8 @@ export async function getArchivedThreads( ) { // const permissions = new Set(["READ_MESSAGE_HISTORY"]); // if (options?.type === "private") permissions.add("MANAGE_THREADS"); - // await bot.utils.requireBotChannelPermissions(bot, channelId, [...permissions]); - // // TODO: pagination - // const result = (await bot.rest.runMethod( // bot.rest, // "get", @@ -36,14 +33,12 @@ export async function getArchivedThreads( // } // : {} // )) as ListActiveThreads; - // const threads = new Collection( // result.threads.map((t) => { // const ddThread = channelToThread(t); // return [ddThread.id, ddThread]; // }) // ); - // for (const member of result.members) { // const thread = threads.get(bot.transformers.snowflake(member.id!)); // thread?.members.set(bot.transformers.snowflake(member.userId!), { @@ -52,6 +47,5 @@ export async function getArchivedThreads( // joinTimestamp: Date.parse(member.joinTimestamp), // }); // } - // return threads; } diff --git a/src/helpers/channels/threads/get_thread_members.ts b/src/helpers/channels/threads/get_thread_members.ts index e76095c14..4a65f5962 100644 --- a/src/helpers/channels/threads/get_thread_members.ts +++ b/src/helpers/channels/threads/get_thread_members.ts @@ -13,21 +13,17 @@ export async function getThreadMembers(bot: Bot, threadId: bigint) { // ) { // throw new Error(bot.constants.Errors.MISSING_INTENT_GUILD_MEMBERS); // } - // const thread = await bot.cache.threads.get(threadId); // if (thread?.isPrivate) { // const channel = await bot.cache.channels.get(thread.parentId); // if (channel && !(await bot.utils.botHasChannelPermissions(bot, channel, ["MANAGE_THREADS"])) && !thread.botIsMember) // throw new Error(bot.constants.Errors.CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD); // } - // const result = await bot.rest.runMethod( // bot.rest, // "get", // bot.constants.endpoints.THREAD_MEMBERS(threadId) // ); - // const members = result.map((member) => threadMemberModified(member)); - // return new Collection(members.map((member) => [member.id, member])); } diff --git a/src/helpers/channels/threads/start_private_thread.ts b/src/helpers/channels/threads/start_private_thread.ts index 28f1eaa7f..b904e04dd 100644 --- a/src/helpers/channels/threads/start_private_thread.ts +++ b/src/helpers/channels/threads/start_private_thread.ts @@ -7,12 +7,9 @@ export async function startPrivateThread(bot: Bot, channelId: bigint, options: S // const channel = await bot.cache.channels.get(channelId); // if (channel) { // if (!channel.isGuildTextBasedChannel) throw new Error(bot.constants.Errors.INVALID_THREAD_PARENT_CHANNEL_TYPE); - // if (channel.isNewsChannel) throw new Error(bot.constants.Errors.GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS); - // await bot.utils.requireBotChannelPermissions(bot, channel, ["SEND_MESSAGES", "USE_PRIVATE_THREADS"]); // } - // return channelToThread( // await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), { // name: options.name, diff --git a/src/helpers/channels/threads/start_thread.ts b/src/helpers/channels/threads/start_thread.ts index bbf9ace01..2c072ebdd 100644 --- a/src/helpers/channels/threads/start_thread.ts +++ b/src/helpers/channels/threads/start_thread.ts @@ -9,10 +9,8 @@ export async function startThread(bot: Bot, channelId: bigint, messageId: bigint // if (!channel.isGuildTextBasedChannel) { // throw new Error(bot.constants.Errors.INVALID_THREAD_PARENT_CHANNEL_TYPE); // } - // await bot.utils.requireBotChannelPermissions(bot, channel, ["SEND_MESSAGES", "USE_PUBLIC_THREADS"]); // } - // return channelToThread( // await bot.rest.runMethod( // bot.rest, diff --git a/tests/mod.ts b/tests/mod.ts index df767137e..eb7edaaf8 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -1,29 +1,18 @@ import { TOKEN } from "../configs.ts"; import { Bot, createBot, createEventHandlers, startBot } from "../mod.ts"; -Deno.test("[Bot] - Starting Tests", async (t) => { - const bot = createBot({ - token: TOKEN || Deno.env.get('DISCORD_TOKEN'), - botId: 0n, - events: createEventHandlers({ - - }), - intents: [], - }) - - await startBot(bot as Bot); - - console.log('Bot online') -}) - - - - - - - +Deno.test("[Bot] - Starting Tests", async (t) => { + const bot = createBot({ + token: TOKEN || Deno.env.get("DISCORD_TOKEN"), + botId: 0n, + events: createEventHandlers({}), + intents: [], + }); + await startBot(bot as Bot); + console.log("Bot online"); +}); // // THE ORDER OF THE IMPORTS IN THIS FILE MATTER! // // DO NOT MOVE THEM UNLESS YOU KNOW WHAT YOUR DOING! @@ -115,5 +104,3 @@ Deno.test("[Bot] - Starting Tests", async (t) => { // await delay(3000); // } - -