From 5f3c94d06491b66dea1bba0d9f9cf68ec96f0eaa Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 10 Apr 2021 16:30:03 +0300 Subject: [PATCH] starboard: use default embed color by default instead of black --- backend/src/plugins/Starboard/types.ts | 4 ++-- .../Starboard/util/createStarboardEmbedFromMessage.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Starboard/types.ts b/backend/src/plugins/Starboard/types.ts index b2118f55..1fbe3de5 100644 --- a/backend/src/plugins/Starboard/types.ts +++ b/backend/src/plugins/Starboard/types.ts @@ -12,7 +12,7 @@ const StarboardOpts = t.type({ copy_full_embed: tNullable(t.boolean), enabled: tNullable(t.boolean), show_star_count: t.boolean, - color: t.number, + color: tNullable(t.number), }); export type TStarboardOpts = t.TypeOf; @@ -28,7 +28,7 @@ export const defaultStarboardOpts: Partial = { star_emoji: ["⭐"], enabled: true, show_star_count: true, - color: 0, + color: null, }; export interface StarboardPluginType extends BasePluginType { diff --git a/backend/src/plugins/Starboard/util/createStarboardEmbedFromMessage.ts b/backend/src/plugins/Starboard/util/createStarboardEmbedFromMessage.ts index 8ea900e2..9625556c 100644 --- a/backend/src/plugins/Starboard/util/createStarboardEmbedFromMessage.ts +++ b/backend/src/plugins/Starboard/util/createStarboardEmbedFromMessage.ts @@ -8,7 +8,11 @@ const videoAttachmentExtensions = ["mp4", "mkv", "mov"]; type StarboardEmbed = EmbedWith<"footer" | "author" | "fields" | "timestamp">; -export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boolean, color: number): StarboardEmbed { +export function createStarboardEmbedFromMessage( + msg: Message, + copyFullEmbed: boolean, + color?: number | null, +): StarboardEmbed { const embed: StarboardEmbed = { footer: { text: `#${(msg.channel as GuildChannel).name}`, @@ -18,9 +22,12 @@ export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boo }, fields: [], timestamp: new Date(msg.timestamp).toISOString(), - color, }; + if (color != null) { + embed.color = color; + } + if (msg.author.avatarURL) { embed.author.icon_url = msg.author.avatarURL; }