2019-05-17 23:39:13 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const axios = require('axios');
|
|
|
|
const fs = require('fs');
|
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',
|
|
|
|
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);
|
2019-05-17 23:55:17 +02:00
|
|
|
args.decMessage = args.decMessage.replace('\n', ' ');
|
2019-05-17 23:39:13 +02:00
|
|
|
args.decMessage = encodeURI(args.decMessage);
|
|
|
|
|
|
|
|
return axios.request({
|
|
|
|
responseType: 'arraybuffer',
|
2019-07-17 21:50:03 +02:00
|
|
|
url: `http://localhost/api/gen.wav?dectalk=${args.decMessage}`,
|
2019-05-17 23:39:13 +02:00
|
|
|
method: 'get',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'audio/wav',
|
|
|
|
},
|
|
|
|
}).then((result) => {
|
|
|
|
const outputFilename = './dectalk.wav';
|
|
|
|
fs.writeFileSync(outputFilename, result.data);
|
|
|
|
return message.channel.send({files: ['./dectalk.wav']});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = dectalkCommand;
|