discord-starboard-plus
Version:
Discord Starboard Plus: A clean, maintainable starboard system for Discord.js bots. Features per-guild configuration, TypeScript support. Highlight your community's favorite messages with customizable starboards.
164 lines • 6.09 kB
TypeScript
import type { Client, Message, MessageReaction, PartialMessageReaction, User, PartialUser, PartialMessage, TextChannel, NewsChannel, EmbedBuilder, MessageCreateOptions, ColorResolvable, Snowflake } from 'discord.js';
/**
* Types for event handlers that accept partial objects
*/
export type ReactionEventHandler = (reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser) => Promise<void>;
export type MessageDeleteEventHandler = (message: Message | PartialMessage) => Promise<void>;
/**
* Type for channels that can receive starboard messages
*/
export type StarboardChannel = TextChannel | NewsChannel;
/**
* Configuration options for the Starboard system
*/
export interface StarboardOptions {
/** The emoji used to star messages (default: '⭐') */
starEmoji: string;
/** The ID of the channel where starred messages will be posted */
starboardChannelID: Snowflake;
/** Minimum number of reactions required to post to starboard (default: 1) */
requiredReactions: number;
/** Whether to ignore reactions from bots (default: true) */
ignoreBots: boolean;
/** Whether to ignore self-reactions (author starring their own message) (default: false) */
ignoreSelf: boolean;
/** List of channel IDs to ignore */
ignoredChannels: Snowflake[];
/** List of guild IDs to ignore */
ignoreGuilds: Snowflake[];
/** Whether to update the reaction count when reactions change (default: true) */
updateOnReaction: boolean;
/** Whether to log actions to console (default: true) */
logActions: boolean;
/** Color for the starboard embed (default: 0xFFAC33) */
embedColor: ColorResolvable;
/** Maximum number of attachments to display (default: 4) */
maxAttachments: number;
/** Whether to allow starring messages from NSFW channels (default: false) */
allowNSFW: boolean;
/** Whether to add a "Jump to message" link (default: true) */
jumpToMessage: boolean;
/** Whether to show the message creation date (default: true) */
showMessageDate: boolean;
/** Maximum search depth for finding existing starboard messages (default: 500) */
maxSearchDepth: number;
/** Whether to use Discord's Components V2 format for embeds (default: false) */
useComponentsV2: boolean;
}
/**
* Partial configuration options (all fields optional except starboardChannelID)
*/
export interface StarboardOptionsInput {
starboardChannelID: Snowflake;
starEmoji?: string;
requiredReactions?: number;
ignoreBots?: boolean;
ignoreSelf?: boolean;
ignoredChannels?: Snowflake[];
ignoreGuilds?: Snowflake[];
updateOnReaction?: boolean;
logActions?: boolean;
embedColor?: ColorResolvable;
maxAttachments?: number;
allowNSFW?: boolean;
jumpToMessage?: boolean;
showMessageDate?: boolean;
maxSearchDepth?: number;
useComponentsV2?: boolean;
}
/**
* Per-guild configuration
*/
export interface GuildConfig {
guildId: Snowflake;
options: StarboardOptions;
}
/**
* Starboard message entry tracking
*/
export interface StarboardEntry {
/** ID of the original message that was starred */
originalMessageId: Snowflake;
/** ID of the starboard message */
starboardMessageId: Snowflake;
/** ID of the channel containing the original message */
channelId: Snowflake;
/** ID of the guild */
guildId: Snowflake;
/** Current reaction count */
reactionCount: number;
}
/**
* Result of searching for a starboard message
*/
export interface MessageSearchResult {
found: boolean;
message: Message | null;
searchedCount: number;
}
/**
* Logger options
*/
export interface LoggerOptions {
enabled: boolean;
prefix: string;
}
/**
* Log context for structured logging
*/
export interface LogContext {
[key: string]: string | number | boolean | undefined;
}
/**
* Services injected into handlers
*/
export interface HandlerServices {
logger: Logger;
validation: ValidationService;
embedBuilder: EmbedBuilderService;
messageSearch: MessageSearchService;
guildConfig: GuildConfigManager;
}
/**
* Bound event handlers for cleanup
*/
export interface BoundHandlers {
reactionAdd: ReactionEventHandler;
reactionRemove: ReactionEventHandler;
messageDelete: MessageDeleteEventHandler;
}
/**
* Embed creation result
*/
export interface StarboardEmbedResult {
content: string;
embeds: EmbedBuilder[];
}
export type { Client, Message, MessageReaction, User, TextChannel, NewsChannel, EmbedBuilder, MessageCreateOptions, ColorResolvable, Snowflake };
export interface Logger {
info(message: string, context?: LogContext): void;
success(message: string, context?: LogContext): void;
warn(message: string, context?: LogContext): void;
error(message: string, error?: Error | null, context?: LogContext): void;
}
export interface ValidationService {
shouldProcessReaction(reaction: MessageReaction, user: User, options: StarboardOptions): boolean;
isMessageValid(message: Message, options: StarboardOptions): boolean;
getValidReactionCount(reaction: MessageReaction, options: StarboardOptions): Promise<number>;
getStarboardChannel(guildId: Snowflake, options: StarboardOptions, client: Client): StarboardChannel | null;
}
export interface EmbedBuilderService {
createStarboardEmbed(message: Message, reactionCount: number, options: StarboardOptions): StarboardEmbedResult;
updateReactionCount(currentContent: string, newCount: number): string;
}
export interface MessageSearchService {
findStarboardMessage(channel: StarboardChannel, originalMessageId: Snowflake, maxSearchDepth: number): Promise<MessageSearchResult>;
}
export interface GuildConfigManager {
setGuildConfig(guildId: Snowflake, options: Partial<StarboardOptions>): void;
getGuildConfig(guildId: Snowflake): StarboardOptions;
hasGuildConfig(guildId: Snowflake): boolean;
removeGuildConfig(guildId: Snowflake): boolean;
getDefaultOptions(): StarboardOptions;
}
//# sourceMappingURL=index.d.ts.map