Change livestream logic

This commit is contained in:
Wizzard 2024-02-06 00:17:15 -05:00
parent 5eec305e91
commit 2becc40819
1 changed files with 12 additions and 7 deletions

View File

@ -5,14 +5,19 @@ 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.members.me.voice;
if (voiceState.channel) {
voiceState.disconnect();
return message.channel.send('Livestream stopped.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
if (message.client.voiceConnection) {
message.client.voiceConnection.disconnect();
message.client.voiceConnection = null;
if (message.client.currentPlayer) {
message.client.currentPlayer.stop();
message.client.currentPlayer.removeAllListeners('end');
message.client.currentPlayer = null;
}
return message.channel.send('Livestream stopped.').then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
} else {
return message.channel.send('No active livestream to stop.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
return message.channel.send('No active livestream to stop.').then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
}
}