From d936b07a4c222860d78dded9131a1549f20a7812 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 21 Dec 2017 17:38:18 +0000 Subject: [PATCH] Doomsday Clock Command --- commands/events/doomsday-clock.js | 28 ++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 commands/events/doomsday-clock.js diff --git a/commands/events/doomsday-clock.js b/commands/events/doomsday-clock.js new file mode 100644 index 00000000..ab70e49a --- /dev/null +++ b/commands/events/doomsday-clock.js @@ -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(/
(.+)<\/span>: (.+)<\/div>/); + return msg.say(stripIndents` + **${time}** + ${desc[1]}: ${desc[2].replace(/(.+)<\/a>/g, '$1').replace(/<\/div>/g, '')} + `); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index f75af8a1..e314ba82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "60.0.0", + "version": "60.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {