mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-13 13:57:18 +00:00
feat: enable coloured starboard embeds
This commit is contained in:
parent
7dcdb5f72f
commit
9ecb98a0d7
3 changed files with 5 additions and 2 deletions
|
@ -12,6 +12,7 @@ const StarboardOpts = t.type({
|
|||
copy_full_embed: tNullable(t.boolean),
|
||||
enabled: tNullable(t.boolean),
|
||||
show_star_count: t.boolean,
|
||||
color: t.number,
|
||||
});
|
||||
export type TStarboardOpts = t.TypeOf<typeof StarboardOpts>;
|
||||
|
||||
|
@ -27,6 +28,7 @@ export const defaultStarboardOpts: Partial<TStarboardOpts> = {
|
|||
star_emoji: ["⭐"],
|
||||
enabled: true,
|
||||
show_star_count: true,
|
||||
color: 0,
|
||||
};
|
||||
|
||||
export interface StarboardPluginType extends BasePluginType {
|
||||
|
|
|
@ -8,7 +8,7 @@ const videoAttachmentExtensions = ["mp4", "mkv", "mov"];
|
|||
|
||||
type StarboardEmbed = EmbedWith<"footer" | "author" | "fields" | "timestamp">;
|
||||
|
||||
export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boolean): StarboardEmbed {
|
||||
export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boolean, color: number): StarboardEmbed {
|
||||
const embed: StarboardEmbed = {
|
||||
footer: {
|
||||
text: `#${(msg.channel as GuildChannel).name}`,
|
||||
|
@ -18,6 +18,7 @@ export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boo
|
|||
},
|
||||
fields: [],
|
||||
timestamp: new Date(msg.timestamp).toISOString(),
|
||||
color: color,
|
||||
};
|
||||
|
||||
if (msg.author.avatarURL) {
|
||||
|
|
|
@ -16,7 +16,7 @@ export async function saveMessageToStarboard(
|
|||
if (!channel) return;
|
||||
|
||||
const starCount = (await pluginData.state.starboardReactions.getAllReactionsForMessageId(msg.id)).length;
|
||||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed));
|
||||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
||||
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
||||
|
||||
const starboardMessage = await (channel as TextChannel).createMessage({ embed });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue