From cab212cecc136c206097020a93fe88e870a6e1b4 Mon Sep 17 00:00:00 2001 From: Terryiscool160 <48654513+Terryiscool160@users.noreply.github.com> Date: Wed, 11 Mar 2020 20:52:43 +0000 Subject: [PATCH] Add files via upload --- changes.txt | 8 ++++++++ src/commands/catfact.js | 8 +++++++- src/commands/dogfact.js | 8 +++++++- src/commands/yoda.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/commands/yoda.js diff --git a/changes.txt b/changes.txt index daa5b88..e91c096 100644 --- a/changes.txt +++ b/changes.txt @@ -1,2 +1,10 @@ +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) +index.js now has better logging of when things fail to load/initialize (terry) +added `dice`, rolls a 6 sided die (terry) +Help command changed, the amount of commands in each category and overall is now displayed +added `inspire` as an alias for inspirobot +ship command +added find by mention to functions \ No newline at end of file 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..cd89858 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.stopTyping(); message.channel.send(`**Did you know?**\n ${body.facts[0]}`); }); +} 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..2d1645d --- /dev/null +++ b/src/commands/yoda.js @@ -0,0 +1,31 @@ +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