feat: add color option to starboard (#163)
Co-authored-by: Almeida <42935195+almeidx@users.noreply.github.com>
This commit is contained in:
parent
2e50fa7630
commit
fcbb25b7ff
4 changed files with 18 additions and 2 deletions
|
@ -57,6 +57,19 @@ export const StarboardPlugin = zeppelinGuildPlugin<StarboardPluginType>()("starb
|
||||||
stars_required: 5
|
stars_required: 5
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
### Basic starboard with custom color
|
||||||
|
Any message on the server that gets 5 star reactions will be posted into the starboard channel (604342689038729226), with the given color (0x87CEEB).
|
||||||
|
|
||||||
|
~~~yml
|
||||||
|
starboard:
|
||||||
|
config:
|
||||||
|
boards:
|
||||||
|
basic:
|
||||||
|
channel_id: "604342689038729226"
|
||||||
|
stars_required: 5
|
||||||
|
color: 0x87CEEB
|
||||||
|
~~~
|
||||||
|
|
||||||
### Custom star emoji
|
### Custom star emoji
|
||||||
This is identical to the basic starboard above, but accepts two emoji: the regular star and a custom :mrvnSmile: emoji
|
This is identical to the basic starboard above, but accepts two emoji: the regular star and a custom :mrvnSmile: emoji
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ const StarboardOpts = t.type({
|
||||||
copy_full_embed: tNullable(t.boolean),
|
copy_full_embed: tNullable(t.boolean),
|
||||||
enabled: tNullable(t.boolean),
|
enabled: tNullable(t.boolean),
|
||||||
show_star_count: t.boolean,
|
show_star_count: t.boolean,
|
||||||
|
color: t.number,
|
||||||
});
|
});
|
||||||
export type TStarboardOpts = t.TypeOf<typeof StarboardOpts>;
|
export type TStarboardOpts = t.TypeOf<typeof StarboardOpts>;
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ export const defaultStarboardOpts: Partial<TStarboardOpts> = {
|
||||||
star_emoji: ["⭐"],
|
star_emoji: ["⭐"],
|
||||||
enabled: true,
|
enabled: true,
|
||||||
show_star_count: true,
|
show_star_count: true,
|
||||||
|
color: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface StarboardPluginType extends BasePluginType {
|
export interface StarboardPluginType extends BasePluginType {
|
||||||
|
|
|
@ -8,7 +8,7 @@ const videoAttachmentExtensions = ["mp4", "mkv", "mov"];
|
||||||
|
|
||||||
type StarboardEmbed = EmbedWith<"footer" | "author" | "fields" | "timestamp">;
|
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 = {
|
const embed: StarboardEmbed = {
|
||||||
footer: {
|
footer: {
|
||||||
text: `#${(msg.channel as GuildChannel).name}`,
|
text: `#${(msg.channel as GuildChannel).name}`,
|
||||||
|
@ -18,6 +18,7 @@ export function createStarboardEmbedFromMessage(msg: Message, copyFullEmbed: boo
|
||||||
},
|
},
|
||||||
fields: [],
|
fields: [],
|
||||||
timestamp: new Date(msg.timestamp).toISOString(),
|
timestamp: new Date(msg.timestamp).toISOString(),
|
||||||
|
color,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (msg.author.avatarURL) {
|
if (msg.author.avatarURL) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function saveMessageToStarboard(
|
||||||
if (!channel) return;
|
if (!channel) return;
|
||||||
|
|
||||||
const starCount = (await pluginData.state.starboardReactions.getAllReactionsForMessageId(msg.id)).length;
|
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));
|
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
||||||
|
|
||||||
const starboardMessage = await (channel as TextChannel).createMessage({ embed });
|
const starboardMessage = await (channel as TextChannel).createMessage({ embed });
|
||||||
|
|
Loading…
Add table
Reference in a new issue