feat(controllers): add VOICE_SERVER_UPDATE event (#652)

This commit is contained in:
ayntee
2021-03-10 20:27:32 +04:00
committed by GitHub
parent 724f09b4f7
commit 26019cbfd1
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import { eventHandlers } from "../../bot.ts";
import {
DiscordPayload,
DiscordVoiceServerUpdateEvent,
} from "../../types/mod.ts";
import { cacheHandlers } from "./cache.ts";
export async function handleVoiceServerUpdate(data: DiscordPayload) {
const payload = data.d as DiscordVoiceServerUpdateEvent;
const guild = await cacheHandlers.get("guilds", payload.guild_id);
if (!guild) return;
eventHandlers.voiceServerUpdate?.(payload.token, guild, payload.endpoint);
}

View File

@@ -55,6 +55,7 @@ import {
handleInternalGuildRoleDelete,
handleInternalGuildRoleUpdate,
} from "./roles.ts";
import { handleVoiceServerUpdate } from "./VOICE_SERVER_UPDATE.ts";
export let controllers = {
READY: handleInternalReady,
@@ -90,6 +91,7 @@ export let controllers = {
TYPING_START: handleInternalTypingStart,
USER_UPDATE: handleInternalUserUpdate,
VOICE_STATE_UPDATE: handleInternalVoiceStateUpdate,
VOICE_SERVER_UPDATE: handleVoiceServerUpdate,
WEBHOOKS_UPDATE: handleInternalWebhooksUpdate,
INTEGRATION_CREATE: handleInternalIntegrationCreate,
INTEGRATION_UPDATE: handleInternalIntegrationUpdate,

View File

@@ -225,6 +225,12 @@ export interface EventHandlers {
member: Member,
voiceState: VoiceStateUpdatePayload,
) => unknown;
/** Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server. */
voiceServerUpdate?: (
token: string,
guild: Guild,
endpoint: string,
) => unknown;
/** Sent when a guild channel's webhook is created, updated, or deleted. */
webhooksUpdate?: (channelID: string, guildID: string) => unknown;
/** Sent when a member has passed the guild's Membership Screening requirements */