Added a voiceSpeaking event, fired when a user in a voiceChannel starts or stops speaking. (#452)

* Added an event for the voice speaking packet.

* Updated the docs to reflect the voiceSpeaking event addition.

* Fixed some spacing issues in the VoiceConnection.js file.

* Moved the speaking boolean to the User object.
This commit is contained in:
Jesse Bryan
2016-07-11 14:12:27 -05:00
committed by abal
parent 620d8cbf15
commit 7ae7a9aa34
6 changed files with 62 additions and 15 deletions

View File

@@ -40,6 +40,7 @@ var User = (function (_Equality) {
this.note = data.note || null;
this.voiceChannel = null;
this.voiceState = {};
this.speaking = false;
}
User.prototype.mention = function mention() {

View File

@@ -447,6 +447,24 @@ var VoiceConnection = (function (_EventEmitter) {
self.mode = data.d.mode;
self.emit("ready", self);
break;
case 5:
var user = self.server.members.get("id", data.d.user_id);
if (user) {
var speaking = data.d.speaking;
var channel = user.voiceChannel;
if (channel) {
user.speaking = speaking;
self.client.emit("voiceSpeaking", channel, user);
} else {
self.client.emit("warn", "channel doesn't exist even though SPEAKING expects them to");
}
} else {
self.client.emit("warn", "user doesn't exist even though SPEAKING expects them to");
}
break;
}
});