const { Command } = require('discord.js-commando'); const snekfetch = require('snekfetch'); const { wait } = require('../../util/Util'); module.exports = class IllegalCommand extends Command { constructor(client) { super(client, { name: 'illegal', aliases: ['is-now-illegal', 'trump', 'first-order-of-business'], group: 'image-edit', memberName: 'illegal', description: 'Makes President Trump make your text illegal.', throttling: { usages: 1, duration: 10 }, clientPermissions: ['ATTACH_FILES'], args: [ { key: 'text', prompt: 'What should the text of the bill be?', type: 'string', validate: text => { if (/^[a-zA-Z0-9 ]+$/g.test(text) && text.length > 11) return true; return 'Invalid text, please enter 10 or fewer basic unicode characters (A-Z, 0-9).'; }, parse: text => text.toUpperCase() } ] }); } async run(msg, { text }) { try { await snekfetch .post('https://is-now-illegal.firebaseio.com/queue/tasks.json') .send({ task: 'gif', word: text }); await msg.say('Trump is busy signing the bill, please wait 5 seconds...'); await wait(5000); const { body } = await snekfetch .get(`https://is-now-illegal.firebaseio.com/gifs/${text}.json`); if (!body) return msg.reply('Trump failed to sign the bill.'); return msg.say({ files: [body.url] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } } };