mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
Discord.js v14
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const types = ['random', 'today'];
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = class XKCDCommand extends Command {
|
||||
group: 'search',
|
||||
memberName: 'xkcd',
|
||||
description: 'Responds with an XKCD comic, either today\'s, a random one, or a specific one.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks],
|
||||
credit: [
|
||||
{
|
||||
name: 'xkcd',
|
||||
@@ -40,34 +40,34 @@ module.exports = class XKCDCommand extends Command {
|
||||
async run(msg, { query }) {
|
||||
const current = await request.get('https://xkcd.com/info.0.json');
|
||||
if (query === 'today') {
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${current.body.num} - ${current.body.title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://xkcd.com/${current.body.num}`)
|
||||
.setImage(current.body.img)
|
||||
.setFooter(current.body.alt);
|
||||
.setFooter({ text: current.body.alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
if (query === 'random') {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await request.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
.setFooter({ text: body.alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
const choice = Number.parseInt(query, 10);
|
||||
if (current.body.num < choice) return msg.say('Could not find any results.');
|
||||
const { body } = await request.get(`https://xkcd.com/${choice}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
.setFooter({ text: body.alt });
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user