forked from embee/woomy
Merge branch 'next' of https://github.com/mudkipscience/woomy into next
This commit is contained in:
commit
da617ce62b
2 changed files with 38 additions and 0 deletions
37
events/voiceStateUpdate.js
Normal file
37
events/voiceStateUpdate.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license.
|
||||
|
||||
const music = require('../utils/music');
|
||||
|
||||
module.exports = (client, oldState, newState) => {
|
||||
if(newState.channelID != oldState.channelID) {
|
||||
let guild = music.getGuild(newState.guild.id);
|
||||
|
||||
if(guild.playing && guild.voiceChannel.id == oldState.channelID) {
|
||||
if(guild.voiceChannel.members.size == 1) {
|
||||
guild.autoDisconnect = true;
|
||||
|
||||
setTimeout(() => {
|
||||
if(guild.voiceChannel.members.size == 1 && guild.autoDisconnect) {
|
||||
setTimeout(() => {
|
||||
if(guild.voiceChannel.members.size == 1 && guild.autoDisconnect) {
|
||||
setTimeout(() => {
|
||||
if(guild.voiceChannel.members.size == 1 && guild.autoDisconnect) {
|
||||
// Probably should be async? But no need here I think
|
||||
guild.dispatcher.end('silent');
|
||||
guild.message.channel.send('No one is listening to me. Leaving voice chat!');
|
||||
} else {
|
||||
guild.autoDisconnect = false;
|
||||
};
|
||||
}, 30000);
|
||||
} else {
|
||||
guild.autoDisconnect = false;
|
||||
};
|
||||
}, 20000);
|
||||
} else {
|
||||
guild.autoDisconnect = false;
|
||||
};
|
||||
}, 10000);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
|
@ -66,6 +66,7 @@ exports.getVideoByQuery = async function (client, query) {
|
|||
|
||||
exports.play = async function (client, message, query, ignoreQueue) {
|
||||
const guild = exports.getGuild(message.guild.id)
|
||||
guild.message = message;
|
||||
|
||||
if (!message.member.voice.channel && !guild.voiceChannel) {
|
||||
return message.reply('You have to be connected to a voice channel to use this command!')
|
||||
|
|
Loading…
Reference in a new issue