From e2403b6cbec1a347aaf3eb18552c4e6616e3bad9 Mon Sep 17 00:00:00 2001 From: Terryiscool160 <48654513+Terryiscool160@users.noreply.github.com> Date: Tue, 10 Mar 2020 00:12:00 +0000 Subject: [PATCH] Fixes. Put CatFact and DogFact into the "Fun" category while also adding a discord disconnect and reconnect logger. --- src/commands/catfact.js | 4 ++-- src/commands/dicerole.js | 27 +++++++++++++++++++++++++++ src/commands/dogfact.js | 2 +- src/events/disconnect.js | 3 +++ src/events/reconnection.js | 3 +++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/commands/dicerole.js create mode 100644 src/events/disconnect.js create mode 100644 src/events/reconnection.js diff --git a/src/commands/catfact.js b/src/commands/catfact.js index 7505a1b..18fc87e 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -3,7 +3,7 @@ const request = require("request"); exports.run = async (bot, message, args) => { 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.facts[0]}`); + message.channel.send(`**Did you know?**\n ${body.data[0].facts}`); }); }; @@ -17,7 +17,7 @@ exports.conf = { exports.help = { name: "catfact", - category: "User", + category: "Fun", description: "Sends a fun fact about a cat.", usage: "catfact/kittenfact" }; diff --git a/src/commands/dicerole.js b/src/commands/dicerole.js new file mode 100644 index 0000000..569f381 --- /dev/null +++ b/src/commands/dicerole.js @@ -0,0 +1,27 @@ +exports.run = async (bot, message, args) => { + if (args.length === 0) { + message.channel.send(`🎲 The dice landed on ${Array.from(Array(6).keys()).random() + 1}.`); + } else { + if (args[0].match(/^\d+$/)) { + message.channel.send(`🎲 The dice landed on ${Array.from(Array(parseInt(args[0])).keys()).random() + 1}.`); + } else { + message.channel.send(`🎲 The dice landed on ${Array.from(Array(6).keys()).random() + 1}.`); + } + } + }; + + exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["diceroll"], + permLevel: "User", + requiredPerms: [] + }; + + exports.help = { + name: "dice", + category: "Fun", + description: "Rolls a dice.", + usage: "dice" + }; + \ No newline at end of file diff --git a/src/commands/dogfact.js b/src/commands/dogfact.js index ae0ef94..dc6bf7c 100644 --- a/src/commands/dogfact.js +++ b/src/commands/dogfact.js @@ -17,7 +17,7 @@ exports.conf = { exports.help = { name: "dogfact", - category: "User", + category: "Fun", description: "Sends a fun fact about a doggo.", usage: "dogfact/pupfact" }; diff --git a/src/events/disconnect.js b/src/events/disconnect.js new file mode 100644 index 0000000..932b5fd --- /dev/null +++ b/src/events/disconnect.js @@ -0,0 +1,3 @@ +module.exports = client => { // logs if the bot gets disconnected from discord. + client.logger.warn(`Bot disconnected at ${new Date()}`); +}; \ No newline at end of file diff --git a/src/events/reconnection.js b/src/events/reconnection.js new file mode 100644 index 0000000..d0a6fb2 --- /dev/null +++ b/src/events/reconnection.js @@ -0,0 +1,3 @@ +module.exports = client => { // logs when the bot reconnects to discord + client.logger.info(`Reconnecting at ${new Date()}`); +}; \ No newline at end of file