mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
add: THREAD_LIST_SYNC handlere
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordenoChannel } from "../../structures/channel.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { ThreadListSync } from "../../types/channels/threads/thread_list_sync.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
|
||||
export async function handleThreadListSync(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as ThreadListSync;
|
||||
|
||||
const discordenoChannels = await Promise.all(
|
||||
payload.threads.map(async (thread) => {
|
||||
const discordenoChannel = await structures.createDiscordenoChannel(
|
||||
thread,
|
||||
payload.guildId,
|
||||
);
|
||||
|
||||
await cacheHandlers.set(
|
||||
"channels",
|
||||
discordenoChannel.id,
|
||||
discordenoChannel,
|
||||
);
|
||||
|
||||
return discordenoChannel;
|
||||
}),
|
||||
);
|
||||
|
||||
const threads = new Collection<string, DiscordenoChannel>(
|
||||
discordenoChannels.map((t) => [t.id, t]),
|
||||
);
|
||||
|
||||
eventHandlers.threadListSync?.(threads, payload.members, payload.guildId);
|
||||
}
|
||||
Reference in New Issue
Block a user