diff --git a/src/handlers/guilds/GUILD_BAN_ADD.ts b/src/handlers/guilds/GUILD_BAN_ADD.ts index 7fa687f12..26df8e004 100644 --- a/src/handlers/guilds/GUILD_BAN_ADD.ts +++ b/src/handlers/guilds/GUILD_BAN_ADD.ts @@ -1,6 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import { DiscordGuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; export async function handleGuildBanAdd(data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildBanAddRemove; diff --git a/src/handlers/guilds/GUILD_BAN_REMOVE.ts b/src/handlers/guilds/GUILD_BAN_REMOVE.ts index 14022ede5..61301ce4c 100644 --- a/src/handlers/guilds/GUILD_BAN_REMOVE.ts +++ b/src/handlers/guilds/GUILD_BAN_REMOVE.ts @@ -1,6 +1,7 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; +import { DiscordGuildBanAddRemove } from "../../types/guilds/guild_ban_add_remove.ts"; export async function handleGuildBanRemove(data: DiscordGatewayPayload) { const payload = data.d as DiscordGuildBanAddRemove; diff --git a/src/handlers/guilds/GUILD_UPDATE.ts b/src/handlers/guilds/GUILD_UPDATE.ts index cb92b88af..11898a945 100644 --- a/src/handlers/guilds/GUILD_UPDATE.ts +++ b/src/handlers/guilds/GUILD_UPDATE.ts @@ -1,18 +1,19 @@ import { eventHandlers } from "../../bot.ts"; import { cacheHandlers } from "../../cache.ts"; +import { GuildUpdateChange } from "../../types/discordeno/guild_update_change.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGuild } from "../../types/guilds/guild.ts"; export async function handleGuildUpdate(data: DiscordGatewayPayload) { const payload = data.d as DiscordGuild; - const cachedGuild = await cacheHandlers.get("guilds", payload.id); - if (!cachedGuild) return; + const newGuild = await cacheHandlers.get("guilds", payload.id); + if (!newGuild) return; const keysToSkip = [ "roles", - "guild_hashes", - "guild_id", - "max_members", + "guildHashes", + "guildId", + "maxMembers", "emojis", ]; @@ -21,7 +22,7 @@ export async function handleGuildUpdate(data: DiscordGatewayPayload) { if (keysToSkip.includes(key)) return; // @ts-ignore index signature - const cachedValue = cachedGuild[key]; + const cachedValue = newGuild[key]; if (cachedValue !== value) { // Guild create sends undefined and update sends false. if (!cachedValue && !value) return; @@ -34,12 +35,12 @@ export async function handleGuildUpdate(data: DiscordGatewayPayload) { } // @ts-ignore index signature - cachedGuild[key] = value; + newGuild[key] = value; return { key, oldValue: cachedValue, value }; } }).filter((change) => change) as GuildUpdateChange[]; - await cacheHandlers.set("guilds", payload.id, cachedGuild); + await cacheHandlers.set("guilds", payload.id, newGuild); - eventHandlers.guildUpdate?.(cachedGuild, changes); + eventHandlers.guildUpdate?.(newGuild, changes); }