From 29dd319b6818329ed91df7c6380dfdb0fa354548 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Thu, 23 Sep 2021 12:46:55 +0100 Subject: [PATCH] refactor(VoiceState): use manager edit method to remove error (#6631) --- src/errors/Messages.js | 1 - src/structures/VoiceState.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/errors/Messages.js b/src/errors/Messages.js index f99dd2d97724..12eef8a5e1eb 100644 --- a/src/errors/Messages.js +++ b/src/errors/Messages.js @@ -64,7 +64,6 @@ const Messages = { VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.', - VOICE_STATE_UNCACHED_MEMBER: 'The member of this voice state is uncached.', VOICE_STATE_NOT_OWN: 'You cannot self-deafen/mute/request to speak on VoiceStates that do not belong to the ClientUser.', VOICE_STATE_INVALID_TYPE: name => `${name} must be a boolean.`, diff --git a/src/structures/VoiceState.js b/src/structures/VoiceState.js index a38d8beb99e4..155e0b459da1 100644 --- a/src/structures/VoiceState.js +++ b/src/structures/VoiceState.js @@ -125,7 +125,7 @@ class VoiceState extends Base { * @returns {Promise} */ setMute(mute = true, reason) { - return this.member?.edit({ mute }, reason) ?? Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER')); + return this.guild.members.edit(this.id, { mute }, reason); } /** @@ -135,7 +135,7 @@ class VoiceState extends Base { * @returns {Promise} */ setDeaf(deaf = true, reason) { - return this.member?.edit({ deaf }, reason) ?? Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER')); + return this.guild.members.edit(this.id, { deaf }, reason); } /** @@ -155,7 +155,7 @@ class VoiceState extends Base { * @returns {Promise} */ setChannel(channel, reason) { - return this.member?.edit({ channel }, reason) ?? Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER')); + return this.guild.members.edit(this.id, { channel }, reason); } /**