seedcord 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +14 -17
  2. package/dist/index.d.mts +0 -1019
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "seedcord",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.1",
5
5
  "description": "A Discord bot framework built on top of Discord.js",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/materwelondhruv/seedcord.git",
9
9
  "directory": "packages/seedcord"
10
10
  },
11
+ "types": "./dist/index.d.ts",
11
12
  "exports": {
12
13
  ".": {
13
- "import": {
14
- "types": "./dist/index.d.mts",
15
- "default": "./dist/index.mjs"
16
- },
17
- "require": {
18
- "types": "./dist/index.d.cts",
19
- "default": "./dist/index.cjs"
20
- }
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.cjs",
17
+ "default": "./dist/index.mjs"
21
18
  }
22
19
  },
23
20
  "files": [
@@ -27,24 +24,24 @@
27
24
  "LICENSE"
28
25
  ],
29
26
  "peerDependencies": {
30
- "typescript": "5.9.2"
27
+ "typescript": "5.9.3"
31
28
  },
32
29
  "dependencies": {
33
30
  "chalk": "5.6.2",
34
31
  "discord.js": "14.22.1",
35
32
  "envapt": "3.0.2",
36
33
  "reflect-metadata": "0.2.2",
37
- "@seedcord/types": "^0.1.4",
38
- "@seedcord/utils": "0.1.1",
39
- "@seedcord/services": "0.1.1"
34
+ "@seedcord/types": "^0.2.1",
35
+ "@seedcord/utils": "0.2.1",
36
+ "@seedcord/services": "0.2.1"
40
37
  },
41
38
  "devDependencies": {
42
- "@seedcord/eslint-config": "^1.1.2",
43
- "@seedcord/tsconfig": "^1.0.3",
44
- "@seedcord/tsup-config": "^1.0.3"
39
+ "@seedcord/tsconfig": "^1.0.4",
40
+ "@seedcord/eslint-config": "^1.2.1",
41
+ "@seedcord/tsup-config": "^1.0.4"
45
42
  },
