From 20ef0c946cdf9b7eb42ca36cc9e203c5e88aa57b Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 17 May 2019 23:39:13 +0200 Subject: [PATCH] dectalk --- commands/fun/dectalk.js | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 commands/fun/dectalk.js diff --git a/commands/fun/dectalk.js b/commands/fun/dectalk.js new file mode 100644 index 00000000..299af771 --- /dev/null +++ b/commands/fun/dectalk.js @@ -0,0 +1,44 @@ +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) { + 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; \ No newline at end of file