mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 11:21:16 +02:00
Doomsday Clock Command
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
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.'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await snekfetch.get('https://thebulletin.org/timeline');
|
||||
const time = text.match(/IT IS(?: STILL)? (.+) MINUTES TO MIDNIGHT/)[0];
|
||||
const desc = text.match(/<div class="body-text"><span class="timeline-year">(.+)<\/span>: (.+)<\/div>/);
|
||||
return msg.say(stripIndents`
|
||||
**${time}**
|
||||
${desc[1]}: ${desc[2].replace(/<a href="(?:.+)">(.+)<\/a>/g, '$1').replace(/<\/div>/g, '')}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "60.0.0",
|
||||
"version": "60.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user