mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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';
|
'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,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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>;
|
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];
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user