forked from embee/woomy
fixed music
This commit is contained in:
parent
6ee9122442
commit
98612a7784
3 changed files with 32 additions and 24 deletions
|
@ -24,11 +24,13 @@ exports.run = async (client, message) => {
|
||||||
if (guild.queue.length < 1 || !guild.playing || !guild.dispatcher) return message.channel.send('Nothing is playing.')
|
if (guild.queue.length < 1 || !guild.playing || !guild.dispatcher) return message.channel.send('Nothing is playing.')
|
||||||
if (!message.member.voice.channel) return message.channel.send('You need to be in voice channel to use this command!')
|
if (!message.member.voice.channel) return message.channel.send('You need to be in voice channel to use this command!')
|
||||||
|
|
||||||
|
guild.dispatcher.end('silent')
|
||||||
|
|
||||||
|
guild.queue = []
|
||||||
guild.playing = false
|
guild.playing = false
|
||||||
guild.paused = false
|
guild.paused = false
|
||||||
guild.queue = []
|
guild.dispatcher = null
|
||||||
|
guild.skippers = []
|
||||||
guild.dispatcher.end('silent')
|
|
||||||
|
|
||||||
message.channel.send('Playback stopped!')
|
message.channel.send('Playback stopped!')
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,33 +7,32 @@ module.exports = (client, oldState, newState) => {
|
||||||
const guild = music.getGuild(newState.guild.id)
|
const guild = music.getGuild(newState.guild.id)
|
||||||
|
|
||||||
if (guild.playing && guild.voiceChannel.id === oldState.channelID) {
|
if (guild.playing && guild.voiceChannel.id === oldState.channelID) {
|
||||||
if (guild.voiceChannel.members.size === 1) {
|
if (guild.voiceChannel.members.filter(member => !member.user.bot).size < 1) {
|
||||||
guild.autoDisconnect = true
|
guild.autoDisconnect = true
|
||||||
|
|
||||||
setTimeout(() => {
|
guild.message.channel.send(`The music will end in 2 minutes if nobody rejoins **${guild.voiceChannel.name}**`)
|
||||||
if (guild.voiceChannel.members.size === 1 && guild.autoDisconnect) {
|
.then(msg => {
|
||||||
setTimeout(() => {
|
msg.delete({ timeout: 120000 })
|
||||||
if (guild.voiceChannel.members.size === 1 && guild.autoDisconnect) {
|
})
|
||||||
setTimeout(() => {
|
|
||||||
if (guild.voiceChannel.members.size === 1 && guild.autoDisconnect) {
|
|
||||||
guild.playing = false
|
|
||||||
guild.queue = []
|
|
||||||
|
|
||||||
// Probably should be async? But no need here I think
|
setTimeout(() => {
|
||||||
guild.dispatcher.end('silent')
|
if (guild.dispatcher !== null && guild.voiceChannel.members.filter(member => !member.user.bot).size < 1 && guild.autoDisconnect) {
|
||||||
guild.message.channel.send('No one is listening to me. Leaving voice chat!')
|
// Probably should be async? But no need here I think
|
||||||
} else {
|
guild.dispatcher.end('silent')
|
||||||
guild.autoDisconnect = false
|
|
||||||
}
|
guild.queue = []
|
||||||
}, 30000)
|
guild.playing = false
|
||||||
} else {
|
guild.paused = false
|
||||||
guild.autoDisconnect = false
|
guild.dispatcher = null
|
||||||
}
|
guild.skippers = []
|
||||||
}, 20000)
|
|
||||||
|
guild.message.channel.send('The music has ended because no one was listening to me ;~;')
|
||||||
} else {
|
} else {
|
||||||
guild.autoDisconnect = false
|
guild.autoDisconnect = false
|
||||||
}
|
}
|
||||||
}, 10000)
|
}, 120000)
|
||||||
|
} else {
|
||||||
|
guild.autoDisconnect = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,11 @@ exports.play = async function (client, message, query, ignoreQueue) {
|
||||||
// Fix the bot if somehow broken
|
// Fix the bot if somehow broken
|
||||||
// music "playing", nothing in queue
|
// music "playing", nothing in queue
|
||||||
if ((guild.playing || guild.dispatcher) && guild.queue.length === 0) {
|
if ((guild.playing || guild.dispatcher) && guild.queue.length === 0) {
|
||||||
|
guild.queue = []
|
||||||
guild.playing = false
|
guild.playing = false
|
||||||
|
guild.paused = false
|
||||||
guild.dispatcher = null
|
guild.dispatcher = null
|
||||||
|
guild.skippers = []
|
||||||
// music not playing, something is in queue
|
// music not playing, something is in queue
|
||||||
} else if (!guild.playing && !guild.dispatcher && guild.queue.length > 0) {
|
} else if (!guild.playing && !guild.dispatcher && guild.queue.length > 0) {
|
||||||
guild.queue = []
|
guild.queue = []
|
||||||
|
@ -188,7 +191,11 @@ exports.play = async function (client, message, query, ignoreQueue) {
|
||||||
if (guild.queue.length > 0) {
|
if (guild.queue.length > 0) {
|
||||||
exports.play(client, message, null, true)
|
exports.play(client, message, null, true)
|
||||||
} else {
|
} else {
|
||||||
|
guild.queue = []
|
||||||
|
guild.playing = false
|
||||||
|
guild.paused = false
|
||||||
guild.dispatcher = null
|
guild.dispatcher = null
|
||||||
|
guild.skippers = []
|
||||||
|
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue