mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 19:04:42 +02:00
Change Yoda API, Security Key
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
};
|
||||
@@ -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.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user