mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Remove more commands
This commit is contained in:
@@ -54,6 +54,6 @@ module.exports = class CalendarCommand extends Command {
|
||||
}
|
||||
}
|
||||
display += '|';
|
||||
return msg.code(null, display);
|
||||
return msg.say(`\`\`\`\n${display}\n\`\`\``);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class Covid19Command extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'covid-19',
|
||||
aliases: ['coronavirus', 'corona', 'covid'],
|
||||
group: 'events',
|
||||
memberName: 'covid-19',
|
||||
description: 'Responds with stats for COVID-19.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'disease.sh',
|
||||
url: 'https://disease.sh/',
|
||||
reason: 'COVID-19 API',
|
||||
reasonURL: 'https://disease.sh/docs/#/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'country',
|
||||
prompt: 'What country do you want to get the stats for? Type `all` to get world stats.',
|
||||
type: 'string',
|
||||
default: 'all',
|
||||
parse: country => encodeURIComponent(country)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { country }) {
|
||||
try {
|
||||
const data = await this.fetchStats(country);
|
||||
const slug = country === 'all' ? null : data.country === 'USA' ? 'us' : data.country.toLowerCase();
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xA2D84E)
|
||||
.setAuthor('Worldometers', 'https://i.imgur.com/IoaBMuK.jpg', 'https://www.worldometers.info/coronavirus/')
|
||||
.setTitle(`Stats for ${country === 'all' ? 'The World' : data.country}`)
|
||||
.setURL(country === 'all'
|
||||
? 'https://www.worldometers.info/coronavirus/'
|
||||
: `https://www.worldometers.info/coronavirus/country/${encodeURIComponent(slug.replace(/ /g, '-'))}/`)
|
||||
.setThumbnail(country === 'all' ? null : data.countryInfo.flag || null)
|
||||
.setFooter('Last Updated')
|
||||
.setTimestamp(data.updated)
|
||||
.addField('❯ Total Cases', `${formatNumber(data.cases)} (${formatNumber(data.todayCases)} Today)`, true)
|
||||
.addField('❯ Total Deaths', `${formatNumber(data.deaths)} (${formatNumber(data.todayDeaths)} Today)`, true)
|
||||
.addField('❯ Total Recoveries',
|
||||
`${formatNumber(data.recovered)} (${formatNumber(data.todayRecovered)} Today)`, true)
|
||||
.addField('❯ Active Cases', formatNumber(data.active), true)
|
||||
.addField('❯ Active Critical Cases', formatNumber(data.critical), true)
|
||||
.addField('❯ Tests', formatNumber(data.tests), true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.say('Country not found or doesn\'t have any cases.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchStats(country) {
|
||||
const { body } = await request
|
||||
.get(`https://disease.sh/v3/covid-19/${country === 'all' ? 'all' : `countries/${country}`}`);
|
||||
return body;
|
||||
}
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { decode: decodeHTML } = require('html-entities');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { embedURL } = require('../../util/Util');
|
||||
|
||||
module.exports = class DoomsdayClockCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'doomsday-clock',
|
||||
group: 'events',
|
||||
memberName: 'doomsday-clock',
|
||||
description: 'Responds with the current time of the Doomsday Clock.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Bulletin of the Atomic Scientists',
|
||||
url: 'https://thebulletin.org/',
|
||||
reason: 'Doomsday Clock Data',
|
||||
reasonURL: 'https://thebulletin.org/doomsday-clock/current-time/'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('https://thebulletin.org/doomsday-clock/past-statements/');
|
||||
const time = text.match(/<h3 class="uabb-infobox-title">(.+)<\/h3>/)[1];
|
||||
const year = text.match(/<h5 class="uabb-infobox-title-prefix">(.+)<\/h5>/)[1];
|
||||
const description = text.match(/<div class="uabb-infobox-text uabb-text-editor">(.|\n)+<p>(.+)<\/p>/)[2]
|
||||
.replace(/<a href="(.+)" target="_blank" rel="noopener">(.+)<\/a>/, embedURL('$2', '$1'));
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`${year}: ${time}`)
|
||||
.setColor(0x000000)
|
||||
.setURL('https://thebulletin.org/doomsday-clock/current-time/')
|
||||
.setAuthor('Bulletin of the Atomic Scientists', undefined, 'https://thebulletin.org/')
|
||||
.setDescription(decodeHTML(description));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
|
||||
module.exports = class FridayThe13thCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'friday-the-13th',
|
||||
aliases: ['friday-13th', 'friday-13', 'friday-the-13', 'friday-the-thirteenth', 'friday-thirteenth'],
|
||||
group: 'events',
|
||||
memberName: 'friday-the-13th',
|
||||
description: 'Determines if today is Friday the 13th.',
|
||||
credit: [
|
||||
{
|
||||
name: 'r/IsTodayFridayThe13th',
|
||||
url: 'https://www.reddit.com/r/IsTodayFridayThe13th/',
|
||||
reason: 'Concept'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const today = new Date();
|
||||
const isFridaythe13th = today.getDay() === 5 && today.getDate() === 13;
|
||||
return msg.say(`Today **is${isFridaythe13th ? '' : ' not'}** Friday the 13th.`);
|
||||
}
|
||||
};
|
||||
@@ -1,74 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { list, today, tomorrow } = require('../../util/Util');
|
||||
const { GOOGLE_KEY, PERSONAL_GOOGLE_CALENDAR_ID } = process.env;
|
||||
const holidayCals = {
|
||||
USA: 'en.usa#holiday@group.v.calendar.google.com',
|
||||
Japan: 'en.japanese#holiday@group.v.calendar.google.com',
|
||||
UK: 'en.uk#holiday@group.v.calendar.google.com',
|
||||
Australia: 'en.australian#holiday@group.v.calendar.google.com',
|
||||
Canada: 'en.canadian#holiday@group.v.calendar.google.com'
|
||||
};
|
||||
|
||||
module.exports = class HolidaysCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'holidays',
|
||||
aliases: ['events', 'google-calendar'],
|
||||
group: 'events',
|
||||
memberName: 'holidays',
|
||||
description: 'Responds with today\'s holidays.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'Calendar API',
|
||||
reasonURL: 'https://developers.google.com/calendar/'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const events = [];
|
||||
for (const [country, calID] of Object.entries(holidayCals)) {
|
||||
const standardEvents = await this.fetchHolidays(calID);
|
||||
if (standardEvents) {
|
||||
const mapped = standardEvents.map(event => `${event} (${country})`);
|
||||
events.push(...mapped);
|
||||
}
|
||||
}
|
||||
if (PERSONAL_GOOGLE_CALENDAR_ID) {
|
||||
const personalEvents = await this.fetchHolidays(PERSONAL_GOOGLE_CALENDAR_ID);
|
||||
if (personalEvents) events.push(...personalEvents);
|
||||
}
|
||||
if (!events.length) return msg.say('There are no holidays today...');
|
||||
const holidays = list(events.map(event => `**${event}**`));
|
||||
return msg.say(`Today${events.length === 1 ? ' is' : `'s holidays are`} ${holidays}!`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
async fetchHolidays(id) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(id)}/events`)
|
||||
.query({
|
||||
maxResults: 20,
|
||||
orderBy: 'startTime',
|
||||
singleEvents: true,
|
||||
timeMax: tomorrow().toISOString(),
|
||||
timeMin: today().toISOString(),
|
||||
timeZone: 'UTC',
|
||||
key: GOOGLE_KEY
|
||||
});
|
||||
if (!body.items.length) return null;
|
||||
return body.items.map(holiday => holiday.summary);
|
||||
} catch (err) {
|
||||
if (err.status === 404) return null;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class HumbleBundleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'humble-bundle',
|
||||
aliases: ['humble'],
|
||||
group: 'events',
|
||||
memberName: 'humble-bundle',
|
||||
description: 'Responds with the current Humble Bundle.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Humble Bundle',
|
||||
url: 'https://www.humblebundle.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.humblebundle.com/developer'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('https://www.humblebundle.com/androidapp/v2/service_check');
|
||||
const body = JSON.parse(text);
|
||||
if (!body.length) return msg.say('There is no bundle right now...');
|
||||
if (body.length > 1) {
|
||||
return msg.say(stripIndents`
|
||||
There are **${body.length}** bundles on right now!
|
||||
${body.map(bundle => `**${bundle.bundle_name}:** <${bundle.url}>`).join('\n')}
|
||||
`);
|
||||
}
|
||||
const data = body[0];
|
||||
return msg.say(stripIndents`
|
||||
The current bundle is **${data.bundle_name}**!
|
||||
${data.url}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
const Command = require('../../framework/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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
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