mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
snekfetch 4.0.0
This commit is contained in:
@@ -14,7 +14,8 @@ module.exports = class DoomsdayClockCommand extends Command {
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await snekfetch.get('https://thebulletin.org/timeline');
|
||||
const { raw } = await snekfetch.get('https://thebulletin.org/timeline');
|
||||
const text = raw.toString();
|
||||
const time = text.match(/IT IS (.+) MINUTES TO MIDNIGHT/)[0];
|
||||
const desc = text.match(/<div class="body-text"><span class="timeline-year">(.+)<\/span>: (.+)<\/div>/);
|
||||
return msg.say(stripIndents`
|
||||
|
||||
@@ -33,8 +33,8 @@ module.exports = class TodayInHistoryCommand extends Command {
|
||||
async run(msg, { month, day }) {
|
||||
const date = month && day ? `/${month}/${day}` : '';
|
||||
try {
|
||||
const { text } = await snekfetch.get(`http://history.muffinlabs.com/date${date}`);
|
||||
const body = JSON.parse(text);
|
||||
const { raw } = await snekfetch.get(`http://history.muffinlabs.com/date${date}`);
|
||||
const body = JSON.parse(raw.toString());
|
||||
const events = body.data.Events;
|
||||
const event = events[Math.floor(Math.random() * events.length)];
|
||||
const embed = new MessageEmbed()
|
||||
@@ -47,7 +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.');
|
||||
if (err.statusCode === 404 || err.statusCode === 500) return msg.say('Invalid date.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user