diff --git a/changes.txt b/changes.txt index 20d4a91..e91c096 100644 --- a/changes.txt +++ b/changes.txt @@ -1,3 +1,4 @@ +Added a yodish command and made catfact and dogfact say if the api errors (terry) Links to avatars now lead to the original file size Bots now get a bot badge in the userinfo command Added dogfact and catfact command (terry) diff --git a/src/commands/catfact.js b/src/commands/catfact.js index 4944b43..8beb770 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -1,10 +1,16 @@ const request = require("request"); exports.run = async (bot, message, args) => { + message.channel.startTyping(); + try{ request({ uri: "https://catfact.ninja/facts", json: true }, (error, response, body) => { - if (error) throw new Error(error); message.channel.send(`**Did you know?**\n ${body.data[0].fact}`); + message.channel.startTyping(); }); +} catch(err) { + message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.stopTyping(); +}; }; exports.conf = { diff --git a/src/commands/dogfact.js b/src/commands/dogfact.js index dc6bf7c..31d1639 100644 --- a/src/commands/dogfact.js +++ b/src/commands/dogfact.js @@ -1,10 +1,16 @@ const request = require("request"); exports.run = async (bot, message, args) => { + message.channel.startTyping(); + try{ request({ uri: "https://dog-api.kinduff.com/api/facts", json: true }, (error, response, body) => { - if (error) throw new Error(error); message.channel.send(`**Did you know?**\n ${body.facts[0]}`); + message.channel.stopTyping(); }); +} catch(err) { + message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.stopTyping(); +}; }; exports.conf = { diff --git a/src/commands/yoda.js b/src/commands/yoda.js new file mode 100644 index 0000000..293d786 --- /dev/null +++ b/src/commands/yoda.js @@ -0,0 +1,32 @@ + +const request = require('request') +exports.run = async (client, message, args) => { + const speech = args.join(' '); + if (!args[0]) { + return message.channel.send(`<:error:466995152976871434> Please include text for me to convert to yodish. Yes.`) + } + try { + const { text } = request({ uri: `http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`, json: true }, (error, response, body) => { + message.channel.send(JSON.parse(text).yodish) + }); + } catch(err) { + message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.stopTyping(); + } + +} + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["yoda","yodasay"], + permLevel: "User", + requiredPerms: [] + }; + + exports.help = { + name: "yodish", + category: "Fun", + description: "Turns any text you input into yodish. Yes.", + usage: "yodish " + }; \ No newline at end of file