If we get another .livestream command check if we're in a voice chat and disconnect and rejoin
This commit is contained in:
parent
3dc617b38b
commit
35f08b663a
|
@ -5,7 +5,7 @@ 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.me.voice;
|
const voiceState = message.guild.members.me.voice;
|
||||||
if (voiceState.channel) {
|
if (voiceState.channel) {
|
||||||
voiceState.disconnect();
|
voiceState.disconnect();
|
||||||
return message.channel.send('Livestream stopped.')
|
return message.channel.send('Livestream stopped.')
|
||||||
|
@ -30,6 +30,12 @@ module.exports = {
|
||||||
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
|
.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 {
|
try {
|
||||||
if (message.client.currentPlayer) {
|
if (message.client.currentPlayer) {
|
||||||
message.client.currentPlayer.stop();
|
message.client.currentPlayer.stop();
|
||||||
|
@ -59,10 +65,10 @@ module.exports = {
|
||||||
|
|
||||||
player.on('finish', () => {
|
player.on('finish', () => {
|
||||||
console.log('Media ended, replaying...');
|
console.log('Media ended, replaying...');
|
||||||
playStream();
|
playStream();
|
||||||
});
|
});
|
||||||
|
|
||||||
playStream();
|
playStream();
|
||||||
|
|
||||||
message.channel.send('Livestream started with the provided video link.')
|
message.channel.send('Livestream started with the provided video link.')
|
||||||
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
|
.then(msg => setTimeout(() => msg.delete().catch(console.error), deleteTimeout));
|
||||||
|
|
Loading…
Reference in New Issue