From e691f1c298e6246178c7da067022647809b38386 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 21 Feb 2019 18:07:51 +0000 Subject: [PATCH] Clean NASA HTML --- commands/search/nasa.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commands/search/nasa.js b/commands/search/nasa.js index d850c81a..c58b988e 100644 --- a/commands/search/nasa.js +++ b/commands/search/nasa.js @@ -34,7 +34,7 @@ module.exports = class NASACommand extends Command { const data = images[Math.floor(Math.random() * images.length)]; const embed = new MessageEmbed() .setTitle(data.data[0].title) - .setDescription(shorten(data.data[0].description)) + .setDescription(shorten(this.cleanHTML(data.data[0].description))) .setColor(0x2E528E) .setAuthor('NASA', 'https://i.imgur.com/Wh8jY9c.png', 'https://www.nasa.gov/multimedia/imagegallery/index.html') .setImage(data.links[0].href) @@ -46,4 +46,11 @@ module.exports = class NASACommand extends Command { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } } + + cleanHTML(text) { + return text + .replace(/<\/?b>/g, '**') + .replace(/<\/?i>/g, '*') + .replace(/)?(.+)<\/a>/g, '[$2]($1)'); + } };