2019-05-17 23:39:13 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
2020-09-04 13:36:08 +02:00
|
|
|
const { execFile } = require('child_process');
|
2019-05-19 21:36:42 +02:00
|
|
|
const rand = require('../../../rand.js');
|
2019-05-17 23:39:13 +02:00
|
|
|
|
|
|
|
class dectalkCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('dectalk', {
|
|
|
|
aliases: ['dectalk', 'dec'],
|
|
|
|
category: 'fun',
|
2019-11-09 12:04:01 +01:00
|
|
|
clientPermissions: ['ATTACH_FILES'],
|
2019-05-17 23:39:13 +02:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'decMessage',
|
|
|
|
type: 'string',
|
2019-06-23 03:41:59 +02:00
|
|
|
prompt: {
|
|
|
|
start: 'Write something so i can say it back in dectalk',
|
|
|
|
},
|
2019-05-17 23:39:13 +02:00
|
|
|
match: 'rest'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
2019-05-18 03:01:57 +02:00
|
|
|
content: 'Send a wav of what you wrote into .wav with dectalk',
|
|
|
|
usage: '[text]',
|
|
|
|
examples: ['This command is very epic']
|
2019-05-17 23:39:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2019-05-19 20:41:58 +02:00
|
|
|
args.decMessage = rand.random(args.decMessage, message);
|
2020-09-04 13:52:25 +02:00
|
|
|
let output = `${message.id}_dectalk.wav`;
|
2020-09-04 13:36:08 +02:00
|
|
|
let decMessage = '[:phoneme on]' + args.decMessage;
|
|
|
|
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
2019-05-17 23:39:13 +02:00
|
|
|
|
2020-09-04 13:36:08 +02:00
|
|
|
if (process.platform === 'win32') {
|
|
|
|
execFile('say.exe', ['-w', output, `${decMessage}`], {cwd: './dectalk/'}, (error, stdout, stderr) => {
|
2020-09-04 13:52:25 +02:00
|
|
|
sendMessage(output, error, stdout, stderr);
|
2020-09-04 13:36:08 +02:00
|
|
|
});
|
|
|
|
} else if (process.platform === 'linux' || process.platform === 'darwin') {
|
|
|
|
execFile('wine', ['say.exe', '-w', output, `${decMessage}`], {cwd: './dectalk/'}, (error, stdout, stderr) => {
|
2020-09-04 13:52:25 +02:00
|
|
|
sendMessage(`./dectalk/${output}`, error, stdout, stderr);
|
2020-09-04 13:36:08 +02:00
|
|
|
});
|
2019-07-17 23:29:29 +02:00
|
|
|
}
|
2020-09-04 13:52:25 +02:00
|
|
|
|
|
|
|
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]});
|
|
|
|
}
|
2019-05-17 23:39:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = dectalkCommand;
|