mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Today in History supports date entry
This commit is contained in:
@@ -10,13 +10,30 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
group: 'events',
|
||||
memberName: 'today-in-history',
|
||||
description: 'Responds with an event that occurred today in history.',
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'month',
|
||||
prompt: 'What month would you like to get an event for?',
|
||||
type: 'month',
|
||||
default: ''
|
||||
},
|
||||
{
|
||||
key: 'day',
|
||||
prompt: 'What day would you like to get an event for?',
|
||||
type: 'integer',
|
||||
default: '',
|
||||
min: 1,
|
||||
max: 31
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
async run(msg, { month, day }) {
|
||||
const date = month && day ? `/${month}/${day}` : '';
|
||||
try {
|
||||
const { text } = await snekfetch.get('http://history.muffinlabs.com/date');
|
||||
const { text } = await snekfetch.get(`http://history.muffinlabs.com/date${date}`);
|
||||
const body = JSON.parse(text);
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
@@ -30,6 +47,7 @@ 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('Invalid date.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "66.0.0",
|
||||
"version": "66.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user