mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Clean NASA HTML
This commit is contained in:
@@ -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 href="(.+)"(?: rel="nofollow">)?(.+)<\/a>/g, '[$2]($1)');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user