Number Fact Command

This commit is contained in:
Daniel Odendahl Jr
2017-09-13 11:08:17 +00:00
parent 6724222138
commit af14cb7291
2 changed files with 33 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
module.exports = class NumberFactCommand extends Command {
constructor(client) {
super(client, {
name: 'number-fact',
group: 'random-res',
memberName: 'number-fact',
description: 'Responds with a random fact about a number.',
args: [
{
key: 'number',
prompt: 'What number do you want to get a fact for?',
type: 'integer'
}
]
});
}
async run(msg, args) {
const { number } = args;
try {
const { text } = await snekfetch
.get(`http://numbersapi.com/${number}`);
return msg.say(text);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "38.6.0",
"version": "38.7.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {