mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 00:09:08 +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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
|
||||
module.exports = class AdorableCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'adorable',
|
||||
aliases: ['adorable-avatar'],
|
||||
group: 'image-edit',
|
||||
memberName: 'adorable',
|
||||
description: 'Creates an adorable avatar based on the text you provide.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Adorable Avatars',
|
||||
url: 'http://avatars.adorable.io/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text should be used for generation?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://api.adorable.io/avatars/285/${text}.png`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'adorable.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user