From 982549d9427d163081e4f555e111daa086344f68 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 2 May 2018 17:41:14 +0000 Subject: [PATCH] Advice slip Command --- README.md | 3 ++- commands/random/advice-slip.js | 23 +++++++++++++++++++++++ package.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 commands/random/advice-slip.js diff --git a/README.md b/README.md index e46ce92c..a626886d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can invite the bot to your server using Be sure to also join the [home server](https://discord.gg/sbMe32W) for information and support. -## Commands (307) +## Commands (308) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -54,6 +54,7 @@ information and support. ### Random Response: * **8-ball**: Asks your question to the Magic 8 Ball. +* **advice-slip**: Responds with a random bit of advice. * **cat-fact**: Responds with a random cat fact. * **cat**: Responds with a random cat image. * **charlie-charlie-challenge**: Asks your question to Charlie. diff --git a/commands/random/advice-slip.js b/commands/random/advice-slip.js new file mode 100644 index 00000000..48213267 --- /dev/null +++ b/commands/random/advice-slip.js @@ -0,0 +1,23 @@ +const { Command } = require('discord.js-commando'); +const snekfetch = require('snekfetch'); + +module.exports = class AdviceSlipCommand extends Command { + constructor(client) { + super(client, { + name: 'advice-slip', + aliases: ['advice'], + group: 'random', + memberName: 'advice-slip', + description: 'Responds with a random bit of advice.' + }); + } + + async run(msg) { + try { + const { raw } = await snekfetch.get('http://api.adviceslip.com/advice'); + return msg.say(JSON.parse(raw.toString()).slip.advice); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index ec36aca7..0f0f81d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "75.0.4", + "version": "75.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {