From 4eacbeb889cbfd4982e38b4583674f3d49c695ae Mon Sep 17 00:00:00 2001 From: Dragory Date: Sat, 22 Dec 2018 14:42:39 +0200 Subject: [PATCH] starboard: also embed cdn.discordapp.com images --- src/plugins/Starboard.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/Starboard.ts b/src/plugins/Starboard.ts index c205d54e..b0b64b5c 100644 --- a/src/plugins/Starboard.ts +++ b/src/plugins/Starboard.ts @@ -301,7 +301,16 @@ export class StarboardPlugin extends ZeppelinPlugin { } else if (msg.content) { const links = getUrlsInString(msg.content); for (const link of links) { - if (link.hostname === "i.imgur.com") { + const parts = link + .toString() + .replace(/\/$/, "") + .split("."); + const ext = parts[parts.length - 1].toLowerCase(); + + if ( + (link.hostname === "i.imgur.com" || link.hostname === "cdn.discordapp.com") && + ["jpeg", "jpg", "png", "gif", "webp"].includes(ext) + ) { embed.image = { url: link.toString() }; break; }