You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
Plaintext
60 lines
1.7 KiB
Plaintext
5 years ago
|
const { Command } = require('discord-akairo');
|
||
5 years ago
|
const util = require('util');
|
||
|
const exec = util.promisify(require('child_process').exec);
|
||
5 years ago
|
const rand = require('../../../rand.js');
|
||
5 years ago
|
|
||
|
class dectalkCommand extends Command {
|
||
|
constructor() {
|
||
|
super('dectalk', {
|
||
|
aliases: ['dectalk', 'dec'],
|
||
|
category: 'fun',
|
||
|
args: [
|
||
|
{
|
||
|
id: 'decMessage',
|
||
|
type: 'string',
|
||
5 years ago
|
prompt: {
|
||
|
start: 'Write something so i can say it back in dectalk',
|
||
|
},
|
||
5 years ago
|
match: 'rest'
|
||
|
}
|
||
|
],
|
||
|
description: {
|
||
5 years ago
|
content: 'Send a wav of what you wrote into .wav with dectalk',
|
||
|
usage: '[text]',
|
||
|
examples: ['This command is very epic']
|
||
5 years ago
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async exec(message, args) {
|
||
5 years ago
|
args.decMessage = rand.random(args.decMessage, message);
|
||
5 years ago
|
args.decMessage = args.decMessage.replace('\n', ' ');
|
||
5 years ago
|
let decMessage = '[:phoneme on] ' + args.decMessage;
|
||
5 years ago
|
|
||
5 years ago
|
if (process.platform == 'win32') {
|
||
5 years ago
|
exec(`cd .\\dectalk && .\\say.exe -w dectalk.wav "${decMessage}"`)
|
||
5 years ago
|
.catch(err => {
|
||
5 years ago
|
console.error(err);
|
||
|
return message.channel.send('Oh no! an error has occured!');
|
||
5 years ago
|
})
|
||
|
.then(() => {
|
||
|
return message.channel.send({files: ['./dectalk/dectalk.wav']});
|
||
|
});
|
||
5 years ago
|
} else if (process.platform == 'linux' || process.platform == 'darwin') {
|
||
5 years ago
|
let loadingmsg = await message.channel.send('Processing ( this can take some time ) <a:loadingmin:527579785212329984>');
|
||
|
|
||
5 years ago
|
exec(`cd dectalk && DISPLAY=:0.0 wine say.exe -w dectalk.wav "${decMessage}"`)
|
||
5 years ago
|
.catch(err => {
|
||
5 years ago
|
loadingmsg.delete();
|
||
|
console.error(err);
|
||
|
return message.channel.send('Oh no! an error has occured!');
|
||
5 years ago
|
})
|
||
|
.then(() => {
|
||
5 years ago
|
loadingmsg.delete();
|
||
5 years ago
|
return message.channel.send({files: ['./dectalk/dectalk.wav']});
|
||
|
});
|
||
|
}
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = dectalkCommand;
|