mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 13:56:25 +02:00
Updates
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class NumberFactCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'number-fact',
|
||||
group: 'random',
|
||||
memberName: 'number-fact',
|
||||
description: 'Responds with a random fact about a specific number.',
|
||||
args: [
|
||||
{
|
||||
key: 'number',
|
||||
prompt: 'What number do you want to get a fact for?',
|
||||
type: 'integer'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { number }) {
|
||||
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.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user