new garfield command

This commit is contained in:
Emily 2020-10-23 12:34:20 +11:00
parent ef0e2d8594
commit 98255e73aa
2 changed files with 19 additions and 5 deletions

View file

@ -10,7 +10,6 @@
"dblapi.js": "^2.4.1",
"discord.js": "^12.4.0",
"enmap": "^5.8.0",
"garfield": "^1.1.2",
"hastebin-gen": "^2.0.5",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",

View file

@ -1,8 +1,23 @@
const garfield = require("garfield");
const fetch = require("node-fetch")
const { MessageEmbed } = require('discord.js')
exports.run = async (client, message) => {
message.channel.send({ files: [garfield.random()] }).catch(() => message.channel.send(
"<:error:466995152976871434> API didn't respond, try again in a few seconds."
));
message.channel.startTyping();
try {
fetch('https://garfield-comics.glitch.me/~SRoMG/?date=xxxx')
.then(res => res.json())
.then(json => {
const embed = new MessageEmbed()
.setTitle(`${json.data.name} (No. ${json.data.number})`)
.setColor(client.embedColour(message))
.setURL('https://www.mezzacotta.net/garfield/?comic=' + json.data.number)
.setImage(json.data.image.src);
message.channel.send(embed)
});
message.channel.stopTyping();
} catch (err) {
message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`)
message.channel.stopTyping();
};
};
exports.conf = {