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!`);
+1 -1
View File
@@ -66,7 +66,7 @@ module.exports = class MayoClinicCommand extends Command {
return {
name: $('h1').first().text().trim(),
url: location,
description: $('p').eq(1).text().trim()
description: $('p[class="caption"]').first().text().trim()
};
}
return location;
+58
View File
@@ -0,0 +1,58 @@
const Command = require('../../structures/Command');
module.exports = class PokedexImageCommand extends Command {
constructor(client) {
super(client, {
name: 'pokedex-image',
aliases: [
'pokemon-image',
'pokémon-image',
'pokédex-image',
'pkmn-image',
'pokedex-img',
'pokémon-img',
'pokemon-img',
'pokédex-img',
'pkmn-img'
],
group: 'search',
memberName: 'pokedex-image',
description: 'Responds with the image of a Pokémon.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Pokémon',
url: 'https://www.pokemon.com/us/',
reason: 'Images, Original Game'
},
{
name: 'PokéAPI',
url: 'https://pokeapi.co/',
reason: 'API'
},
{
name: 'Serebii.net',
url: 'https://www.serebii.net/index2.shtml',
reason: 'Images'
}
],
args: [
{
key: 'pokemon',
prompt: 'What Pokémon would you like to get the image of?',
type: 'string'
}
]
});
}
async run(msg, { pokemon }) {
try {
const data = await this.client.pokemon.fetch(pokemon);
if (!data) return msg.say('Could not find any results.');
return msg.say(`#${data.displayID} - ${data.name}`, { files: [data.spriteImageURL] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+7 -1
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const path = require('path');
const { list } = require('../../util/Util');
const types = ['default', 'moth', 'jojo', 'spoiler'];
const types = ['default', 'moth', 'jojo', 'spoiler', 'nitro'];
module.exports = class DarkLightCommand extends Command {
constructor(client) {
@@ -30,6 +30,12 @@ module.exports = class DarkLightCommand extends Command {
name: 'JoJo\'s Bizzare Adventure',
url: 'http://www.araki-jojo.com/',
reason: 'Original Anime'
},
{
name: 'u/MoonlightCapital',
url: 'https://www.reddit.com/user/MoonlightCapital/',
reason: 'Image',
reasonURL: 'https://www.reddit.com/r/discordapp/comments/a9fr7x/troll_your_friends_with_this/'
}
],
args: [
-27
View File
@@ -1,27 +0,0 @@
const Command = require('../../structures/Command');
const path = require('path');
module.exports = class NitroCommand extends Command {
constructor(client) {
super(client, {
name: 'nitro',
aliases: ['fake-nitro'],
group: 'single',
memberName: 'nitro',
description: 'Sends an image of a fake nitro giveaway.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'u/MoonlightCapital',
url: 'https://www.reddit.com/user/MoonlightCapital/',
reason: 'Image',
reasonURL: 'https://www.reddit.com/r/discordapp/comments/a9fr7x/troll_your_friends_with_this/'
}
]
});
}
run(msg) {
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'nitro.png')] });
}
};