1
0
Fork 0
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.
Haha-Yes/commands/fun/tts/dectalk.js

45 lines
1.0 KiB
JavaScript

5 years ago
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: '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) {
args.decMessage = args.decMessage.replace('\n', ' ');
5 years ago
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;