diff --git a/packages/bot/src/bot.ts b/packages/bot/src/bot.ts index b4a339f82..8b11a40f0 100644 --- a/packages/bot/src/bot.ts +++ b/packages/bot/src/bot.ts @@ -2,7 +2,14 @@ import type { CreateGatewayManagerOptions, GatewayManager } from '@discordeno/ga import { ShardSocketCloseCodes, createGatewayManager } from '@discordeno/gateway' import type { CreateRestManagerOptions, RestManager } from '@discordeno/rest' import { createRestManager } from '@discordeno/rest' -import type { BigString, DiscordGatewayPayload, DiscordReady, GatewayIntents, RecursivePartial } from '@discordeno/types' +import type { + BigString, + DiscordGatewayPayload, + DiscordReady, + DiscordVoiceChannelEffectAnimationType, + GatewayIntents, + RecursivePartial, +} from '@discordeno/types' import { type Collection, createLogger, getBotIdFromToken, type logger } from '@discordeno/utils' import { createBotGatewayHandlers } from './handlers.js' import { type BotHelpers, createBotHelpers } from './helpers.js' @@ -238,6 +245,16 @@ export interface EventHandlers { reactionRemoveEmoji: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji }) => unknown reactionRemoveAll: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint }) => unknown presenceUpdate: (presence: PresenceUpdate) => unknown + voiceChannelEffectSend: (payload: { + channelId: bigint + guildId: bigint + userId: bigint + emoji?: Emoji + animationType?: DiscordVoiceChannelEffectAnimationType + animationId?: number + soundId?: bigint | number + soundVolume?: number + }) => unknown voiceServerUpdate: (payload: { token: string; endpoint?: string; guildId: bigint }) => unknown voiceStateUpdate: (voiceState: VoiceState) => unknown channelCreate: (channel: Channel) => unknown diff --git a/packages/bot/src/handlers.ts b/packages/bot/src/handlers.ts index 6b76d043b..84d143f68 100644 --- a/packages/bot/src/handlers.ts +++ b/packages/bot/src/handlers.ts @@ -63,6 +63,7 @@ export function createBotGatewayHandlers( THREAD_MEMBERS_UPDATE: options.THREAD_MEMBERS_UPDATE ?? handlers.handleThreadMembersUpdate, TYPING_START: options.TYPING_START ?? handlers.handleTypingStart, USER_UPDATE: options.USER_UPDATE ?? handlers.handleUserUpdate, + VOICE_CHANNEL_EFFECT_SEND: options.VOICE_CHANNEL_EFFECT_SEND ?? handlers.handleVoiceChannelEffectSend, VOICE_SERVER_UPDATE: options.VOICE_SERVER_UPDATE ?? handlers.handleVoiceServerUpdate, VOICE_STATE_UPDATE: options.VOICE_STATE_UPDATE ?? handlers.handleVoiceStateUpdate, WEBHOOKS_UPDATE: options.WEBHOOKS_UPDATE ?? handlers.handleWebhooksUpdate, diff --git a/packages/bot/src/handlers/voice/VOICE_CHANNEL_EFFECT_SEND.ts b/packages/bot/src/handlers/voice/VOICE_CHANNEL_EFFECT_SEND.ts new file mode 100644 index 000000000..f2b1f60e5 --- /dev/null +++ b/packages/bot/src/handlers/voice/VOICE_CHANNEL_EFFECT_SEND.ts @@ -0,0 +1,19 @@ +import type { DiscordGatewayPayload, DiscordVoiceChannelEffectSend } from '@discordeno/types' +import type { Bot } from '../../index.js' + +export async function handleVoiceChannelEffectSend(bot: Bot, data: DiscordGatewayPayload): Promise { + if (!bot.events.voiceChannelEffectSend) return + + const payload = data.d as DiscordVoiceChannelEffectSend + + bot.events.voiceChannelEffectSend({ + guildId: bot.transformers.snowflake(payload.guild_id), + channelId: bot.transformers.snowflake(payload.channel_id), + userId: bot.transformers.snowflake(payload.user_id), + animationType: payload.animation_type ?? undefined, + animationId: payload.animation_id ?? undefined, + emoji: payload.emoji ? bot.transformers.emoji(bot, payload.emoji) : undefined, + soundId: typeof payload.sound_id === 'string' ? bot.transformers.snowflake(payload.sound_id) : payload.sound_id, + soundVolume: payload.sound_volume, + }) +} diff --git a/packages/bot/src/handlers/voice/index.ts b/packages/bot/src/handlers/voice/index.ts index 6302f4659..2514c703a 100644 --- a/packages/bot/src/handlers/voice/index.ts +++ b/packages/bot/src/handlers/voice/index.ts @@ -1,2 +1,3 @@ export * from './VOICE_SERVER_UPDATE.js' export * from './VOICE_STATE_UPDATE.js' +export * from './VOICE_CHANNEL_EFFECT_SEND.js' diff --git a/packages/bot/src/typings.ts b/packages/bot/src/typings.ts index c62d13b88..7cd3bffab 100644 --- a/packages/bot/src/typings.ts +++ b/packages/bot/src/typings.ts @@ -197,6 +197,7 @@ export interface BotGatewayHandlerOptions { PRESENCE_UPDATE: typeof handlers.handlePresenceUpdate TYPING_START: typeof handlers.handleTypingStart USER_UPDATE: typeof handlers.handleUserUpdate + VOICE_CHANNEL_EFFECT_SEND: typeof handlers.handleVoiceChannelEffectSend VOICE_SERVER_UPDATE: typeof handlers.handleVoiceServerUpdate VOICE_STATE_UPDATE: typeof handlers.handleVoiceStateUpdate WEBHOOKS_UPDATE: typeof handlers.handleWebhooksUpdate diff --git a/packages/types/src/discord.ts b/packages/types/src/discord.ts index 4b10335f5..46057db39 100644 --- a/packages/types/src/discord.ts +++ b/packages/types/src/discord.ts @@ -2828,6 +2828,34 @@ export interface DiscordVoiceServerUpdate { endpoint: string | null } +/** https://discord.com/developers/docs/topics/gateway-events#voice-channel-effect-send-voice-channel-effect-send-event-fields */ +export interface DiscordVoiceChannelEffectSend { + /** ID of the channel the effect was sent in */ + channel_id: string + /** ID of the guild the effect was sent in */ + guild_id: string + /** ID of the user who sent the effect */ + user_id: string + /** The emoji sent, for emoji reaction and soundboard effects */ + emoji?: DiscordEmoji | null + /** The type of emoji animation, for emoji reaction and soundboard effects */ + animation_type?: DiscordVoiceChannelEffectAnimationType | null + /** The ID of the emoji animation, for emoji reaction and soundboard effects */ + animation_id?: number | null + /** The ID of the soundboard sound, for soundboard effects */ + sound_id?: string | number + /** The volume of the soundboard sound, from 0 to 1, for soundboard effects */ + sound_volume?: number +} + +/** https://discord.com/developers/docs/topics/gateway-events#voice-channel-effect-send-animation-types */ +export enum DiscordVoiceChannelEffectAnimationType { + /** A fun animation, sent by a Nitro subscriber */ + Premium = 0, + /** The standard animation */ + Basic = 1, +} + /** https://discord.com/developers/docs/topics/gateway#invite-create */ export interface DiscordInviteCreate { /** The channel the invite is for */ diff --git a/packages/types/src/shared.ts b/packages/types/src/shared.ts index 1805fe894..5b6c7adc4 100644 --- a/packages/types/src/shared.ts +++ b/packages/types/src/shared.ts @@ -896,6 +896,7 @@ export type GatewayDispatchEventNames = | 'STAGE_INSTANCE_DELETE' | 'TYPING_START' | 'USER_UPDATE' + | 'VOICE_CHANNEL_EFFECT_SEND' | 'VOICE_STATE_UPDATE' | 'VOICE_SERVER_UPDATE' | 'WEBHOOKS_UPDATE' @@ -969,6 +970,7 @@ export enum GatewayIntents { GuildInvites = 1 << 6, /** * - VOICE_STATE_UPDATE + * - VOICE_CHANNEL_EFFECT_SEND */ GuildVoiceStates = 1 << 7, /**