starboard: also embed cdn.discordapp.com images

This commit is contained in:
Dragory 2018-12-22 14:42:39 +02:00
parent e2c57f8057
commit 4eacbeb889

View file

@ -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;
}