From aba72cac111ba4748018ba143c3cfdee61a5d208 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 4 Sep 2020 13:52:25 +0200 Subject: [PATCH] Don't use tmpdir as it apparently doesn't like that Signed-off-by: loicbersier --- commands/fun/tts/dectalk.js | 37 ++++++++++++++--------------------- commands/fun/tts/dectalkvc.js | 7 +++---- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/commands/fun/tts/dectalk.js b/commands/fun/tts/dectalk.js index d0ad28b2..373e02f1 100644 --- a/commands/fun/tts/dectalk.js +++ b/commands/fun/tts/dectalk.js @@ -1,6 +1,5 @@ const { Command } = require('discord-akairo'); const { execFile } = require('child_process'); -const os = require('os'); const rand = require('../../../rand.js'); class dectalkCommand extends Command { @@ -29,37 +28,31 @@ class dectalkCommand extends Command { async exec(message, args) { args.decMessage = rand.random(args.decMessage, message); - let output = `${os.tmpdir()}/${message.id}_dectalk.wav`; + let output = `${message.id}_dectalk.wav`; let decMessage = '[:phoneme on]' + args.decMessage; let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); if (process.platform === 'win32') { execFile('say.exe', ['-w', output, `${decMessage}`], {cwd: './dectalk/'}, (error, stdout, stderr) => { - if (error) { - loadingmsg.delete(); - console.error(stdout); - console.error(stderr); - console.error(error); - return message.channel.send('Oh no! an error has occurred!'); - } - - loadingmsg.delete(); - return message.channel.send({files: [output]}); + sendMessage(output, error, stdout, stderr); }); } else if (process.platform === 'linux' || process.platform === 'darwin') { execFile('wine', ['say.exe', '-w', output, `${decMessage}`], {cwd: './dectalk/'}, (error, stdout, stderr) => { - if (error) { - loadingmsg.delete(); - console.error(stdout); - console.error(stderr); - console.error(error); - return message.channel.send('Oh no! an error has occurred!'); - } - - loadingmsg.delete(); - return message.channel.send({files: [output]}); + sendMessage(`./dectalk/${output}`, error, stdout, stderr); }); } + + async function sendMessage(file, error, stdout, stderr) { + console.error(stdout); + loadingmsg.delete(); + if (error) { + console.error(stderr); + console.error(error); + return message.channel.send('Oh no! an error has occurred!'); + } + + return message.channel.send({files: [file]}); + } } } diff --git a/commands/fun/tts/dectalkvc.js b/commands/fun/tts/dectalkvc.js index 9218fbc8..3fac64b2 100644 --- a/commands/fun/tts/dectalkvc.js +++ b/commands/fun/tts/dectalkvc.js @@ -1,6 +1,5 @@ const { Command } = require('discord-akairo'); const { execFile } = require('child_process'); -const os = require('os'); const rand = require('../../../rand.js'); class dectalkvcCommand extends Command { @@ -29,7 +28,7 @@ class dectalkvcCommand extends Command { async exec(message, args) { args.decMessage = rand.random(args.decMessage, message); - let output = `${os.tmpdir()}/${message.id}_dectalk.wav`; + let output = `${message.id}_dectalk.wav`; let decMessage = '[:phoneme on] ' + args.decMessage; let loadingmsg = await message.channel.send('Processing ( this can take some time ) '); @@ -44,7 +43,7 @@ class dectalkvcCommand extends Command { } loadingmsg.delete(); - playinVC(output); + playinVC(`./dectalk/${output}`); }); } else if (process.platform === 'linux' || process.platform === 'darwin') { @@ -58,7 +57,7 @@ class dectalkvcCommand extends Command { } loadingmsg.delete(); - playinVC(output); + playinVC(`./dectalk/${output}`); }); }