Various Fixes and Improvements

This commit is contained in:
Dragon Fire
2021-01-13 17:18:36 -05:00
parent 2061cd77f3
commit 01bc9e7a10
8 changed files with 74 additions and 37 deletions
+5 -5
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { decode: decodeHTML } = require('html-entities');
const { MessageEmbed } = require('discord.js');
const { embedURL } = require('../../util/Util');
@@ -23,18 +24,17 @@ module.exports = class DoomsdayClockCommand extends Command {
async run(msg) {
try {
const { text } = await request.get('https://thebulletin.org/doomsday-clock/past-announcements/');
const { text } = await request.get('https://thebulletin.org/doomsday-clock/past-statements/');
const time = text.match(/<h3 class="uabb-infobox-title">(.+)<\/h3>/)[1];
const year = text.match(/<h5 class="uabb-infobox-title-prefix">(.+)<\/h5>/)[1];
const description = text.match(/<div class="uabb-infobox-text uabb-text-editor">.+<p>(.+)<\/p>/)[1]
.replace(/<a href="(.+)" target="_blank" rel="noopener">(.+)<\/a>/, embedURL('$2', '$1'))
.replace(/<em>(.+)<\/em>/i, '_$1_');
const description = text.match(/<div class="uabb-infobox-text uabb-text-editor">(.|\n)+<p>(.+)<\/p>/)[2]
.replace(/<a href="(.+)" target="_blank" rel="noopener">(.+)<\/a>/, embedURL('$2', '$1'));
const embed = new MessageEmbed()
.setTitle(`${year}: ${time}`)
.setColor(0x000000)
.setURL('https://thebulletin.org/doomsday-clock/current-time/')
.setAuthor('Bulletin of the Atomic Scientists', undefined, 'https://thebulletin.org/')
.setDescription(description);
.setDescription(decodeHTML(description));
return msg.embed(embed);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);