mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 15:57:42 +02:00
Cat Facts, Dog Facts
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class CatFactCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'cat-fact',
|
||||
group: 'random-res',
|
||||
memberName: 'cat-fact',
|
||||
description: 'Responds with a cat fact.'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://catfact.ninja/fact')
|
||||
.query({ max_length: 2000 });
|
||||
return msg.say(body.fact);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class DogFactCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dog-fact',
|
||||
group: 'random-res',
|
||||
memberName: 'dog-fact',
|
||||
description: 'Responds with a dog fact.'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://dog-api.kinduff.com/api/facts');
|
||||
return msg.say(body.facts[0]);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user