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.', description: 'Starts or stops a live stream in a voice channel with a provided video link.',
async execute(message, args, deleteTimeout) { async execute(message, args, deleteTimeout) {
if (args[0] === 'stop') { if (args[0] === 'stop') {
const voiceState = message.guild.members.me.voice; if (message.client.voiceConnection) {
if (voiceState.channel) { message.client.voiceConnection.disconnect();
voiceState.disconnect(); message.client.voiceConnection = null;
return message.channel.send('Livestream stopped.')
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout)); 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 { } else {
return message.channel.send('No active livestream to stop.') return message.channel.send('No active livestream to stop.').then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
} }
} }