forked from Supositware/Haha-Yes
Don't output to tmpdir
This commit is contained in:
parent
17f2a38e8d
commit
772c3b038b
2 changed files with 8 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
const os = require('os');
|
||||
const rand = require('../../../rand.js');
|
||||
|
||||
class dectalkCommand extends Command {
|
||||
|
@ -29,24 +28,23 @@ class dectalkCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message, args) {
|
||||
let output = `${os.tmpdir()}/${message.id}_dectalk.wav`;
|
||||
args.decMessage = rand.random(args.decMessage, message);
|
||||
args.decMessage = args.decMessage.replace('\n', ' ');
|
||||
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
||||
|
||||
if (process.platform == 'win32') {
|
||||
exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`)
|
||||
exec(`cd .\\dectalk && .\\say.exe -w ${message.id}_dectalk.wav "${decMessage}"`)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return message.channel.send('Oh no! an error has occurred!');
|
||||
})
|
||||
.then(() => {
|
||||
return message.channel.send({files: [output]});
|
||||
return message.channel.send({files: [`${message.id}_dectalk.wav`]});
|
||||
});
|
||||
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
||||
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
||||
|
||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`)
|
||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${message.id}_dectalk.wav "${decMessage}"`)
|
||||
.catch(err => {
|
||||
loadingmsg.delete();
|
||||
console.error(err);
|
||||
|
@ -54,7 +52,7 @@ class dectalkCommand extends Command {
|
|||
})
|
||||
.then(() => {
|
||||
loadingmsg.delete();
|
||||
return message.channel.send({files: [output]});
|
||||
return message.channel.send({files: [`${message.id}_dectalk.wav`]});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
const os = require('os');
|
||||
const rand = require('../../../rand.js');
|
||||
|
||||
class dectalkvcCommand extends Command {
|
||||
|
@ -29,13 +28,12 @@ class dectalkvcCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message, args) {
|
||||
let output = `${os.tmpdir()}/${message.id}_dectalk.wav`;
|
||||
args.decMessage = rand.random(args.decMessage, message);
|
||||
args.decMessage = args.decMessage.replace('\n', ' ');
|
||||
let decMessage = '[:phoneme on] ' + args.decMessage.replace(/(["'$`\\])/g,'\\$1');
|
||||
|
||||
if (process.platform == 'win32') {
|
||||
exec(`cd .\\dectalk && .\\say.exe -w ${output} "${decMessage}"`)
|
||||
exec(`cd .\\dectalk && .\\say.exe -w ${message.id}_dectalk.wav "${decMessage}"`)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return message.channel.send('Oh no! an error has occurred!');
|
||||
|
@ -45,7 +43,7 @@ class dectalkvcCommand extends Command {
|
|||
if (!voiceChannel) return message.channel.send('Please enter a voice channel first.');
|
||||
try {
|
||||
const connection = await voiceChannel.join();
|
||||
const dispatcher = connection.play(output);
|
||||
const dispatcher = connection.play(`${message.id}_dectalk.wav`);
|
||||
dispatcher.once('finish', () => voiceChannel.leave());
|
||||
dispatcher.once('error', () => voiceChannel.leave());
|
||||
return null;
|
||||
|
@ -58,7 +56,7 @@ class dectalkvcCommand extends Command {
|
|||
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
||||
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
||||
|
||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${output} "${decMessage}"`)
|
||||
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w ${message.id}_dectalk.wav "${decMessage}"`)
|
||||
.catch(err => {
|
||||
loadingmsg.delete();
|
||||
console.error(err);
|
||||
|
@ -70,7 +68,7 @@ class dectalkvcCommand extends Command {
|
|||
try {
|
||||
loadingmsg.delete();
|
||||
const connection = await voiceChannel.join();
|
||||
const dispatcher = connection.play(output);
|
||||
const dispatcher = connection.play(`${message.id}_dectalk.wav`);
|
||||
dispatcher.once('finish', () => voiceChannel.leave());
|
||||
dispatcher.once('error', () => voiceChannel.leave());
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue