mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 00:07:36 +02:00
Updates
This commit is contained in:
@@ -7,7 +7,7 @@ module.exports = class DaysUntilCommand extends Command {
|
||||
aliases: ['days-until-christmas'],
|
||||
group: 'events',
|
||||
memberName: 'days-until',
|
||||
description: 'Responds with how many days until a certain date this year.',
|
||||
description: 'Responds with how many days there are until a certain date.',
|
||||
args: [
|
||||
{
|
||||
key: 'date',
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = class GoogleDoodleCommand extends Command {
|
||||
name: 'google-doodle',
|
||||
group: 'events',
|
||||
memberName: 'google-doodle',
|
||||
description: 'Responds with a Google doodle, either the latest or a random one from a specific month/year.',
|
||||
description: 'Responds with a Google Doodle, either the latest one or a random one from the past.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = class HoroscopeCommand extends Command {
|
||||
name: 'horoscope',
|
||||
group: 'events',
|
||||
memberName: 'horoscope',
|
||||
description: 'Responds with today\'s horoscope for a particular sign.',
|
||||
description: 'Responds with today\'s horoscope for a specific Zodiac sign.',
|
||||
details: `**Signs**: ${signs.join(', ')}`,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
|
||||
@@ -9,22 +9,14 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
aliases: ['event', 'today', 'history'],
|
||||
group: 'events',
|
||||
memberName: 'today-in-history',
|
||||
description: 'Responds with an event that occurred today in history, or on a specific day.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'date',
|
||||
prompt: 'What date do you want events for? Month/Day format.',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
description: 'Responds with an event that occurred today in history.',
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { date }) {
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await snekfetch.get(`http://history.muffinlabs.com/date${date ? `/${date}` : ''}`);
|
||||
const { text } = await snekfetch.get('http://history.muffinlabs.com/date');
|
||||
const body = JSON.parse(text);
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
@@ -38,7 +30,6 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
event.links.map(link => `[${link.title}](${link.link.replace(/\)/g, '%29')})`).join(', '));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404 || err.status === 500) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = class WordOfTheDayCommand extends Command {
|
||||
aliases: ['wordnik-word-of-the-day'],
|
||||
group: 'events',
|
||||
memberName: 'word-of-the-day',
|
||||
description: 'Gets the word of the day.'
|
||||
description: 'Responds with today\'s word of the day.'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,24 +9,24 @@ module.exports = class XKCDCommand extends Command {
|
||||
aliases: ['kcd'],
|
||||
group: 'events',
|
||||
memberName: 'xkcd',
|
||||
description: 'Gets an XKCD Comic, optionally opting for today\'s or a specific number.',
|
||||
description: 'Responds with an XKCD comic, either today\'s, a random one, or a specific one.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'type',
|
||||
key: 'query',
|
||||
prompt: 'Please enter either a specific comic number, today, or random.',
|
||||
type: 'string',
|
||||
default: 'today',
|
||||
parse: type => type.toLowerCase()
|
||||
parse: query => query.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { type }) {
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const current = await snekfetch.get('https://xkcd.com/info.0.json');
|
||||
if (type === 'today') {
|
||||
if (query === 'today') {
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(`${current.body.num} - ${current.body.title}`)
|
||||
.setColor(0x9797FF)
|
||||
@@ -35,7 +35,7 @@ module.exports = class XKCDCommand extends Command {
|
||||
.setFooter(current.body.alt);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
if (type === 'random') {
|
||||
if (query === 'random') {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await snekfetch.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -46,7 +46,7 @@ module.exports = class XKCDCommand extends Command {
|
||||
.setFooter(body.alt);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
const choice = parseInt(type, 10);
|
||||
const choice = parseInt(query, 10);
|
||||
if (isNaN(choice) || current.body.num < choice || choice < 1) return msg.say('Could not find any results.');
|
||||
const { body } = await snekfetch.get(`https://xkcd.com/${choice}/info.0.json`);
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
Reference in New Issue
Block a user