Files
discordeno/src/handlers/guilds/GUILD_UPDATE.ts
T
2021-10-21 17:41:47 +02:00

15 lines
638 B
TypeScript

import type { Bot } from "../../bot.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import type { Guild } from "../../types/guilds/guild.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
export async function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
const payload = data.d as SnakeCasedPropertiesDeep<Guild>;
const guild = bot.transformers.guild(bot, { guild: payload, shardId });
const cached = await bot.cache.guilds.get(guild.id);
await bot.cache.guilds.set(guild.id, guild);
bot.events.guildUpdate(bot, guild, cached);
}