From a4f2532700f6e5e930bcab9877cd8fd9c61eaefe Mon Sep 17 00:00:00 2001 From: Supositware Date: Fri, 18 Jan 2019 22:24:11 +0100 Subject: [PATCH] please work --- commands/general/ttsvc.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/commands/general/ttsvc.js b/commands/general/ttsvc.js index e363d39..91d8a6f 100644 --- a/commands/general/ttsvc.js +++ b/commands/general/ttsvc.js @@ -44,7 +44,7 @@ class TtsvcCommand extends Command { } // Write the binary audio content to a local file - fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', err => { + fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', async err => { if (err) { console.error('ERROR:', err); message.channel.send('An error has occured, the message is probably too long'); @@ -53,15 +53,10 @@ class TtsvcCommand extends Command { } console.log('Audio content written to file: ttsvc.mp3'); - // If not in voice channel ask user to join if (message.member.voice.channel) { - const connection = message.member.voice.channel.join(); - const dispatcher = connection.play('./ttsvc'); - - dispatcher.on('finish', () => { - connection.leave(); - }); + const connection = await message.member.voice.channel.join(); + connection.play('./ttsvc'); } else { message.reply('You need to join a voice channel first!'); }