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.
111 lines • 3.55 kB
TypeScript
import type { Client } from 'discord.js';
import type { StarboardOptions, StarboardOptionsInput, Snowflake } from '../types';
/**
* Main orchestrator for the Starboard system.
*
* Implements clean architecture principles:
* - Dependency injection for all services
* - Proper event listener management (no memory leaks)
* - Per-guild configuration support
*/
export declare class StarboardManager {
private readonly client;
private readonly logger;
private readonly guildConfig;
private readonly validation;
private readonly messageSearch;
private readonly embedBuilder;
private readonly handlers;
/**
* Bound event handlers stored for proper cleanup.
*/
private readonly boundHandlers;
private isDestroyed;
/**
* Create a new StarboardManager instance.
*
* @param client - Discord.js Client instance
* @param options - Starboard configuration options
* @throws Error if client is missing or options are invalid
*/
constructor(client: Client, options: StarboardOptionsInput);
/**
* Create handler instances with injected dependencies.
*/
private createHandlers;
/**
* Attach event listeners to the client.
*/
private attachListeners;
/**
* Wrapper for reaction add handler.
* Handles partial reactions by fetching the full reaction if needed.
*/
private handleReactionAdd;
/**
* Wrapper for reaction remove handler.
* Handles partial reactions by fetching the full reaction if needed.
*/
private handleReactionRemove;
/**
* Wrapper for message delete handler.
* Handles partial messages - note: deleted messages may not be fetchable.
*/
private handleMessageDelete;
/**
* Clean up event listeners and destroy the instance.
* FIX: This method properly removes event listeners, fixing the memory leak.
*/
destroy(): void;
/**
* Check if the manager has been destroyed.
*/
isActive(): boolean;
/**
* Set configuration for a specific guild.
*
* @param guildId - The guild ID
* @param options - Partial options to merge with defaults
*/
setGuildConfig(guildId: Snowflake, options: Partial<StarboardOptions>): void;
/**
* Get configuration for a specific guild.
*
* @param guildId - The guild ID
* @returns The guild's configuration (or defaults if not set)
*/
getGuildConfig(guildId: Snowflake): StarboardOptions;
/**
* Check if a guild has custom configuration.
*
* @param guildId - The guild ID
*/
hasGuildConfig(guildId: Snowflake): boolean;
/**
* Remove custom configuration for a guild.
*
* @param guildId - The guild ID
* @returns true if config was removed, false if it didn't exist
*/
removeGuildConfig(guildId: Snowflake): boolean;
/**
* Get the default options used for guilds without custom config.
*/
getDefaultOptions(): StarboardOptions;
/**
* Update the default options.
* Affects all guilds without custom configuration.
*
* @param options - Partial options to merge with current defaults
*/
updateDefaultOptions(options: Partial<StarboardOptions>): void;
/**
* Get list of guilds with custom configuration.
*/
getConfiguredGuilds(): Snowflake[];
/**
* Get number of guilds with custom configuration.
*/
getConfiguredGuildCount(): number;
}
//# sourceMappingURL=StarboardManager.d.ts.map