mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Discord.js v14
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const logos = require('../../assets/json/logos');
|
||||
const { GOV_KEY } = process.env;
|
||||
@@ -13,7 +13,7 @@ module.exports = class ApodCommand extends Command {
|
||||
group: 'events',
|
||||
memberName: 'apod',
|
||||
description: 'Responds with today\'s Astronomy Picture of the Day.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
clientPermissions: [PermissionFlagsBits.EmbedLinks],
|
||||
credit: [
|
||||
{
|
||||
name: 'NASA',
|
||||
@@ -29,14 +29,18 @@ module.exports = class ApodCommand extends Command {
|
||||
const { body } = await request
|
||||
.get('https://api.nasa.gov/planetary/apod')
|
||||
.query({ api_key: GOV_KEY });
|
||||
const embed = new MessageEmbed()
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(body.title)
|
||||
.setDescription(shorten(body.explanation))
|
||||
.setColor(0x2E528E)
|
||||
.setAuthor('Astronomy Picture of the Day', logos.nasa, 'https://apod.nasa.gov/apod/astropix.html')
|
||||
.setAuthor({
|
||||
name: 'Astronomy Picture of the Day',
|
||||
iconURL: logos.nasa,
|
||||
url: 'https://apod.nasa.gov/apod/astropix.html'
|
||||
})
|
||||
.setImage(body.media_type === 'image' ? body.url : null)
|
||||
.setURL(body.url)
|
||||
.setFooter(`Image Credits: ${body.copyright ? body.copyright.replaceAll('\n', '/') : 'Public Domain'}`)
|
||||
.setFooter({ text: `Image Credits: ${body.copyright ? body.copyright.replaceAll('\n', '/') : 'Public Domain'}` })
|
||||
.setTimestamp();
|
||||
return msg.embed(embed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user