From 5a268c9f2f011a35ffddab15a9b3abe4f64ba872 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Wed, 26 Sep 2018 13:47:21 +0200 Subject: [PATCH] Show random cat and random dog --- commands/fun/randocat.js | 27 +++++++++++++++++++++++++++ commands/fun/randodog.js | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 commands/fun/randocat.js create mode 100644 commands/fun/randodog.js diff --git a/commands/fun/randocat.js b/commands/fun/randocat.js new file mode 100644 index 00000000..736ba508 --- /dev/null +++ b/commands/fun/randocat.js @@ -0,0 +1,27 @@ +const { Command } = require('discord.js-commando'); +const Discord = require('discord.js'); +const snekfetch = require('snekfetch'); +module.exports = class CatCommand extends Command { + constructor(client) { + super(client, { + name: 'cat', + group: 'fun', + memberName: 'cat', + description: `Show a random cat`, + }); + } + + async run(message, { city }) { + const { body } = await snekfetch.get(`http://aws.random.cat/meow`); + if (body.cod == '404') { + return message.say(`No results found for **${city}**`); + } + const dogEmbed = new Discord.RichEmbed() + .setColor("#ff9900") + .setTitle('Meow') + .setImage(body.file) + + + message.say(dogEmbed); + } +}; \ No newline at end of file diff --git a/commands/fun/randodog.js b/commands/fun/randodog.js new file mode 100644 index 00000000..ed1bb005 --- /dev/null +++ b/commands/fun/randodog.js @@ -0,0 +1,27 @@ +const { Command } = require('discord.js-commando'); +const Discord = require('discord.js'); +const snekfetch = require('snekfetch'); +module.exports = class DoggyCommand extends Command { + constructor(client) { + super(client, { + name: 'doggy', + group: 'fun', + memberName: 'doggy', + description: `Show a random doggy`, + }); + } + + async run(message, { city }) { + const { body } = await snekfetch.get(`https://random.dog/woof.json`); + if (body.cod == '404') { + return message.say(`No results found for **${city}**`); + } + const dogEmbed = new Discord.RichEmbed() + .setColor("#ff9900") + .setTitle('Woof') + .setImage(body.url) + + + message.say(dogEmbed); + } +}; \ No newline at end of file