Haha-Yes/commands/fun/dectalk.js

45 lines
1,008 B
JavaScript
Raw Normal View History

2019-05-17 23:39:13 +02:00
const { Command } = require('discord-akairo');
const axios = require('axios');
const fs = require('fs');
class dectalkCommand extends Command {
constructor() {
super('dectalk', {
aliases: ['dectalk', 'dec'],
category: 'fun',
args: [
{
id: 'decMessage',
type: 'string',
match: 'rest'
}
],
description: {
content: 'Generate your text into dectalk',
usage: '',
examples: ['']
}
});
}
async exec(message, args) {
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',
url: `https://talk.moustacheminer.com/api/gen.wav?dectalk=${args.decMessage}`,
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;