Skip to content

Commit

Permalink
refactor(VoiceState): use manager edit method to remove error (#6631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImRodry committed Sep 23, 2021
1 parent 124e177 commit 29dd319
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/errors/Messages.js
Expand Up @@ -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.`,
Expand Down
6 changes: 3 additions & 3 deletions src/structures/VoiceState.js
Expand Up @@ -125,7 +125,7 @@ class VoiceState extends Base {
* @returns {Promise<GuildMember>}
*/
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);
}

/**
Expand All @@ -135,7 +135,7 @@ class VoiceState extends Base {
* @returns {Promise<GuildMember>}
*/
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);
}

/**
Expand All @@ -155,7 +155,7 @@ class VoiceState extends Base {
* @returns {Promise<GuildMember>}
*/
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);
}

/**
Expand Down

0 comments on commit 29dd319

Please sign in to comment.