From 1a0ee2091dd8ce3e3ee9d14b6c729f1617d81d85 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 26 Oct 2019 00:01:17 +0200 Subject: [PATCH] Add loading message when its run on linux --- commands/fun/tts/dectalk.js | 10 ++++++++-- commands/fun/tts/dectalkvc.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/commands/fun/tts/dectalk.js b/commands/fun/tts/dectalk.js index 85a7ebe3..291b83e1 100644 --- a/commands/fun/tts/dectalk.js +++ b/commands/fun/tts/dectalk.js @@ -34,17 +34,23 @@ class dectalkCommand extends Command { if (process.platform == 'win32') { exec(`cd .\\dectalk && .\\say.exe -w dectalk.wav "${decMessage}"`) .catch(err => { - return console.error(err); + console.error(err); + return message.channel.send('Oh no! an error has occured!'); }) .then(() => { return message.channel.send({files: ['./dectalk/dectalk.wav']}); }); } else if (process.platform == 'linux' || process.platform == 'darwin') { + let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); + exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalk.wav "${decMessage}"`) .catch(err => { - return console.error(err); + loadingmsg.delete(); + console.error(err); + return message.channel.send('Oh no! an error has occured!'); }) .then(() => { + loadingmsg.delete(); return message.channel.send({files: ['./dectalk/dectalk.wav']}); }); } diff --git a/commands/fun/tts/dectalkvc.js b/commands/fun/tts/dectalkvc.js index 89726e3e..2bad3b95 100644 --- a/commands/fun/tts/dectalkvc.js +++ b/commands/fun/tts/dectalkvc.js @@ -34,7 +34,8 @@ class dectalkvcCommand extends Command { if (process.platform == 'win32') { exec(`cd .\\dectalk && .\\say.exe -w dectalkvc.wav "${decMessage}"`) .catch(err => { - return console.error(err); + console.error(err); + return message.channel.send('Oh no! an error has occured!'); }) .then(async () => { const voiceChannel = message.member.voice.channel; @@ -52,14 +53,19 @@ class dectalkvcCommand extends Command { }); } else if (process.platform == 'linux' || process.platform == 'darwin') { + let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); + exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalkvc.wav "${decMessage}"`) .catch(err => { - return console.error(err); + loadingmsg.delete(); + console.error(err); + return message.channel.send('Oh no! an error has occured!'); }) .then(async () => { const voiceChannel = message.member.voice.channel; if (!voiceChannel) return message.say('Please enter a voice channel first.'); try { + loadingmsg.delete(); const connection = await voiceChannel.join(); const dispatcher = connection.play('./dectalk/dectalkvc.wav'); dispatcher.once('finish', () => voiceChannel.leave()); @@ -67,6 +73,7 @@ class dectalkvcCommand extends Command { return null; } catch (err) { voiceChannel.leave(); + loadingmsg.delete(); return message.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } });