mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
6bd233da6f
fix: bunch of imports that were missing
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { eventHandlers } from "../../bot.ts";
|
|
import { cache, cacheHandlers } from "../../cache.ts";
|
|
import { structures } from "../../structures/mod.ts";
|
|
import { basicShards } from "../../ws/shard.ts";
|
|
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
|
import { DiscordGuild } from "../../types/guilds/guild.ts";
|
|
|
|
export async function handleGuildCreate(
|
|
data: DiscordGatewayPayload,
|
|
shardId: number,
|
|
) {
|
|
const payload = data.d as DiscordGuild;
|
|
// When shards resume they emit GUILD_CREATE again.
|
|
if (await cacheHandlers.has("guilds", payload.id)) return;
|
|
|
|
const guildStruct = await structures.createGuildStruct(
|
|
data.d,
|
|
shardId,
|
|
);
|
|
await cacheHandlers.set("guilds", guildStruct.id, guildStruct);
|
|
|
|
const shard = basicShards.get(shardId);
|
|
|
|
if (shard?.unavailableGuildIds.has(payload.id)) {
|
|
await cacheHandlers.delete("unavailableGuilds", payload.id);
|
|
|
|
shard.unavailableGuildIds.delete(payload.id);
|
|
|
|
return eventHandlers.guildAvailable?.(guildStruct);
|
|
}
|
|
|
|
if (!cache.isReady) return eventHandlers.guildLoaded?.(guildStruct);
|
|
eventHandlers.guildCreate?.(guildStruct);
|
|
}
|