Skip to content

Commit 4a914bd

Browse files
alexemanuelolauuruum
authored andcommitted
Fix raidalarm notification giving invalid thumbnail url
1 parent a2352fb commit 4a914bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/discordTools/discordEmbeds.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ const DiscordTools = require('./discordTools.js');
2626
const InstanceUtils = require('../util/instanceUtils.js');
2727
const Timer = require('../util/timer');
2828

29+
function isValidUrl(url) {
30+
if (url.startsWith('https') || url.startsWith('http')) return true;
31+
return false;
32+
}
33+
2934
module.exports = {
3035
getEmbed: function (options = {}) {
3136
const embed = new Discord.EmbedBuilder();
3237

3338
if (options.hasOwnProperty('title')) embed.setTitle(options.title);
3439
if (options.hasOwnProperty('color')) embed.setColor(options.color);
3540
if (options.hasOwnProperty('description')) embed.setDescription(options.description);
36-
if (options.hasOwnProperty('thumbnail') && options.thumbnail !== '') embed.setThumbnail(options.thumbnail);
41+
if (options.hasOwnProperty('thumbnail') && options.thumbnail !== '' && isValidUrl(options.thumbnail))
42+
embed.setThumbnail(options.thumbnail);
3743
if (options.hasOwnProperty('image')) embed.setImage(options.image);
3844
if (options.hasOwnProperty('url') && options.url !== '') embed.setURL(options.url);
3945
if (options.hasOwnProperty('author')) embed.setAuthor(options.author);

0 commit comments

Comments
 (0)