mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 08:03:30 +01:00
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:
@@ -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.js');
|
||||
|
||||
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,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ module.exports = (client, { d: data }) => {
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
7
packages/discord.js/typings/index.d.ts
vendored
7
packages/discord.js/typings/index.d.ts
vendored
@@ -5458,6 +5458,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 ClientEventTypes {
|
||||
applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData];
|
||||
autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution];
|
||||
@@ -5571,6 +5577,7 @@ export interface ClientEventTypes {
|
||||
typingStart: [typing: Typing];
|
||||
userUpdate: [oldUser: PartialUser | User, newUser: User];
|
||||
voiceChannelEffectSend: [voiceChannelEffect: VoiceChannelEffect];
|
||||
voiceServerUpdate: [data: VoiceServerUpdateData];
|
||||
voiceStateUpdate: [oldState: VoiceState, newState: VoiceState];
|
||||
warn: [message: string];
|
||||
webhooksUpdate: [channel: AnnouncementChannel | ForumChannel | MediaChannel | TextChannel | VoiceChannel];
|
||||
|
||||
@@ -202,6 +202,7 @@ import type {
|
||||
Invite,
|
||||
GuildInvite,
|
||||
AuthorizingIntegrationOwners,
|
||||
VoiceServerUpdateData,
|
||||
} from './index.js';
|
||||
import {
|
||||
ActionRowBuilder,
|
||||
@@ -1379,6 +1380,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);
|
||||
|
||||
Reference in New Issue
Block a user