46
43
  "scripts": {
47
- "build": "tsup && cp dist/index.d.cts dist/index.d.mts",
44
+ "build": "tsup",
48
45
  "clean": "rm -rf dist",
49
46
  "lint": "eslint 'src/**/*.{ts,tsx}' --cache",
50
47
  "lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix --cache",
package/dist/index.d.mts DELETED
@@ -1,1019 +0,0 @@
1
- import { Logger, CoordinatedShutdown, CoordinatedStartup, StartupPhase } from '@seedcord/services';
2
- export * from '@seedcord/services';
3
- import { ClientOptions, Guild, User, SlashCommandBuilder, ContextMenuCommandBuilder, Collection, Client, ChatInputCommandInteraction, ButtonInteraction, ModalSubmitInteraction, AutocompleteInteraction, AnySelectMenuInteraction, ContextMenuCommandInteraction, ClientEvents, Events, AutocompleteFocusedOption, EmbedBuilder, ButtonBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, UserSelectMenuBuilder, ChannelSelectMenuBuilder, MentionableSelectMenuBuilder, RoleSelectMenuBuilder, ModalBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, ContainerBuilder, TextDisplayBuilder, FileBuilder, MediaGalleryBuilder, SectionBuilder, SeparatorBuilder, ActionRowBuilder, TextInputBuilder, WebhookClient } from 'discord.js';
4
- import { Nullable, Tail, TypedConstructor, ConstructorFunction } from '@seedcord/types';
5
- export * from '@seedcord/types';
6
- import { UUID } from 'crypto';
7
- export * from '@seedcord/utils';
8
-
9
- /**
10
- * Djs Interactions handlers
11
- */
12
- interface InteractionsConfig {
13
- /**
14
- * Path to dir containing interaction handlers.
15
- */
16
- path: string;
17
- ignoreCustomIds?: string[];
18
- }
19
- /**
20
- * Djs Events handlers
21
- */
22
- interface EventsConfig {
23
- /**
24
- * Path to dir containing event handlers.
25
- */
26
- path: string;
27
- }
28
- /**
29
- * Djs SlashCommands and ContextMenuCommands
30
- */
31
- interface CommandsConfig {
32
- /**
33
- * Path to dir containing commands and context menus to register.
34
- */
35
- path: string;
36
- }
37
- /**
38
- * Application side effects configuration
39
- */
40
- interface EffectsConfig {
41
- /**
42
- * Path to dir of user defined side effects.
43
- */
44
- path: string;
45
- }
46
- /**
47
- * Discord bot configuration
48
- */
49
- interface BotConfig {
50
- interactions: InteractionsConfig;
51
- events: EventsConfig;
52
- commands: CommandsConfig;
53
- /**
54
- * Discord.js ClientOptions passed directly to the Client constructor
55
- */
56
- clientOptions: ClientOptions;
57
- /**
58
- * Optional emoji mappings. Pass an object with emojis mappings (e.g. below). These emojis will be loaded from the Application Emojis that you've uploaded via the Dev-Dashboard
59
- *
60
- * Key: The name of the object key you want to use in your codebase
61
- *
62
- * Value: The emoji identifier used in Discord
63
- *
64
- * @example
65
- * ```ts
66
- * const Emojis = {
67
- * ThumbsUp: 'thumbsup',
68
- * ThumbsDown: 'thumbsdown',
69
- * Lol: 'lol_1',
70
- * Kek: 'keklmao',
71
- * };
72
- * ```
73
- *
74
- * will turn into
75
- *
76
- * @example
77
- * ```ts
78
- * const Emojis = {
79
- * ThumbsUp: '<:thumbsup:1872389747982323423>',
80
- * ThumbsDown: '<:thumbsdown:1872389747982323424>',
81
- * Lol: '<:lol_1:1872389747982323425>',
82
- * Kek: '<a:keklmao:1872389747982323426>',
83
- * };
84
- * ```
85
- */
86
- emojis?: Record<string, string>;
87
- /**
88
- * Whether to show the error stack trace in the terminal in errors caught by the `@Catchable` decorator
89
- *
90
- * `false` by default
91
- */
92
- errorStack?: boolean;
93
- }
94
- /** Main configuration object for Seedcord bot */
95
- interface Config {
96
- bot: BotConfig;
97
- effects: EffectsConfig;
98
- }
99
-
100
- /**
101
- * Default side effects that are always available in the framework.
102
- */
103
- interface DefaultEffects {
104
- /** Triggered when an unhandled exception occurs */
105
- unknownException: {
106
- uuid: UUID;
107
- error: Error;
108
- guild: Nullable<Guild>;
109
- user: Nullable<User>;
110
- };
111
- }
112
- /**
113
- * Custom side effects defined by the application.
114
- *
115
- * This interface can be augmented via declaration merging to add
116
- * type-safe custom effect definitions for emitting custom side effects anywhere in the application.
117
- *
118
- * @example
119
- * ```typescript
120
- * declare module 'seedcord' {
121
- * interface Effects {
122
- * 'userJoin': { user: User; guild: Guild };
123
- * 'levelUp': { user: User; level: number; guild: Guild };
124
- * }
125
- * }
126
- * ```
127
- */
128
- interface Effects {
129
- }
130
- /**
131
- * Combined effects interface containing both default and custom side effects.
132
- */
133
- interface AllEffects extends DefaultEffects, Effects {
134
- }
135
- /**
136
- * Helper type to extract all available effect event names.
137
- */
138
- type EffectKeys = keyof AllEffects;
139
- /**
140
- * Helper type to get parameters for a specific effect event.
141
- *
142
- * @typeParam KeyOfEffects - The effect event name
143
- */
144
- type EffectParams<KeyOfEffects extends EffectKeys> = AllEffects[KeyOfEffects];
145
-
146
- /**
147
- * Manages application effects and event handling
148
- *
149
- * Provides a centralized system for registering and executing custom effects
150
- * throughout the application lifecycle. Effects are loaded from configured directories
151
- * and can be triggered programmatically or by framework events.
152
- *
153
- * @internal Accessed via core.effects, not directly instantiated
154
- */
155
- declare class EffectsRegistry extends Plugin {
156
- protected core: Core;
157
- readonly logger: Logger;
158
- private isInitialized;
159
- private readonly effectsMap;
160
- private readonly emitter;
161
- constructor(core: Core);
162
- init(): Promise<void>;
163
- private loadEffects;
164
- private registerEffect;
165
- private isEffectHandler;
166
- private attachEffects;
167
- emit<KeyOfEffects extends EffectKeys>(event: KeyOfEffects, data: AllEffects[KeyOfEffects]): boolean;
168
- }
169
-
170
- /** Base interface defining core Seedcord functionality */
171
- interface BaseCore {
172
- readonly bot: Bot;
173
- readonly effects: EffectsRegistry;
174
- readonly shutdown: CoordinatedShutdown;
175
- readonly startup: CoordinatedStartup;
176
- readonly config: Config;
177
- start(): Promise<this>;
178
- }
179
- /**
180
- * Main interface for Seedcord core functionality
181
- *
182
- * This interface can be augmented via declaration merging to add
183
- * type-safe plugin definitions when using `this.core#` in handlers.
184
- *
185
- * Only add classes that extend {@link Plugin} to this
186
- *
187
- * @example
188
- * ```typescript
189
- * declare module 'seedcord' {
190
- * interface Core {
191
- * db: Mongo;
192
- * }
193
- * }
194
- * ```
195
- * */
196
- interface Core extends BaseCore {
197
- }
198
-
199
- /** Interface for objects that can be initialized asynchronously */
200
- interface Initializeable {
201
- init(): Promise<void>;
202
- }
203
- /**
204
- * Base class for Seedcord plugins
205
- *
206
- * Extend this class to create plugins that integrate with the Seedcord lifecycle.
207
- * Plugins have access to the core instance and must implement initialization logic.
208
- */
209
- declare abstract class Plugin implements Initializeable {
210
- protected pluggable: Core;
211
- /** Logger instance for this plugin - must be implemented by subclasses */
212
- abstract logger: Logger;
213
- constructor(pluggable: Core);
214
- /**
215
- * Initialize the plugin - implement setup logic here
216
- * @virtual Override this method in your plugin classes
217
- */
218
- abstract init(): Promise<void>;
219
- }
220
- /**
221
- * Constructor type for plugins that can accept additional arguments after Core
222
- * @param TPlugin - The plugin type being constructed
223
- */
224
- type PluginCtor<TPlugin extends Plugin = Plugin> = new (core: Core, ...args: any[]) => TPlugin;
225
- /**
226
- * Extracts the argument types for a plugin constructor (excluding the Core parameter)
227
- * @param Ctor - The plugin constructor to extract arguments from
228
- */
229
- type PluginArgs<Ctor extends PluginCtor> = Tail<ConstructorParameters<Ctor>>;
230
- /**
231
- * Base class for objects that can have plugins attached
232
- *
233
- * Provides plugin attachment capabilities and lifecycle management.
234
- * Plugins are attached during configuration and initialized during startup.
235
- */
236
- declare class Pluggable {
237
- protected isInitialized: boolean;
238
- protected readonly shutdown: CoordinatedShutdown;
239
- protected readonly startup: CoordinatedStartup;
240
- private static readonly PLUGIN_INIT_TIMEOUT_MS;
241
- constructor(shutdown: CoordinatedShutdown, startup: CoordinatedStartup);
242
- protected init(): Promise<this>;
243
- /**
244
- * Attaches a plugin to this instance
245
- *
246
- * Plugins provide external functionality and are initialized during the specified startup phase.
247
- * The plugin instance becomes available as a property in `core` wherever it's available.
248
- *
249
- * Make sure to augment the {@link Core} interface with the plugin type to ensure TypeScript recognizes it and provides intellisense.
250
- *
251
- * @typeParam Key - The property name for accessing the plugin
252
- * @typeParam Ctor - The plugin constructor type
253
- * @param key - Property name to access the plugin instance
254
- * @param Plugin - Plugin constructor class
255
- * @param startupPhase - When during startup to initialize this plugin ({@link StartupPhase})
256
- * @param args - Additional arguments to pass to the plugin constructor
257
- * @returns This instance with the plugin attached as a typed property
258
- * @throws An {@link Error} When called after initialization or if key already exists
259
- * @example
260
- * ```typescript
261
- * seedcord.attach('db', Mongo, StartupPhase.Configuration, { uri: 'mongodb://...', name: 'seedcord', dir: ... })
262
- * ```
263
- */
264
- attach<Key extends string, Ctor extends PluginCtor>(this: this, key: Key, Plugin: Ctor, startupPhase: StartupPhase, ...args: PluginArgs<Ctor>): this & Record<Key, InstanceType<Ctor>>;
265
- }
266
-
267
- /**
268
- * Manages Discord application command registration and deployment.
269
- *
270
- * Scans command directories, builds command structures, and handles both
271
- * global and guild-specific command deployment to Discord's API.
272
- *
273
- * @internal
274
- */
275
- declare class CommandRegistry implements Initializeable {
276
- private readonly core;
277
- private readonly logger;
278
- private isInitialised;
279
- readonly globalCommands: (SlashCommandBuilder | ContextMenuCommandBuilder)[];
280
- readonly guildCommands: Collection<string, (SlashCommandBuilder | ContextMenuCommandBuilder)[]>;
281
- constructor(core: Core);
282
- init(): Promise<void>;
283
- private loadCommands;
284
- private isCommandClass;
285
- private registerCommand;
286
- setCommands(): Promise<void>;
287
- }
288
-
289
- /**
290
- * Discord bot implementation that manages client and controllers
291
- * @internal - Accessed via core.bot, not directly instantiated by users
292
- */
293
- declare class Bot extends Plugin {
294
- protected core: Core;
295
- readonly botToken: string;
296
- readonly logger: Logger;
297
- private isInitialized;
298
- private readonly _client;
299
- private readonly interactions;
300
- private readonly events;
301
- readonly commands: CommandRegistry;
302
- private readonly emojiInjector;
303
- /**
304
- * @param core - Seedcord core instance
305
- * @internal
306
- */
307
- constructor(core: Core);
308
- /**
309
- * Initializes Discord client and all controllers
310
- * @internal
311
- */
312
- init(): Promise<void>;
313
- /**
314
- * Stops the bot and cleans up connections
315
- * @internal
316
- */
317
- stop(): Promise<void>;
318
- /**
319
- * Logs the bot into Discord using the configured token
320
- */
321
- private login;
322
- /**
323
- * Logs out and destroys the Discord client connection
324
- */
325
- private logout;
326
- get client(): Client;
327
- }
328
-
329
- /**
330
- * Main Seedcord bot framework class
331
- *
332
- * Primary entry point for creating Discord bots with Seedcord.
333
- * Manages component lifecycle and provides plugin support.
334
- */
335
- declare class Seedcord extends Pluggable implements Core {
336
- readonly config: Config;
337
- private static isInstantiated;
338
- /** @see {@link CoordinatedShutdown} */
339
- readonly shutdown: CoordinatedShutdown;
340
- /** @see {@link CoordinatedStartup} */
341
- readonly startup: CoordinatedStartup;
342
- /** @see {@link EffectsRegistry} */
343
- readonly effects: EffectsRegistry;
344
- /** @see {@link Bot} */
345
- readonly bot: Bot;
346
- /** @see {@link HealthCheck} */
347
- private readonly healthCheck;
348
- /**
349
- * Creates a new Seedcord instance
350
- *
351
- * @param config - Bot configuration including paths and Discord client options
352
- * @throws An {@link Error} When attempting to create multiple instances (singleton)
353
- */
354
- constructor(config: Config);
355
- /**
356
- * Registers default startup tasks
357
- * @internal
358
- */
359
- private registerStartupTasks;
360
- /**
361
- * Starts the bot and runs all initialization tasks
362
- *
363
- * @returns This Seedcord instance when fully initialized
364
- */
365
- start(): Promise<this>;
366
- }
367
-
368
- /** All valid Discord.js interaction types that can be handled */
369
- type ValidInteractionTypes = ChatInputCommandInteraction | ButtonInteraction | ModalSubmitInteraction | AutocompleteInteraction | AnySelectMenuInteraction | ContextMenuCommandInteraction;
370
- /** All valid Discord.js client events except interaction events */
371
- type ValidNonInteractionTypes = ClientEvents[Exclude<keyof ClientEvents, Events.InteractionCreate>];
372
- /** All event types that can be handled (interactions and client events) */
373
- type ValidEventTypes = ValidInteractionTypes | ValidNonInteractionTypes;
374
- /** Interaction types that can receive replies (excludes autocomplete) */
375
- type Repliables = Exclude<ValidInteractionTypes, AutocompleteInteraction>;
376
- /** Handler types that can reply to interactions */
377
- type RepliableInteractionHandler = InteractionHandler<Repliables> | InteractionMiddleware<Repliables>;
378
- /** Base interface for event handlers */
379
- interface Handler {
380
- execute(): Promise<void>;
381
- }
382
- /**
383
- * Interface for handlers that can run pre-execution checks
384
- *
385
- * Should always accompany the `@Catchable` decorator. Will require the class to implement the `runChecks` method.
386
- *
387
- * @see {@link Checkable}
388
- */
389
- interface WithChecks {
390
- /**
391
- * Runs pre-execution checks for the handler.
392
- *
393
- * @remarks It'll be called automatically if a class is decorated with {@link Checkable} before the execute method.
394
- *
395
- * @virtual Override this method in your handler classes
396
- */
397
- runChecks(): Promise<void>;
398
- }
399
- interface HandlerWithChecks extends WithChecks, Handler {
400
- }
401
- declare abstract class BaseHandler<ValidEvent extends ValidEventTypes> implements Handler {
402
- core: Core;
403
- protected checkable: boolean;
404
- protected break: boolean;
405
- protected errored: boolean;
406
- protected event: ValidEvent;
407
- protected args: string[];
408
- protected constructor(event: ValidEvent, core: Core, args?: string[]);
409
- /**
410
- * Main handler logic - implement this method to define behavior
411
- * @virtual Override this method in your handler classes
412
- */
413
- abstract execute(): Promise<void>;
414
- hasChecks(): this is HandlerWithChecks;
415
- hasErrors(): boolean;
416
- setErrored(): void;
417
- shouldBreak(): boolean;
418
- getEvent(): ValidEvent;
419
- /**
420
- * Gets arguments parsed from interaction customId
421
- *
422
- * Arguments are extracted from customId using ":" and "-" separators.
423
- * For customId "accept:user123-guild456", returns ["user123", "guild456"]
424
- */
425
- protected getArgs(): string[];
426
- /**
427
- * Gets a specific argument by index from parsed customId
428
- * @param index - Zero-based index of the argument to retrieve
429
- * @returns The argument at the specified index, or undefined if not found
430
- */
431
- protected getArg(index: number): string | undefined;
432
- }
433
- /**
434
- * Base class for Discord interaction handlers
435
- *
436
- * Extend this class to handle slash commands, buttons, modals, and select menus.
437
- * Use decorators like \@SlashRoute, \@ButtonRoute, etc. to define routing.
438
- *
439
- * @typeParam Repliable - The interaction type this handler processes
440
- */
441
- declare abstract class InteractionHandler<Repliable extends Repliables> extends BaseHandler<Repliable> implements Handler {
442
- constructor(event: Repliable, core: Core, args?: string[]);
443
- }
444
- /**
445
- * Base class for interaction middleware
446
- *
447
- * Middleware runs before interaction handlers and can modify behavior or block execution.
448
- * Unlike handlers, middleware should not send responses directly.
449
- *
450
- * @typeParam Repliable - The interaction type this middleware processes
451
- */
452
- declare abstract class InteractionMiddleware<Repliable extends Repliables> extends BaseHandler<Repliable> implements Handler {
453
- constructor(event: Repliable, core: Core, args?: string[]);
454
- }
455
- /**
456
- * Handler for Discord autocomplete interactions
457
- *
458
- * Extend this class to provide autocomplete suggestions for slash command options.
459
- * The focused option is automatically available via the `focused` property.
460
- */
461
- declare abstract class AutocompleteHandler extends BaseHandler<AutocompleteInteraction> implements Handler {
462
- /** The currently focused autocomplete option (Based on what you set in \@AutocompleteRoute) */
463
- protected readonly focused: AutocompleteFocusedOption;
464
- constructor(event: AutocompleteInteraction, core: Core, args?: string[]);
465
- }
466
- /**
467
- * Base class for Discord client event handlers
468
- *
469
- * Extend this class to handle Discord events like messageCreate, guildMemberAdd, etc.
470
- * Use the \@EventRegisterable decorator to specify which event to listen for.
471
- *
472
- * @typeParam Repliable - The Discord event type this handler processes
473
- */
474
- declare abstract class EventHandler<Repliable extends keyof ClientEvents> extends BaseHandler<ClientEvents[Repliable]> implements Handler {
475
- constructor(event: ClientEvents[Repliable], core: Core, args?: string[]);
476
- }
477
- /** Constructor type for interaction and autocomplete handlers */
478
- type HandlerConstructor = TypedConstructor<typeof InteractionHandler | typeof AutocompleteHandler>;
479
- /** Constructor type for interaction middleware */
480
- type MiddlewareConstructor = TypedConstructor<typeof InteractionMiddleware> & (new (event: Repliables, core: Core, args?: string[]) => InteractionMiddleware<Repliables>);
481
- /** Constructor type for autocomplete handlers */
482
- type AutocompleteHandlerConstructor = TypedConstructor<typeof AutocompleteHandler> & (new (event: AutocompleteInteraction, core: Core, args?: string[]) => AutocompleteHandler);
483
- /** Constructor type for Discord client event handlers */
484
- type EventHandlerConstructor = TypedConstructor<typeof EventHandler>;
485
-
486
- type HandlerCtor = new (...args: any[]) => Handler;
487
- /**
488
- * Marks a handler class as requiring check execution.
489
- *
490
- * Enables the runChecks() method to be called before execute()
491
- * for handlers that need pre-execution validation.
492
- *
493
- * @param ctor - The handler to mark as checkable (Do not pass this directly. Just call the decorator without a **()**)
494
- * @decorator
495
- * @example
496
- * ```typescript
497
- * \@Checkable
498
- * class AdminCommand extends InteractionHandler {
499
- * async runChecks() {
500
- * // Perform admin permission checks
501
- * }
502
- * }
503
- * ```
504
- */
505
- declare function Checkable<TypeHandler extends HandlerCtor>(ctor: TypeHandler): TypeHandler;
506
-
507
- /**
508
- * Configuration options for the Catchable decorator.
509
- */
510
- interface CatchableOptions {
511
- /** Whether to log errors to console (default: false) */
512
- log?: boolean;
513
- /** Always use followUp instead of reply/editReply (default: false) */
514
- forceFollowup?: boolean;
515
- }
516
- /**
517
- * Catches and handles errors in interaction handler methods
518
- *
519
- * Automatically sends error responses to users and prevents uncaught exceptions.
520
- * Should be applied to the execute() or runChecks() methods of interaction handlers.
521
- *
522
- * @param options - Configuration for error handling behavior
523
- * @decorator
524
- * @example
525
- * ```typescript
526
- * class MyHandler extends InteractionHandler {
527
- * \@Catchable({ log: true })
528
- * async execute() {
529
- * // method implementation
530
- * }
531
- * }
532
- * ```
533
- */
534
- declare function Catchable(options?: CatchableOptions): (_target: RepliableInteractionHandler, _propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<void>>) => void;
535
-
536
- declare const BuilderTypes: {
537
- command: typeof SlashCommandBuilder;
538
- embed: typeof EmbedBuilder;
539
- button: typeof ButtonBuilder;
540
- menu_string: typeof StringSelectMenuBuilder;
541
- menu_option_string: typeof StringSelectMenuOptionBuilder;
542
- menu_user: typeof UserSelectMenuBuilder;
543
- menu_channel: typeof ChannelSelectMenuBuilder;
544
- menu_mentionable: typeof MentionableSelectMenuBuilder;
545
- menu_role: typeof RoleSelectMenuBuilder;
546
- modal: typeof ModalBuilder;
547
- context_menu: typeof ContextMenuCommandBuilder;
548
- subcommand: typeof SlashCommandSubcommandBuilder;
549
- group: typeof SlashCommandSubcommandGroupBuilder;
550
- container: typeof ContainerBuilder;
551
- text_display: typeof TextDisplayBuilder;
552
- file: typeof FileBuilder;
553
- media: typeof MediaGalleryBuilder;
554
- section: typeof SectionBuilder;
555
- separator: typeof SeparatorBuilder;
556
- };
557
- declare const RowTypes: {
558
- button: typeof ActionRowBuilder<ButtonBuilder>;
559
- menu_string: typeof ActionRowBuilder<StringSelectMenuBuilder>;
560
- menu_user: typeof ActionRowBuilder<UserSelectMenuBuilder>;
561
- menu_channel: typeof ActionRowBuilder<ChannelSelectMenuBuilder>;
562
- menu_mentionable: typeof ActionRowBuilder<MentionableSelectMenuBuilder>;
563
- menu_role: typeof ActionRowBuilder<RoleSelectMenuBuilder>;
564
- modal: typeof ActionRowBuilder<ModalActionRowComponentBuilder>;
565
- };
566
- declare const ModalTypes: {
567
- text: typeof TextInputBuilder;
568
- };
569
- type BuilderType = keyof typeof BuilderTypes;
570
- type InstantiatedBuilder<BuilderKey extends BuilderType> = InstanceType<(typeof BuilderTypes)[BuilderKey]>;
571
- type ActionRowComponentType = keyof typeof RowTypes;
572
- type InstantiatedActionRow<RowKey extends ActionRowComponentType> = InstanceType<(typeof RowTypes)[RowKey]>;
573
- type ModalFieldTypes = keyof typeof ModalTypes;
574
- type InstantiatedModalField<ModalKey extends ModalFieldTypes> = InstanceType<(typeof ModalTypes)[ModalKey]>;
575
- /**
576
- * Base class for Discord component wrappers
577
- *
578
- * Provides common functionality for building Discord components with proper typing.
579
- *
580
- * @typeParam TComponent - The Discord.js component type being wrapped
581
- */
582
- declare abstract class BaseComponent<TComponent> {
583
- private readonly _component;
584
- protected constructor(ComponentClass: new () => TComponent);
585
- /**
586
- * Gets the built component (should be considered read-only)
587
- *
588
- * Returns the finalized component ready for use in Discord messages.
589
- *
590
- * Please do not use for further configuration, use `this.instance` for that.
591
- * @example new SomeComponent().component
592
- */
593
- abstract get component(): InstantiatedBuilder<BuilderType> | InstantiatedActionRow<ActionRowComponentType>;
594
- /**
595
- * Gets the component instance for configuration
596
- *
597
- * Use this to access Discord.js builder methods like setTitle(), setDescription(), etc.
598
- *
599
- * Use this in your component classes to configure the builder
600
- * @example this.instance.setTitle('My Modal')
601
- */
602
- protected get instance(): TComponent;
603
- /**
604
- * Builds a customId string for interactive components
605
- *
606
- * Creates customIds in the format "prefix:arg1-arg2-arg3" for buttons, modals, etc.
607
- * Arguments are joined with hyphens and separated from prefix with a colon.
608
- *
609
- * @param prefix - The route prefix that handlers will match against
610
- * @param args - Additional arguments to encode in the customId
611
- * @returns Formatted customId string
612
- */
613
- buildCustomId(prefix: string, ...args: string[]): string;
614
- }
615
- /**
616
- * Base class for Discord.js builder components
617
- *
618
- * Wraps Discord.js builders (SlashCommandBuilder, EmbedBuilder, etc.) with
619
- * Seedcord-specific defaults and helper methods.
620
- *
621
- * @typeParam BuilderKey - The type of Discord.js builder being wrapped
622
- */
623
- declare abstract class BuilderComponent<BuilderKey extends BuilderType> extends BaseComponent<InstantiatedBuilder<BuilderKey>> {
624
- private readonly botColor;
625
- protected constructor(type: BuilderKey);
626
- get component(): InstantiatedBuilder<BuilderKey>;
627
- }
628
- /**
629
- * Base class for Discord action row components
630
- *
631
- * Wraps Discord.js action row builder with Seedcord-specific defaults and helper methods.
632
- *
633
- * @typeParam RowKey - The Discord.js action row type being wrapped
634
- */
635
- declare abstract class RowComponent<RowKey extends ActionRowComponentType> extends BaseComponent<InstantiatedActionRow<RowKey>> {
636
- protected constructor(type: RowKey);
637
- get component(): InstantiatedActionRow<RowKey>;
638
- }
639
- /**
640
- * Base class for modal field components
641
- *
642
- * Wraps Discord.js modal field builders (TextInputBuilder, etc.) and
643
- * packages them in action rows for use in modals.
644
- *
645
- * @typeParam ModalKey - The type of modal field builder being wrapped
646
- */
647
- declare abstract class ModalComponent<ModalKey extends ModalFieldTypes> extends BaseComponent<InstantiatedModalField<ModalKey>> {
648
- protected constructor(type: ModalKey);
649
- get component(): InstantiatedActionRow<'modal'>;
650
- }
651
- /**
652
- * Pre-configured error embed with default styling
653
- *
654
- * This is bundled in {@link CustomError}s as the response.
655
- */
656
- declare class BaseErrorEmbed extends BuilderComponent<'embed'> {
657
- /**
658
- * Creates a new error embed with default configuration.
659
- */
660
- constructor();
661
- }
662
- /**
663
- * Base class for custom error types with Discord embed responses
664
- *
665
- * Errors extending CustomError should be used with the `Catchable` decorators to implement a control flow. These errors will be caught and handled by the framework to show the user the configured response.
666
- */
667
- declare abstract class CustomError extends Error {
668
- message: string;
669
- private _emit;
670
- readonly response: EmbedBuilder;
671
- protected constructor(message: string);
672
- /**
673
- * Whether this error should be emitted to logs
674
- *
675
- * Controls logging behavior. Errors with emit=true will always be logged,
676
- * while emit=false errors may be suppressed in production.
677
- *
678
- * @returns True if the error should be logged
679
- */
680
- get emit(): boolean;
681
- /**
682
- * Sets whether this error should be emitted to logs
683
- *
684
- * @see {@link emit}
685
- */
686
- set emit(value: boolean);
687
- }
688
- /** Constructor type for custom error classes */
689
- type CustomErrorConstructor = new (message: string, ...args: any[]) => CustomError;
690
-
691
- declare const CommandMetadataKey: unique symbol;
692
- type CommandCtor = new (...args: any[]) => BuilderComponent<'command' | 'context_menu'>;
693
- /**
694
- * Metadata for global command registration.
695
- */
696
- interface GlobalMeta {
697
- scope: 'global';
698
- }
699
- /**
700
- * Metadata for guild-specific command registration.
701
- */
702
- interface GuildMeta {
703
- scope: 'guild';
704
- guilds: string[];
705
- }
706
- /**
707
- * Union type for command registration metadata.
708
- */
709
- type CommandMeta = GlobalMeta | GuildMeta;
710
- /**
711
- * Registers a command for global deployment.
712
- *
713
- * @param scope - Must be 'global' for global registration
714
- * @decorator
715
- * @example
716
- * ```typescript
717
- * \@RegisterCommand('global')
718
- * class PingCommand extends BuilderComponent {
719
- * // Global command
720
- * }
721
- * ```
722
- */
723
- declare function RegisterCommand(scope: 'global'): (ctor: CommandCtor) => void;
724
- /**
725
- * Registers a command for specific guild deployment.
726
- *
727
- * @param scope - Must be 'guild' for guild-specific registration
728
- * @param guilds - Array of guild IDs where the command should be registered
729
- * @decorator
730
- * @example
731
- * ```typescript
732
- * \@RegisterCommand('guild', ['123456789'])
733
- * class AdminCommand extends BuilderComponent {
734
- * // Guild-specific command
735
- * }
736
- * ```
737
- */
738
- declare function RegisterCommand(scope: 'guild', guilds: string[]): (ctor: CommandCtor) => void;
739
-
740
- /**
741
- * Catches and handles errors in event handler methods.
742
- *
743
- * Automatically handles errors in event handlers and sends error responses
744
- * if the event contains a Discord message object.
745
- *
746
- * @param log - Whether to log errors to console (default: false)
747
- * @decorator
748
- * @example
749
- * ```typescript
750
- * class MessageHandler extends EventHandler {
751
- * \@EventCatchable(true)
752
- * async execute() {
753
- * // Event handling logic
754
- * }
755
- * }
756
- * ```
757
- */
758
- declare function EventCatchable(log?: boolean): (_target: EventHandler<keyof ClientEvents>, _prop: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<void>>) => void;
759
-
760
- declare const EventMetadataKey: unique symbol;
761
- /**
762
- * Registers an event handler class with a specific Discord.js event.
763
- *
764
- * Associates the decorated class with a Discord client event for automatic
765
- * registration and execution when the event is emitted.
766
- *
767
- * @param eventName - The Discord.js event name to listen for
768
- * @decorator
769
- * @example
770
- * ```typescript
771
- * \@RegisterEvent(Events.MessageCreate)
772
- * class MessageHandler extends EventHandler<Events.MessageCreate> {
773
- * async execute() {
774
- * // Handle message creation
775
- * }
776
- * }
777
- * ```
778
- */
779
- declare function RegisterEvent<KeyofEvents extends keyof ClientEvents>(eventName: KeyofEvents): (constructor: ConstructorFunction) => void;
780
-
781
- declare enum InteractionRoutes {
782
- Slash = "interaction:slash",
783
- Button = "interaction:button",
784
- Modal = "interaction:modal",
785
- StringMenu = "interaction:stringMenu",
786
- UserMenu = "interaction:userMenu",
787
- RoleMenu = "interaction:roleMenu",
788
- ChannelMenu = "interaction:channelMenu",
789
- MentionableMenu = "interaction:mentionableMenu",
790
- MessageContextMenu = "interaction:messageContextMenu",
791
- UserContextMenu = "interaction:userContextMenu",
792
- Autocomplete = "interaction:autocomplete"
793
- }
794
- declare enum SelectMenuType {
795
- String = "string",
796
- User = "user",
797
- Role = "role",
798
- Channel = "channel",
799
- Mentionable = "mentionable"
800
- }
801
- declare const InteractionMetadataKey: unique symbol;
802
- /**
803
- * Routes slash commands to handler classes
804
- *
805
- * Supports single commands, subcommands, and subcommand groups.
806
- * Use forward slashes to separate subcommand paths.
807
- *
808
- * @param routeOrRoutes - Command path(s) to handle
809
- * @decorator
810
- * @example
811
- * ```typescript
812
- * \@SlashRoute('ping')
813
- * class PingCommand extends InteractionHandler {
814
- * // handles /ping command
815
- * }
816
- *
817
- * \@SlashRoute(['ban', 'kick'])
818
- * class ModerationHandler extends InteractionHandler {
819
- * // handles /ban and /kick commands
820
- * }
821
- *
822
- * \@SlashRoute('admin/user/promote')
823
- * class PromoteHandler extends InteractionHandler {
824
- * // handles /admin user promote subcommand
825
- * }
826
- * ```
827
- */
828
- declare function SlashRoute(routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
829
- /**
830
- * Routes button interactions to handler classes
831
- *
832
- * Matches the customId prefix before the first colon.
833
- * For customId "accept:user123", use \@ButtonRoute("accept").
834
- *
835
- * @param routeOrRoutes - CustomId prefix(es) to handle
836
- * @decorator
837
- */
838
- declare function ButtonRoute(routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
839
- /**
840
- * Routes modal submissions to handler classes
841
- *
842
- * Matches the customId prefix before the first colon.
843
- *
844
- * @param routeOrRoutes - CustomId prefix(es) to handle
845
- * @decorator
846
- */
847
- declare function ModalRoute(routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
848
- /**
849
- * Routes context menu commands to handler classes
850
- *
851
- * @param type - Context menu type: 'message' for message context menus, 'user' for user context menus
852
- * @param routeOrRoutes - Command name(s) to handle
853
- * @decorator
854
- */
855
- declare function ContextMenuRoute(type: 'message' | 'user', routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
856
- /**
857
- * Routes autocomplete interactions to handler classes
858
- *
859
- * Handles autocomplete requests for specific command options.
860
- * Creates routes for each command-field combination.
861
- *
862
- * @param commandRoutes - Command path(s) to handle
863
- * @param focusedFields - Option name(s) to provide completions for
864
- * @example \@AutocompleteRoute('user', 'name') // Single command, single field
865
- * @example \@AutocompleteRoute(['user', 'profile'], ['name', 'bio']) // Multiple commands, multiple fields
866
- * @decorator
867
- */
868
- declare function AutocompleteRoute(commandRoutes: string | string[], focusedFields: string | string[]): (constructor: ConstructorFunction) => void;
869
- /**
870
- * Routes select menu interactions to handler classes
871
- *
872
- * Matches the customId prefix before the first colon.
873
- *
874
- * @param type - Select menu type from {@link SelectMenuType}
875
- * @param routeOrRoutes - CustomId prefix(es) to handle
876
- * @decorator
877
- */
878
- declare function SelectMenuRoute(type: SelectMenuType, routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
879
-
880
- /**
881
- * Throws a custom error with a formatted message and optional UUID.
882
- *
883
- * Wraps an unknown error in a {@link CustomError} subclass. If the error class
884
- * is {@link DatabaseError}, a UUID is generated and passed to the constructor.
885
- *
886
- * @typeParam T - A constructor for a {@link CustomError} subclass
887
- * @param error - The original error or value
888
- * @param message - Custom message to include
889
- * @param CustomError - Error class to instantiate and throw
890
- * @throws Instance of the provided {@link CustomError} subclass
891
- *
892
- * @example
893
- * ```typescript
894
- * try {
895
- * // risky code
896
- * } catch (e) {
897
- * throwCustomError(e, "Something went wrong", MyCustomError);
898
- * }
899
- * ```
900
- */
901
- declare function throwCustomError<Ctor extends CustomErrorConstructor>(error: unknown, message: string, CustomError: Ctor): never;
902
-
903
- /**
904
- * Type-safe event emitter for application effects.
905
- *
906
- * Provides a strongly-typed wrapper around Node.js EventEmitter
907
- * for Seedcord's effect system.
908
- *
909
- * @typeParam AllEffects - Side effect definitions mapping event names to data types
910
- */
911
- declare class EffectsEmitter {
912
- private readonly emitter;
913
- /**
914
- * Registers a listener for the specified side effect.
915
- *
916
- * @typeParam KeyOfEffects - The side effect name type
917
- * @param event - The side effect name to listen for
918
- * @param listener - Function to call when the event is emitted
919
- * @returns This EffectsEmitter instance for chaining
920
- */
921
- on<KeyOfEffects extends EffectKeys>(event: KeyOfEffects, listener: (data: AllEffects[KeyOfEffects]) => void): this;
922
- /**
923
- * Registers a one-time listener for the specified side effect.
924
- *
925
- * @typeParam KeyOfEffects - The side effect name type
926
- * @param event - The side effect name to listen for once
927
- * @param listener - Function to call when the event is emitted
928
- * @returns This EffectsEmitter instance for chaining
929
- */
930
- once<KeyOfEffects extends EffectKeys>(event: KeyOfEffects, listener: (data: AllEffects[KeyOfEffects]) => void): this;
931
- /**
932
- * Emits a side effect with the provided data.
933
- *
934
- * @typeParam KeyOfEffects - The side effect name type
935
- * @param event - The side effect name to emit
936
- * @param data - The data to pass to registered listeners
937
- * @returns True if the event had listeners, false otherwise
938
- */
939
- emit<KeyOfEffects extends EffectKeys>(event: KeyOfEffects, data: AllEffects[KeyOfEffects]): boolean;
940
- }
941
-
942
- declare const EffectMetadataKey: unique symbol;
943
- /**
944
- * Registers a side effect handler class with a specific side effect event.
945
- *
946
- * Associates the decorated class with a side effect event type for automatic
947
- * registration and execution when the side effect is emitted.
948
- *
949
- * @param effect - The side effect event name to register for
950
- * @decorator
951
- * @example
952
- * ```typescript
953
- * \@RegisterEffect('userJoin')
954
- * class WelcomeHandler extends EffectHandler<'userJoin'> {
955
- * async execute() {
956
- * // Handle user join event
957
- * }
958
- * }
959
- * ```
960
- */
961
- declare function RegisterEffect<TEffect extends EffectKeys>(effect: TEffect): (constructor: ConstructorFunction) => void;
962
-
963
- /**
964
- * Abstract base class for handling application side effects.
965
- *
966
- * Provides type-safe access to effects data and the core framework instance.
967
- * Extend this class to create custom side effect handlers.
968
- *
969
- * @typeParam KeyOfEffects - The specific side effect type this handler processes
970
- */
971
- declare abstract class EffectsHandler<KeyOfEffects extends EffectKeys> {
972
- protected readonly data: AllEffects[KeyOfEffects];
973
- protected readonly core: Core;
974
- /**
975
- * Creates a new effects handler instance.
976
- *
977
- * @param data - The effect event data
978
- * @param core - The core framework instance
979
- */
980
- constructor(data: AllEffects[KeyOfEffects], core: Core);
981
- /**
982
- * Executes the effect handler logic.
983
- * @virtual Override this method in your handler classes
984
- */
985
- abstract execute(): Promise<void>;
986
- }
987
-
988
- /**
989
- * Abstract webhook logging handler for side effect events.
990
- *
991
- * Extends EffectsHandler to provide webhook-based logging capabilities.
992
- * Implementations must define the webhook client to send messages to.
993
- *
994
- * @typeParam KeyOfEffects - The specific side effect type this handler processes
995
- */
996
- declare abstract class WebhookLog<KeyOfEffects extends EffectKeys> extends EffectsHandler<KeyOfEffects> {
997
- /** The Discord webhook client for sending log messages */
998
- abstract webhook: WebhookClient;
999
- constructor(data: AllEffects[KeyOfEffects], core: Core);
1000
- }
1001
-
1002
- /**
1003
- * Generic database operation error with UUID tracking.
1004
- *
1005
- * Thrown for various database operation failures and includes
1006
- * a UUID for error tracking and debugging purposes.
1007
- */
1008
- declare class DatabaseError extends CustomError {
1009
- uuid: UUID;
1010
- /**
1011
- * Creates a new DatabaseError.
1012
- *
1013
- * @param message - The error message describing what went wrong
1014
- * @param uuid - A unique identifier for this specific error instance
1015
- */
1016
- constructor(message: string, uuid: UUID);
1017
- }
1018
-
1019
- export { type AllEffects, AutocompleteHandler, type AutocompleteHandlerConstructor, AutocompleteRoute, BaseErrorEmbed, Bot, BuilderComponent, ButtonRoute, Catchable, Checkable, type CommandMeta, CommandMetadataKey, type Config, ContextMenuRoute, type Core, CustomError, type CustomErrorConstructor, DatabaseError, type DefaultEffects, type EffectKeys, EffectMetadataKey, type EffectParams, type Effects, EffectsEmitter, EffectsHandler, EffectsRegistry, EventCatchable, EventHandler, type EventHandlerConstructor, EventMetadataKey, type Handler, type HandlerConstructor, type Initializeable, InteractionHandler, InteractionMetadataKey, InteractionMiddleware, InteractionRoutes, type MiddlewareConstructor, ModalComponent, ModalRoute, Pluggable, Plugin, type PluginArgs, type PluginCtor, RegisterCommand, RegisterEffect, RegisterEvent, type RepliableInteractionHandler, type Repliables, RowComponent, Seedcord, SelectMenuRoute, SelectMenuType, SlashRoute, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionTypes, WebhookLog, type WithChecks, throwCustomError };