mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
ISS, People in Space, and Adorable Commands
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class IssCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'iss',
|
||||
aliases: ['international-space-station'],
|
||||
group: 'events',
|
||||
memberName: 'iss',
|
||||
description: 'Responds with where the Internation Space Station currently is.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Open Notify',
|
||||
url: 'http://open-notify.org/',
|
||||
reason: 'ISS Current Location API',
|
||||
reasonURL: 'http://open-notify.org/Open-Notify-API/ISS-Location-Now/'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('http://api.open-notify.org/iss-now.json');
|
||||
const position = body.iss_position;
|
||||
return msg.say(`The ISS is currently at **${position.latitude}, ${position.longitude}**.`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { removeDuplicates } = require('../../util/Util');
|
||||
|
||||
module.exports = class PeopleInSpaceCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'people-in-space',
|
||||
aliases: ['space', 'spacemen', 'astronauts', 'spacewomen'],
|
||||
group: 'events',
|
||||
memberName: 'people-in-space',
|
||||
description: 'Responds with the people currently in space.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Open Notify',
|
||||
url: 'http://open-notify.org/',
|
||||
reason: 'People in Space API',
|
||||
reasonURL: 'http://open-notify.org/Open-Notify-API/People-In-Space/'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await request.get('http://api.open-notify.org/astros.json');
|
||||
const crafts = {};
|
||||
for (const person of body.people) {
|
||||
if (crafts[person.craft]) crafts[person.craft].push(person.name);
|
||||
else crafts[person.craft] = [person.name];
|
||||
}
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x2E528E)
|
||||
.setImage('https://i.imgur.com/m3ooNfl.jpg');
|
||||
for (const [craft, people] of Object.entries(crafts)) {
|
||||
embed.addField(`❯ ${craft} (${people.length})`, people.join('\n'), true);
|
||||
}
|
||||
return msg.say(`There are currently **${body.number}** people in space!`, embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user