diff --git a/commands/randomimg/xkcd.js b/commands/randomimg/xkcd.js index a70d4307..2a91cdb8 100644 --- a/commands/randomimg/xkcd.js +++ b/commands/randomimg/xkcd.js @@ -1,4 +1,5 @@ const { Command } = require('discord.js-commando'); +const { RichEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); module.exports = class XKCDCommand extends Command { @@ -31,14 +32,21 @@ module.exports = class XKCDCommand extends Command { try { const current = await snekfetch .get('https://xkcd.com/info.0.json'); - if (type === 'today') return msg.say({ files: [current.body.img] }) - .catch(err => msg.say(`${err.name}: ${err.message}`)); - else { + if (type === 'today') { + const embed = new RichEmbed() + .setTitle(`${current.body.num} - ${current.body.title}`) + .setImage(current.body.img) + .setFooter(current.body.alt); + return msg.embed(embed); + } else { const random = Math.floor(Math.random() * current.body.num) + 1; const { body } = await snekfetch .get(`https://xkcd.com/${random}/info.0.json`); - return msg.say({ files: [body.img] }) - .catch(err => msg.say(`${err.name}: ${err.message}`)); + const embed = new RichEmbed() + .setTitle(`${body.num} - ${body.title}`) + .setImage(body.img) + .setFooter(body.alt); + return msg.embed(embed); } } catch (err) { return msg.say(`${err.name}: ${err.message}`); diff --git a/package.json b/package.json index e545ad6e..4cb14cb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "21.1.0", + "version": "21.1.1", "description": "A Discord Bot", "main": "Shard.js", "scripts": {