starboard: use default embed color by default instead of black

This commit is contained in:
Dragory 2021-04-10 16:30:03 +03:00
parent 5e77976dec
commit 5f3c94d064
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 11 additions and 4 deletions

View file

@ -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<typeof StarboardOpts>;
@ -28,7 +28,7 @@ export const defaultStarboardOpts: Partial<TStarboardOpts> = {
star_emoji: ["⭐"],
enabled: true,
show_star_count: true,
color: 0,
color: null,
};
export interface StarboardPluginType extends BasePluginType {

View file

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