From 16076124b2687ebb9cde40ec8585fca4c6588869 Mon Sep 17 00:00:00 2001 From: Lewdcario Date: Sun, 14 Oct 2018 13:58:34 -0500 Subject: [PATCH] fix(Client#voiceStateUpdate): newState is guaranteed --- src/client/websocket/packets/handlers/VoiceStateUpdate.js | 7 +++---- typings/index.d.ts | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client/websocket/packets/handlers/VoiceStateUpdate.js b/src/client/websocket/packets/handlers/VoiceStateUpdate.js index d6cc08aee..e423d0d0b 100644 --- a/src/client/websocket/packets/handlers/VoiceStateUpdate.js +++ b/src/client/websocket/packets/handlers/VoiceStateUpdate.js @@ -29,9 +29,8 @@ class VoiceStateUpdateHandler extends AbstractHandler { if (member && member.user.id === client.user.id && data.channel_id) { client.emit('self.voiceStateUpdate', data); } - if (oldState || newState) { - client.emit(Events.VOICE_STATE_UPDATE, oldState, newState); - } + + client.emit(Events.VOICE_STATE_UPDATE, oldState, newState); } } } @@ -40,7 +39,7 @@ class VoiceStateUpdateHandler extends AbstractHandler { * Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes. * @event Client#voiceStateUpdate * @param {?VoiceState} oldState The voice state before the update - * @param {?VoiceState} newState The voice state after the update + * @param {VoiceState} newState The voice state after the update */ module.exports = VoiceStateUpdateHandler; diff --git a/typings/index.d.ts b/typings/index.d.ts index 23e015062..70ff34b39 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -195,7 +195,7 @@ declare module 'discord.js' { public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; public on(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this; public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this; - public on(event: 'voiceStateUpdate', listener: (oldState?: VoiceState, newState?: VoiceState) => void): this; + public on(event: 'voiceStateUpdate', listener: (oldState: VoiceState | undefined, newState: VoiceState) => void): this; public on(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; public on(event: string, listener: Function): this; @@ -227,7 +227,7 @@ declare module 'discord.js' { public once(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; public once(event: 'typingStart' | 'typingStop', listener: (channel: Channel, user: User) => void): this; public once(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this; - public once(event: 'voiceStateUpdate', listener: (oldState?: VoiceState, newState?: VoiceState) => void): this; + public once(event: 'voiceStateUpdate', listener: (oldState: VoiceState | undefined, newState: VoiceState) => void): this; public once(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; public once(event: string, listener: Function): this; }