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