If we get another .livestream command check if we're in a voice chat and disconnect and rejoin

This commit is contained in:
Wizzard 2024-02-05 23:42:20 -05:00
parent 3dc617b38b
commit 35f08b663a
1 changed files with 9 additions and 3 deletions

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Starts or stops a live stream in a voice channel with a provided video link.',
async execute(message, args, deleteTimeout) {
if (args[0] === 'stop') {
const voiceState = message.guild.me.voice;
const voiceState = message.guild.members.me.voice;
if (voiceState.channel) {
voiceState.disconnect();
return message.channel.send('Livestream stopped.')
@ -30,6 +30,12 @@ module.exports = {
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
}
const voiceState = message.guild.members.me.voice;
if (voiceState.channel) {
console.log('Already in a voice channel, leaving...');
await voiceState.disconnect();
}
try {
if (message.client.currentPlayer) {
message.client.currentPlayer.stop();