diff --git a/commands/random/security-key.js b/commands/random/security-key.js new file mode 100644 index 00000000..b9b1b79a --- /dev/null +++ b/commands/random/security-key.js @@ -0,0 +1,18 @@ +const { Command } = require('discord.js-commando'); +const crypto = require('crypto'); + +module.exports = class SecurityKeyCommand extends Command { + constructor(client) { + super(client, { + name: 'security-key', + aliases: ['crypto', 'random-bytes'], + group: 'random', + memberName: 'security-key', + description: 'Responds with a random security key.' + }); + } + + run(msg) { + return msg.say(crypto.randomBytes(15).toString('hex')); + } +}; diff --git a/commands/text-edit/yoda.js b/commands/text-edit/yoda.js index c553c331..f65173f2 100644 --- a/commands/text-edit/yoda.js +++ b/commands/text-edit/yoda.js @@ -1,6 +1,6 @@ const { Command } = require('discord.js-commando'); const snekfetch = require('snekfetch'); -const { MASHAPE_KEY } = process.env; +const { YODA_KEY } = process.env; module.exports = class YodaCommand extends Command { constructor(client) { @@ -13,8 +13,7 @@ module.exports = class YodaCommand extends Command { args: [ { key: 'sentence', - label: 'text', - prompt: 'What text would you like to convert to Yoda speak?', + prompt: 'What sentence would you like to convert to Yoda speak?', type: 'string', max: 500 } @@ -24,12 +23,14 @@ module.exports = class YodaCommand extends Command { async run(msg, { sentence }) { try { - const { text } = await snekfetch - .get('https://yoda.p.mashape.com/yoda') - .query({ sentence }) - .set({ 'X-Mashape-Key': MASHAPE_KEY }); - if (!text) return msg.reply('Empty, this message is. Try again later, you must.'); - return msg.say(text); + const { body } = await snekfetch + .get('https://yoda-speak-api.herokuapp.com/') + .query({ + text: sentence, + token: YODA_KEY + }); + if (!body.response) return msg.reply('Empty, this message is. Try again later, you must.'); + return msg.say(body.response); } catch (err) { return msg.reply(`Being a jerk again, Yoda is: \`${err.message}\`. Try again later, you must.`); }