Skip to content

Commit

Permalink
Check voice connection channelID before disconnecting
Browse files Browse the repository at this point in the history
  • Loading branch information
abalabahaha committed May 26, 2017
1 parent 80b4c78 commit ae77d2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/Client.js
Expand Up @@ -252,6 +252,9 @@ class Client extends EventEmitter {
* @arg {String} channelID The ID of the voice channel
*/
leaveVoiceChannel(channelID) {
if(!channelID) {
return;
}
var channel = this.getChannel(channelID);
if(!channel) {
return;
Expand Down
6 changes: 5 additions & 1 deletion lib/gateway/Shard.js
Expand Up @@ -688,7 +688,11 @@ class Shard extends EventEmitter {
case "GUILD_DELETE": {
var voiceConnection = this.client.voiceConnections.get(packet.d.id);
if(voiceConnection) {
this.client.leaveVoiceChannel(voiceConnection.channelID);
if(voiceConnection.channelID) {
this.client.leaveVoiceChannel(voiceConnection.channelID);
} else {
this.client.voiceConnections.leave(packet.d.id);
}
}

delete this.client.guildShardMap[packet.d.id];
Expand Down

0 comments on commit ae77d2c

Please sign in to comment.