feat(VoiceState): self mute/deaf methods (#3243)

* Implemented setSelfMute/Deaf, done typings, fixed bug in VoiceState with errors.

* Completed requested changes

* return send in sendVoiceStateUpdate so its a promise, update typings

* Updated methods to return a boolean

* Requested changes

* Fix bug

* Update src/structures/VoiceState.js

Co-Authored-By: MrJacz <23615291+MrJacz@users.noreply.github.com>

* fix
This commit is contained in:
Jacz
2019-05-04 01:11:11 +10:00
committed by SpaceEEC
parent a59968f7de
commit 692494dc04
4 changed files with 40 additions and 5 deletions

View File

@@ -177,20 +177,21 @@ class VoiceConnection extends EventEmitter {
/**
* Sends a request to the main gateway to join a voice channel.
* @param {Object} [options] The options to provide
* @returns {Promise<Shard>}
* @private
*/
sendVoiceStateUpdate(options = {}) {
options = Util.mergeDefault({
guild_id: this.channel.guild.id,
channel_id: this.channel.id,
self_mute: false,
self_deaf: false,
self_mute: this.voice ? this.voice.selfMute : false,
self_deaf: this.voice ? this.voice.selfDeaf : false,
}, options);
const queueLength = this.channel.guild.shard.ratelimit.queue.length;
this.emit('debug', `Sending voice state update (queue length is ${queueLength}): ${JSON.stringify(options)}`);
this.channel.guild.shard.send({
return this.channel.guild.shard.send({
op: OPCodes.VOICE_STATE_UPDATE,
d: options,
});