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-02-08 16:48:49 +00:00
committed by GitHub
parent c460a920ac
commit a3e189df00
4 changed files with 43 additions and 4 deletions

View File

@@ -1,6 +1,33 @@
'use strict'; 'use strict';
module.exports = (client, packet) => { const { Events } = require('../../../util/Events.js');
client.emit('debug', `[VOICE] received voice server: ${JSON.stringify(packet)}`);
client.voice.onVoiceServer(packet.d); 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,
});
}; };

View File

@@ -23,7 +23,7 @@ module.exports = (client, { d: data }) => {
// Emit event // Emit event
if (member?.user.id === client.user.id) { 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); client.voice.onVoiceStateUpdate(data);
} }

View File

@@ -5458,6 +5458,12 @@ export type OmitPartialGroupDMChannel<Structure extends { channel: Channel }> =
channel: Exclude<Structure['channel'], PartialGroupDMChannel>; channel: Exclude<Structure['channel'], PartialGroupDMChannel>;
}; };
export interface VoiceServerUpdateData {
endpoint: string | null;
guildId: Snowflake;
token: string;
}
export interface ClientEventTypes { export interface ClientEventTypes {
applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData]; applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData];
autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution]; autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution];
@@ -5571,6 +5577,7 @@ export interface ClientEventTypes {
typingStart: [typing: Typing]; typingStart: [typing: Typing];
userUpdate: [oldUser: PartialUser | User, newUser: User]; userUpdate: [oldUser: PartialUser | User, newUser: User];
voiceChannelEffectSend: [voiceChannelEffect: VoiceChannelEffect]; voiceChannelEffectSend: [voiceChannelEffect: VoiceChannelEffect];
voiceServerUpdate: [data: VoiceServerUpdateData];
voiceStateUpdate: [oldState: VoiceState, newState: VoiceState]; voiceStateUpdate: [oldState: VoiceState, newState: VoiceState];
warn: [message: string]; warn: [message: string];
webhooksUpdate: [channel: AnnouncementChannel | ForumChannel | MediaChannel | TextChannel | VoiceChannel]; webhooksUpdate: [channel: AnnouncementChannel | ForumChannel | MediaChannel | TextChannel | VoiceChannel];

View File

@@ -202,6 +202,7 @@ import type {
Invite, Invite,
GuildInvite, GuildInvite,
AuthorizingIntegrationOwners, AuthorizingIntegrationOwners,
VoiceServerUpdateData,
} from './index.js'; } from './index.js';
import { import {
ActionRowBuilder, ActionRowBuilder,
@@ -1379,6 +1380,10 @@ client.on('userUpdate', ({ client: oldClient }, { client: newClient }) => {
expectType<Client<true>>(newClient); expectType<Client<true>>(newClient);
}); });
client.on('voiceServerUpdate', data => {
expectType<VoiceServerUpdateData>(data);
});
client.on('voiceStateUpdate', ({ client: oldClient }, { client: newClient }) => { client.on('voiceStateUpdate', ({ client: oldClient }, { client: newClient }) => {
expectType<Client<true>>(oldClient); expectType<Client<true>>(oldClient);
expectType<Client<true>>(newClient); expectType<Client<true>>(newClient);