Files
discordeno/src/handlers/channels/CHANNEL_PINS_UPDATE.ts
T
ayntee 8654aeded5 refactor: rename controllers to handlers and handlers to helpers (#660)
* refactor: rename controllers to handlers and handlers to helpers

* fmt
2021-03-11 21:41:03 +04:00

20 lines
606 B
TypeScript

import { eventHandlers } from "../../bot.ts";
import {
DiscordChannelPinsUpdateEvent,
DiscordPayload,
} from "../../types/mod.ts";
import { cacheHandlers } from "../../cache.ts";
export async function handleChannelPinsUpdate(data: DiscordPayload) {
const payload = data.d as DiscordChannelPinsUpdateEvent;
const channel = await cacheHandlers.get("channels", payload.channel_id);
if (!channel) return;
const guild = payload.guild_id
? await cacheHandlers.get("guilds", payload.guild_id)
: undefined;
eventHandlers.channelPinsUpdate?.(channel, guild, payload.last_pin_timestamp);
}