From bee00ef40ef903be89763cb5f3abda6f5f645bbe Mon Sep 17 00:00:00 2001 From: Supositware Date: Fri, 18 Jan 2019 22:18:20 +0100 Subject: [PATCH] test --- commands/general/ttsvc.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/commands/general/ttsvc.js b/commands/general/ttsvc.js index 161c9a8..e363d39 100644 --- a/commands/general/ttsvc.js +++ b/commands/general/ttsvc.js @@ -56,19 +56,12 @@ class TtsvcCommand extends Command { // If not in voice channel ask user to join if (message.member.voice.channel) { - const voiceChannel = message.member.voice.channel.join(); - if (text == 'stop') { - voiceChannel.leave(); - message.channel.send('I leaved the channel'); - } else { // you should be careful in what is included in your scopes, you didn't use the {} - voiceChannel.join().then(connection => { - const dispatcher = connection.playStream('./ttsvc.mp3'); - // End at then end of the audio stream - dispatcher.on('end', () => setTimeout(function () { - voiceChannel.leave(); - }, 2000)); - }); - } + const connection = message.member.voice.channel.join(); + const dispatcher = connection.play('./ttsvc'); + + dispatcher.on('finish', () => { + connection.leave(); + }); } else { message.reply('You need to join a voice channel first!'); }