mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
The beginnings of the voiceUserStateChange event
This commit is contained in:
@@ -1703,16 +1703,31 @@ var InternalClient = (function () {
|
||||
if (user && server) {
|
||||
|
||||
if (data.channel_id) {
|
||||
// speaking
|
||||
// in voice channel
|
||||
var channel = self.channels.get("id", data.channel_id);
|
||||
if (channel) {
|
||||
if (server.eventStartSpeaking(user, channel)) client.emit("voiceJoin", user, channel);else client.emit("warn", "voice state error occurred in adding");
|
||||
if (channel && channel.type === "voice") {
|
||||
var oldState = {
|
||||
mute: user.voiceState.mute,
|
||||
self_mute: user.voiceState.self_mute,
|
||||
deaf: user.voiceState.deaf,
|
||||
self_deaf: user.voiceState.self_deaf
|
||||
};
|
||||
user.voiceState.mute = data.mute;
|
||||
user.voiceState.self_mute = data.self_mute;
|
||||
user.voiceState.deaf = data.deaf;
|
||||
user.voiceState.self_deaf = data.self_deaf;
|
||||
if ((oldState.mute != user.voiceState.mute || oldState.self_mute != user.voiceState.self_mute || oldState.deaf != user.voiceState.deaf || oldState.self_deaf != user.voiceState.self_deaf) && oldState.mute !== undefined) {
|
||||
client.emit("voiceUserStateChange", user, oldState);
|
||||
} else {
|
||||
server.eventVoiceJoin(user, channel);
|
||||
client.emit("voiceJoin", user, channel);
|
||||
}
|
||||
} else {
|
||||
client.emit("warn", "voice state channel not in cache");
|
||||
}
|
||||
} else {
|
||||
// not speaking
|
||||
client.emit("voiceLeave", user, server.eventStopSpeaking(user));
|
||||
// not in voice channel
|
||||
client.emit("voiceLeave", user, server.eventVoiceLeave(user));
|
||||
}
|
||||
} else {
|
||||
client.emit("warn", "voice state update but user or server not in cache");
|
||||
|
||||
Reference in New Issue
Block a user