feat: emit voiceServerUpdate event (#11414)

* feat: emit voiceServerUpdate event

* fix: add back debug log

* refactor: censor token in debug logs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2026-07-14 21:18:26 +01:00
committed by Jiralite
co-authored by kodiakhq[bot]
parent b0e6aff856
commit 74a42bfd10
4 changed files with 43 additions and 4 deletions
@@ -25,7 +25,7 @@ class VoiceStateUpdate extends Action {
// Emit event
if (member?.user.id === client.user.id) {
client.emit('debug', `[VOICE] received voice state update: ${JSON.stringify(data)}`);
client.emit(Events.Debug, `[VOICE] received voice state update: ${JSON.stringify(data)}`);
client.voice.onVoiceStateUpdate(data);
}
@@ -1,6 +1,33 @@
'use strict';
module.exports = (client, packet) => {
client.emit('debug', `[VOICE] received voice server: ${JSON.stringify(packet)}`);
client.voice.onVoiceServer(packet.d);
const Events = require('../../../util/Events');
module.exports = (client, { d: data }) => {
client.emit(
Events.Debug,
`[VOICE] received voice server: ${JSON.stringify({ ...data, token: '*'.repeat(data.token.length) })}`,
);
client.voice.onVoiceServer(data);
/**
* Represents the properties of a voice server update
*
* @typedef {Object} VoiceServerUpdateData
* @property {Snowflake} guildId The id of the guild this voice server update is for
* @property {?string} endpoint The voice server host
* @property {string} token The voice connection token
*/
/**
* Emitted whenever a voice server is updated.
*
* @event Client#voiceServerUpdate
* @param {VoiceServerUpdateData} data The voice server update data
*/
client.emit(Events.VoiceServerUpdate, {
guildId: data.guild_id,
endpoint: data.endpoint,
token: data.token,
});
};
+7
View File
@@ -6073,6 +6073,12 @@ export type OmitPartialGroupDMChannel<Structure extends { channel: Channel }> =
channel: Exclude<Structure['channel'], PartialGroupDMChannel>;
};
export interface VoiceServerUpdateData {
endpoint: string | null;
guildId: Snowflake;
token: string;
}
export interface ClientEvents {
applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData];
autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution];
@@ -6170,6 +6176,7 @@ export interface ClientEvents {
typingStart: [typing: Typing];
userUpdate: [oldUser: User | PartialUser, newUser: User];
voiceChannelEffectSend: [voiceChannelEffect: VoiceChannelEffect];
voiceServerUpdate: [data: VoiceServerUpdateData];
voiceStateUpdate: [oldState: VoiceState, newState: VoiceState];
/** @deprecated Use {@link ClientEvents.webhooksUpdate} instead. */
webhookUpdate: ClientEvents['webhooksUpdate'];
@@ -202,6 +202,7 @@ import {
Entitlement,
SKU,
UserSelectMenuBuilder,
VoiceServerUpdateData,
RoleSelectMenuBuilder,
ChannelSelectMenuBuilder,
MentionableSelectMenuBuilder,
@@ -1357,6 +1358,10 @@ client.on('userUpdate', ({ client: oldClient }, { client: newClient }) => {
expectType<Client<true>>(newClient);
});
client.on('voiceServerUpdate', data => {
expectType<VoiceServerUpdateData>(data);
});
client.on('voiceStateUpdate', ({ client: oldClient }, { client: newClient }) => {
expectType<Client<true>>(oldClient);
expectType<Client<true>>(newClient);