feat: voice channel effect send event (#250)

This commit is contained in:
Marcos Susaña 2024-08-21 18:05:21 -04:00 committed by GitHub
parent 753a70f94c
commit 0bc8a6789c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 65 additions and 2 deletions

View File

@ -1,4 +1,8 @@
import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from '../../types';
import type {
GatewayVoiceChannelEffectSendDispachData,
GatewayVoiceServerUpdateDispatchData,
GatewayVoiceStateUpdateDispatchData,
} from '../../types';
import { toCamelCase } from '../../common';
import type { UsingClient } from '../../commands';
import { Transformers, type VoiceStateStructure } from '../../client/transformers';
@ -14,3 +18,7 @@ export const VOICE_STATE_UPDATE = async (
if (!data.guild_id) return [Transformers.VoiceState(self, data)];
return [Transformers.VoiceState(self, data), await self.cache.voiceStates?.get(data.user_id, data.guild_id)];
};
export const VOICE_CHANNEL_EFFECT_SEND = (_self: UsingClient, data: GatewayVoiceChannelEffectSendDispachData) => {
return toCamelCase(data);
};

View File

@ -32,9 +32,10 @@ import type {
AutoModerationRuleTriggerType,
APIAuditLogEntry,
APIEntitlement,
APIPartialEmoji,
} from './payloads/index';
import type { ReactionType } from './rest/index';
import type { Nullable } from './utils';
import type { AnimationTypes, Nullable } from './utils';
/**
* https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-query-string-params
@ -1496,6 +1497,47 @@ export type GatewayUserUpdateDispatch = DataPayload<GatewayDispatchEvents.UserUp
*/
export type GatewayUserUpdateDispatchData = APIUser;
/**
* https://discord.com/developers/docs/topics/gateway-events#voice-channel-effect-send
*/
export type GatewayVoiceChannelEffectSendDispach = DataPayload<
GatewayDispatchEvents.VoiceChannelEffectSend,
GatewayVoiceChannelEffectSendDispachData
>;
/**
* https://discord.com/developers/docs/topics/gateway-events#voice-channel-effect-send-voice-channel-effect-send-event-fields
*/
export type GatewayVoiceChannelEffectSendDispachData =
| GatewayVoiceChannelEffectSendSoundboard
| GatewayVoiceChannelEffectSendReaction;
export type _GatewayVoiceChannelEffectSendDispachData = {
/** 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?: APIPartialEmoji | null;
/** The type of emoji animation, for emoji reaction and soundboard effects */
animation_type?: AnimationTypes | null;
/** The ID of the emoji animation, for emoji reaction and soundboard effects */
animation_id?: number;
/** 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;
};
export type GatewayVoiceChannelEffectSendReaction = Omit<
_GatewayVoiceChannelEffectSendDispachData,
'sound_id' | 'sound_volume'
>;
export type GatewayVoiceChannelEffectSendSoundboard = _GatewayVoiceChannelEffectSendDispachData;
/**
* https://discord.com/developers/docs/topics/gateway-events#voice-state-update
*/

View File

@ -367,6 +367,7 @@ export enum GatewayDispatchEvents {
ThreadUpdate = 'THREAD_UPDATE',
TypingStart = 'TYPING_START',
UserUpdate = 'USER_UPDATE',
VoiceChannelEffectSend = 'VOICE_CHANNEL_EFFECT_SEND',
VoiceServerUpdate = 'VOICE_SERVER_UPDATE',
VoiceStateUpdate = 'VOICE_STATE_UPDATE',
WebhooksUpdate = 'WEBHOOKS_UPDATE',
@ -835,3 +836,13 @@ export enum OverwriteType {
Role,
Member,
}
/**
* https://discord.com/developers/docs/topics/gateway-events#voice-channel-effect-send-animation-types
*/
export enum AnimationTypes {
/** A fun animation, sent by a Nitro subscriber */
PREMIUM = 0,
/** The standard animation */
BASIC,
}

View File

@ -58,6 +58,7 @@ import type {
APIChannel,
APIAutoModerationRule,
APIEntitlement,
GatewayVoiceChannelEffectSendDispachData,
} from '../types';
import { GatewayDispatchEvents } from '../types';
@ -141,6 +142,7 @@ export interface Events {
[GatewayDispatchEvents.PresenceUpdate]: GatewayPresenceUpdateDispatchData;
[GatewayDispatchEvents.TypingStart]: GatewayTypingStartDispatchData;
[GatewayDispatchEvents.UserUpdate]: GatewayUserUpdateDispatchData;
[GatewayDispatchEvents.VoiceChannelEffectSend]: GatewayVoiceChannelEffectSendDispachData;
[GatewayDispatchEvents.VoiceStateUpdate]: GatewayVoiceStateUpdateData;
[GatewayDispatchEvents.VoiceServerUpdate]: GatewayVoiceServerUpdateDispatchData;
[GatewayDispatchEvents.WebhooksUpdate]: GatewayWebhooksUpdateDispatchData;