mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 14:20:51 +02:00
APOD Command
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { shorten } = require('../../structures/Util');
|
||||
const { GOV_KEY } = process.env;
|
||||
|
||||
module.exports = class APODCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'apod',
|
||||
aliases: ['nasa-apod', 'astronomy-picture-of-the-day', 'apod-image', 'nasa-apod-image'],
|
||||
group: 'random',
|
||||
memberName: 'apod',
|
||||
description: 'Responds with today\'s Astronomy Picture of the Day.',
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://api.nasa.gov/planetary/apod')
|
||||
.query({ qpi_key: GOV_KEY });
|
||||
return msg.say(shorten(body.explanation), { files: [body.url] });
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user