seedcord 0.1.1 → 0.2.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/README.md +5 -0
- package/dist/index.cjs +237 -1120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -540
- package/dist/index.d.mts +16 -540
- package/dist/index.d.ts +16 -540
- package/dist/index.mjs +212 -1084
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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';
|
|
3
6
|
import { UUID } from 'crypto';
|
|
4
|
-
|
|
5
|
-
import { Envapter } from 'envapt';
|
|
6
|
-
import * as fs from 'node:fs';
|
|
7
|
+
export * from '@seedcord/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Djs Interactions handlers
|
|
@@ -63,116 +64,6 @@ interface Config {
|
|
|
63
64
|
effects: EffectsConfig;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* Logging service with console and file output support
|
|
68
|
-
*
|
|
69
|
-
* Provides structured logging with timestamps, levels, and labels.
|
|
70
|
-
* Instances are cached by transport name for consistent formatting.
|
|
71
|
-
*/
|
|
72
|
-
declare class Logger {
|
|
73
|
-
private logger;
|
|
74
|
-
private static readonly instances;
|
|
75
|
-
private static instance;
|
|
76
|
-
constructor(transportName: string);
|
|
77
|
-
private getFormatCustomizations;
|
|
78
|
-
private createConsoleTransport;
|
|
79
|
-
private initializeLogger;
|
|
80
|
-
/**
|
|
81
|
-
* Logs an error message with optional additional data.
|
|
82
|
-
*
|
|
83
|
-
* @param msg - The error message to log
|
|
84
|
-
* @param args - Additional data to include in the log entry
|
|
85
|
-
*/
|
|
86
|
-
error(msg: string, ...args: unknown[]): void;
|
|
87
|
-
/**
|
|
88
|
-
* Logs a warning message with optional additional data.
|
|
89
|
-
*
|
|
90
|
-
* @param msg - The warning message to log
|
|
91
|
-
* @param args - Additional data to include in the log entry
|
|
92
|
-
*/
|
|
93
|
-
warn(msg: string, ...args: unknown[]): void;
|
|
94
|
-
/**
|
|
95
|
-
* Logs an informational message with optional additional data.
|
|
96
|
-
*
|
|
97
|
-
* @param msg - The informational message to log
|
|
98
|
-
* @param args - Additional data to include in the log entry
|
|
99
|
-
*/
|
|
100
|
-
info(msg: string, ...args: unknown[]): void;
|
|
101
|
-
/**
|
|
102
|
-
* Logs an HTTP-related message with optional additional data.
|
|
103
|
-
*
|
|
104
|
-
* @param msg - The HTTP message to log
|
|
105
|
-
* @param args - Additional data to include in the log entry
|
|
106
|
-
*/
|
|
107
|
-
http(msg: string, ...args: unknown[]): void;
|
|
108
|
-
/**
|
|
109
|
-
* Logs a verbose message with optional additional data.
|
|
110
|
-
*
|
|
111
|
-
* @param msg - The verbose message to log
|
|
112
|
-
* @param args - Additional data to include in the log entry
|
|
113
|
-
*/
|
|
114
|
-
verbose(msg: string, ...args: unknown[]): void;
|
|
115
|
-
/**
|
|
116
|
-
* Logs a debug message with optional additional data.
|
|
117
|
-
*
|
|
118
|
-
* @param msg - The debug message to log
|
|
119
|
-
* @param args - Additional data to include in the log entry
|
|
120
|
-
*/
|
|
121
|
-
debug(msg: string, ...args: unknown[]): void;
|
|
122
|
-
/**
|
|
123
|
-
* Logs a silly/trace level message with optional additional data.
|
|
124
|
-
*
|
|
125
|
-
* @param msg - The silly message to log
|
|
126
|
-
* @param args - Additional data to include in the log entry
|
|
127
|
-
*/
|
|
128
|
-
silly(msg: string, ...args: unknown[]): void;
|
|
129
|
-
/**
|
|
130
|
-
* Static method to log an error message with a specific prefix.
|
|
131
|
-
* Creates or retrieves a logger instance for the given prefix.
|
|
132
|
-
*
|
|
133
|
-
* @param prefix - The logger prefix/label to use
|
|
134
|
-
* @param msg - The error message to log
|
|
135
|
-
* @param args - Additional data to include in the log entry
|
|
136
|
-
*/
|
|
137
|
-
static Error(prefix: string, msg: string, ...args: unknown[]): void;
|
|
138
|
-
/**
|
|
139
|
-
* Static method to log an informational message with a specific prefix.
|
|
140
|
-
* Creates or retrieves a logger instance for the given prefix.
|
|
141
|
-
*
|
|
142
|
-
* @param prefix - The logger prefix/label to use
|
|
143
|
-
* @param msg - The informational message to log
|
|
144
|
-
* @param args - Additional data to include in the log entry
|
|
145
|
-
*/
|
|
146
|
-
static Info(prefix: string, msg: string, ...args: unknown[]): void;
|
|
147
|
-
/**
|
|
148
|
-
* Static method to log a warning message with a specific prefix.
|
|
149
|
-
* Creates or retrieves a logger instance for the given prefix.
|
|
150
|
-
*
|
|
151
|
-
* @param prefix - The logger prefix/label to use
|
|
152
|
-
* @param msg - The warning message to log
|
|
153
|
-
* @param args - Additional data to include in the log entry
|
|
154
|
-
*/
|
|
155
|
-
static Warn(prefix: string, msg: string, ...args: unknown[]): void;
|
|
156
|
-
/**
|
|
157
|
-
* Static method to log a debug message with a specific prefix.
|
|
158
|
-
* Creates or retrieves a logger instance for the given prefix.
|
|
159
|
-
*
|
|
160
|
-
* @param prefix - The logger prefix/label to use
|
|
161
|
-
* @param msg - The debug message to log
|
|
162
|
-
* @param args - Additional data to include in the log entry
|
|
163
|
-
*/
|
|
164
|
-
static Debug(prefix: string, msg: string, ...args: unknown[]): void;
|
|
165
|
-
/**
|
|
166
|
-
* Static method to log a silly/trace level message with a specific prefix.
|
|
167
|
-
* Creates or retrieves a logger instance for the given prefix.
|
|
168
|
-
*
|
|
169
|
-
* @param prefix - The logger prefix/label to use
|
|
170
|
-
* @param msg - The silly message to log
|
|
171
|
-
* @param args - Additional data to include in the log entry
|
|
172
|
-
*/
|
|
173
|
-
static Silly(prefix: string, msg: string, ...args: unknown[]): void;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
67
|
/**
|
|
177
68
|
* Default side effects that are always available in the framework.
|
|
178
69
|
*/
|
|
@@ -243,213 +134,6 @@ declare class EffectsRegistry extends Plugin {
|
|
|
243
134
|
emit<KeyOfEffects extends EffectKeys>(event: KeyOfEffects, data: AllEffects[KeyOfEffects]): boolean;
|
|
244
135
|
}
|
|
245
136
|
|
|
246
|
-
/**
|
|
247
|
-
* Abstract base class for coordinated lifecycle management (startup/shutdown)
|
|
248
|
-
*/
|
|
249
|
-
declare abstract class CoordinatedLifecycle<TPhase extends number> {
|
|
250
|
-
protected readonly phaseOrder: TPhase[];
|
|
251
|
-
protected readonly phaseEnum: Record<number, string>;
|
|
252
|
-
protected readonly logger: Logger;
|
|
253
|
-
protected readonly events: EventEmitter<[never]>;
|
|
254
|
-
protected readonly tasksMap: Map<TPhase, LifecycleTask[]>;
|
|
255
|
-
protected constructor(loggerName: string, phaseOrder: TPhase[], phaseEnum: Record<number, string>);
|
|
256
|
-
/**
|
|
257
|
-
* Adds a lifecycle task to a specific phase.
|
|
258
|
-
*
|
|
259
|
-
* Tasks are executed in phase order during lifecycle operations.
|
|
260
|
-
* Each task has a timeout to prevent hanging operations.
|
|
261
|
-
*
|
|
262
|
-
* @param phase - The lifecycle phase to add the task to
|
|
263
|
-
* @param taskName - Unique name for the task (used for logging and removal)
|
|
264
|
-
* @param task - Async function to execute during the phase
|
|
265
|
-
* @param timeoutMs - Maximum time allowed for task execution in milliseconds
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* lifecycle.addTask(StartupPhase.Services, 'start-database', async () => {
|
|
269
|
-
* await database.connect();
|
|
270
|
-
* }, 10000);
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
addTask(phase: TPhase, taskName: string, task: () => Promise<void>, timeoutMs: number): void;
|
|
274
|
-
/**
|
|
275
|
-
* Removes a lifecycle task from a specific phase.
|
|
276
|
-
*
|
|
277
|
-
* @param phase - The lifecycle phase to remove the task from
|
|
278
|
-
* @param taskName - Name of the task to remove
|
|
279
|
-
* @returns True if the task was found and removed, false otherwise
|
|
280
|
-
*/
|
|
281
|
-
removeTask(phase: TPhase, taskName: string): boolean;
|
|
282
|
-
/**
|
|
283
|
-
* Run all tasks in a specific phase
|
|
284
|
-
*/
|
|
285
|
-
protected runPhase(phase: TPhase): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Run a single task with timeout
|
|
288
|
-
*/
|
|
289
|
-
protected runTaskWithTimeout(phase: TPhase, task: LifecycleTask): Promise<void>;
|
|
290
|
-
/**
|
|
291
|
-
* Subscribe to lifecycle events
|
|
292
|
-
*/
|
|
293
|
-
on(event: string, listener: (...args: unknown[]) => void): void;
|
|
294
|
-
/**
|
|
295
|
-
* Unsubscribe from lifecycle events
|
|
296
|
-
*/
|
|
297
|
-
off(event: string, listener: (...args: unknown[]) => void): void;
|
|
298
|
-
protected emit(event: string, ...args: unknown[]): boolean;
|
|
299
|
-
protected abstract canAddTask(): boolean;
|
|
300
|
-
protected abstract canRemoveTask(): boolean;
|
|
301
|
-
protected abstract getTaskType(): string;
|
|
302
|
-
protected abstract executeTasksInPhase(phase: TPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Shutdown phases for coordinated application shutdown.
|
|
307
|
-
*/
|
|
308
|
-
declare enum ShutdownPhase {
|
|
309
|
-
/** Stop accepting new requests/interactions */
|
|
310
|
-
StopAcceptingRequests = 1,
|
|
311
|
-
/** Stop background services (health checks, etc.) */
|
|
312
|
-
StopServices = 2,
|
|
313
|
-
/** Disconnect from external resources (database, APIs) */
|
|
314
|
-
ExternalResources = 3,
|
|
315
|
-
/** Disconnect from Discord */
|
|
316
|
-
DiscordCleanup = 4,
|
|
317
|
-
/** Final cleanup tasks */
|
|
318
|
-
FinalCleanup = 5
|
|
319
|
-
}
|
|
320
|
-
type CoordinatedShutdownEventKey = PhaseEvents<'shutdown', UnionToTuple<ShutdownPhase>>;
|
|
321
|
-
declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase> {
|
|
322
|
-
private isShuttingDown;
|
|
323
|
-
private exitCode;
|
|
324
|
-
constructor();
|
|
325
|
-
protected canAddTask(): boolean;
|
|
326
|
-
protected canRemoveTask(): boolean;
|
|
327
|
-
protected getTaskType(): string;
|
|
328
|
-
protected executeTasksInPhase(phase: ShutdownPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
|
|
329
|
-
private registerSignalHandlers;
|
|
330
|
-
/**
|
|
331
|
-
* Adds a task to a specific shutdown phase with timeout.
|
|
332
|
-
*
|
|
333
|
-
* @param phase - The shutdown phase from {@link ShutdownPhase}
|
|
334
|
-
* @param taskName - Unique identifier for the task
|
|
335
|
-
* @param task - Async function to execute
|
|
336
|
-
* @param timeoutMs - Task timeout in milliseconds (default: 5000)
|
|
337
|
-
*/
|
|
338
|
-
addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
|
|
339
|
-
/**
|
|
340
|
-
* Removes a task from a specific shutdown phase.
|
|
341
|
-
*
|
|
342
|
-
* @param phase - The shutdown phase to remove from
|
|
343
|
-
* @param taskName - Name of the task to remove
|
|
344
|
-
* @returns True if task was found and removed
|
|
345
|
-
*/
|
|
346
|
-
removeTask(phase: ShutdownPhase, taskName: string): boolean;
|
|
347
|
-
/**
|
|
348
|
-
* Executes the coordinated shutdown sequence.
|
|
349
|
-
*
|
|
350
|
-
* Runs all registered tasks across shutdown phases in reverse order.
|
|
351
|
-
* Tasks within each phase are executed in parallel for faster shutdown.
|
|
352
|
-
* Process exits with the specified code when complete.
|
|
353
|
-
*
|
|
354
|
-
* @param exitCode - Process exit code (default: 0)
|
|
355
|
-
* @returns Promise that resolves when shutdown is complete
|
|
356
|
-
* @example
|
|
357
|
-
* ```typescript
|
|
358
|
-
* shutdown.addTask(ShutdownPhase.Services, 'database', () => db.disconnect(), 5000);
|
|
359
|
-
* await shutdown.run(0); // Graceful shutdown
|
|
360
|
-
* ```
|
|
361
|
-
*/
|
|
362
|
-
run(exitCode?: number): Promise<void>;
|
|
363
|
-
/**
|
|
364
|
-
* Subscribe to shutdown events
|
|
365
|
-
*/
|
|
366
|
-
on(event: CoordinatedShutdownEventKey, listener: (...args: unknown[]) => void): void;
|
|
367
|
-
/**
|
|
368
|
-
* Unsubscribe from shutdown events
|
|
369
|
-
*/
|
|
370
|
-
off(event: CoordinatedShutdownEventKey, listener: (...args: unknown[]) => void): void;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Startup phases for coordinated initialization
|
|
375
|
-
*
|
|
376
|
-
* Defines the order in which different components are initialized during bot startup.
|
|
377
|
-
*/
|
|
378
|
-
declare enum StartupPhase {
|
|
379
|
-
/** Validate environment variables and config files */
|
|
380
|
-
Validation = 1,
|
|
381
|
-
/** Discover plugin constructors via decorators or registry */
|
|
382
|
-
Discovery = 2,
|
|
383
|
-
/** Register plugin metadata and declared dependencies */
|
|
384
|
-
Registration = 3,
|
|
385
|
-
/** Inject and validate plugin-specific configuration */
|
|
386
|
-
Configuration = 4,
|
|
387
|
-
/** Instantiate plugin classes with Core and arguments */
|
|
388
|
-
Instantiation = 5,
|
|
389
|
-
/** Activate plugins by calling their init/setup effects */
|
|
390
|
-
Activation = 6,
|
|
391
|
-
/** Mark seedcord as ready and start handling interactions */
|
|
392
|
-
Ready = 7
|
|
393
|
-
}
|
|
394
|
-
type CoordinatedStartupEventKey = PhaseEvents<'startup', UnionToTuple<StartupPhase>>;
|
|
395
|
-
/**
|
|
396
|
-
* Manages bot startup lifecycle with ordered phases
|
|
397
|
-
*
|
|
398
|
-
* Coordinates initialization of all bot components in a predictable sequence.
|
|
399
|
-
* Tasks are executed within their designated phases to ensure proper dependency order.
|
|
400
|
-
*/
|
|
401
|
-
declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase> {
|
|
402
|
-
private isStartingUp;
|
|
403
|
-
private hasStarted;
|
|
404
|
-
constructor();
|
|
405
|
-
/**
|
|
406
|
-
* Adds a task to a specific startup phase with timeout.
|
|
407
|
-
*
|
|
408
|
-
* @param phase - The startup phase from {@link StartupPhase}
|
|
409
|
-
* @param taskName - Unique identifier for the task
|
|
410
|
-
* @param task - Async function to execute
|
|
411
|
-
* @param timeoutMs - Task timeout in milliseconds (default: 10000)
|
|
412
|
-
*/
|
|
413
|
-
addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
|
|
414
|
-
protected canAddTask(): boolean;
|
|
415
|
-
protected canRemoveTask(): boolean;
|
|
416
|
-
protected getTaskType(): string;
|
|
417
|
-
protected executeTasksInPhase(phase: StartupPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
|
|
418
|
-
/**
|
|
419
|
-
* Executes the coordinated startup sequence.
|
|
420
|
-
*
|
|
421
|
-
* Runs all registered tasks across startup phases in the correct order.
|
|
422
|
-
* Each phase completes before the next phase begins. Tasks within a phase
|
|
423
|
-
* are executed sequentially to maintain predictable initialization.
|
|
424
|
-
*
|
|
425
|
-
* @returns Promise that resolves when startup is complete
|
|
426
|
-
* @throws An {@link Error} If startup fails or is called multiple times
|
|
427
|
-
* @example
|
|
428
|
-
* ```typescript
|
|
429
|
-
* const startup = new CoordinatedStartup();
|
|
430
|
-
* startup.addTask(StartupPhase.Services, 'database', () => db.connect(), 10000);
|
|
431
|
-
* await startup.run();
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
run(): Promise<void>;
|
|
435
|
-
/**
|
|
436
|
-
* Subscribe to startup events
|
|
437
|
-
*/
|
|
438
|
-
on(event: CoordinatedStartupEventKey, listener: (...args: unknown[]) => void): void;
|
|
439
|
-
/**
|
|
440
|
-
* Unsubscribe from startup events
|
|
441
|
-
*/
|
|
442
|
-
off(event: CoordinatedStartupEventKey, listener: (...args: unknown[]) => void): void;
|
|
443
|
-
/**
|
|
444
|
-
* Check if startup has completed
|
|
445
|
-
*/
|
|
446
|
-
get isReady(): boolean;
|
|
447
|
-
/**
|
|
448
|
-
* Check if startup is currently running
|
|
449
|
-
*/
|
|
450
|
-
get isRunning(): boolean;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
137
|
/** Base interface defining core Seedcord functionality */
|
|
454
138
|
interface BaseCore {
|
|
455
139
|
readonly bot: Bot;
|
|
@@ -541,7 +225,7 @@ declare class Pluggable {
|
|
|
541
225
|
* @throws An {@link Error} When called after initialization or if key already exists
|
|
542
226
|
* @example
|
|
543
227
|
* ```typescript
|
|
544
|
-
* seedcord.attach('db', Mongo, StartupPhase.Configuration, { uri: 'mongodb://...',
|
|
228
|
+
* seedcord.attach('db', Mongo, StartupPhase.Configuration, { uri: 'mongodb://...', name: 'seedcord', dir: ... })
|
|
545
229
|
* ```
|
|
546
230
|
*/
|
|
547
231
|
attach<Key extends string, Ctor extends PluginCtor>(this: this, key: Key, Plugin: Ctor, startupPhase: StartupPhase, ...args: PluginArgs<Ctor>): this & Record<Key, InstanceType<Ctor>>;
|
|
@@ -553,6 +237,7 @@ declare class Pluggable {
|
|
|
553
237
|
*/
|
|
554
238
|
declare class Bot extends Plugin {
|
|
555
239
|
protected core: Core;
|
|
240
|
+
readonly botToken: string;
|
|
556
241
|
readonly logger: Logger;
|
|
557
242
|
private isInitialized;
|
|
558
243
|
private readonly _client;
|
|
@@ -807,6 +492,12 @@ declare const BuilderTypes: {
|
|
|
807
492
|
context_menu: typeof ContextMenuCommandBuilder;
|
|
808
493
|
subcommand: typeof SlashCommandSubcommandBuilder;
|
|
809
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;
|
|
810
501
|
};
|
|
811
502
|
declare const RowTypes: {
|
|
812
503
|
button: typeof ActionRowBuilder<ButtonBuilder>;
|
|
@@ -875,6 +566,7 @@ declare abstract class BaseComponent<TComponent> {
|
|
|
875
566
|
* @typeParam BuilderKey - The type of Discord.js builder being wrapped
|
|
876
567
|
*/
|
|
877
568
|
declare abstract class BuilderComponent<BuilderKey extends BuilderType> extends BaseComponent<InstantiatedBuilder<BuilderKey>> {
|
|
569
|
+
private readonly botColor;
|
|
878
570
|
protected constructor(type: BuilderKey);
|
|
879
571
|
get component(): InstantiatedBuilder<BuilderKey>;
|
|
880
572
|
}
|
|
@@ -1124,189 +816,6 @@ declare function AutocompleteRoute(commandRoutes: string | string[], focusedFiel
|
|
|
1124
816
|
*/
|
|
1125
817
|
declare function SelectMenuRoute(type: SelectMenuType, routeOrRoutes: string | string[]): (constructor: ConstructorFunction) => void;
|
|
1126
818
|
|
|
1127
|
-
/**
|
|
1128
|
-
* HTTP health check service for monitoring bot status.
|
|
1129
|
-
*
|
|
1130
|
-
* Provides a simple HTTP endpoint that responds with JSON status
|
|
1131
|
-
* information, useful for container orchestration and monitoring.
|
|
1132
|
-
*/
|
|
1133
|
-
declare class HealthCheck extends Plugin {
|
|
1134
|
-
private readonly core;
|
|
1135
|
-
readonly logger: Logger;
|
|
1136
|
-
private readonly port;
|
|
1137
|
-
private readonly path;
|
|
1138
|
-
private server?;
|
|
1139
|
-
constructor(core: Core);
|
|
1140
|
-
/**
|
|
1141
|
-
* Starts the health check server.
|
|
1142
|
-
* @returns Promise that resolves when the server is listening
|
|
1143
|
-
*/
|
|
1144
|
-
init(): Promise<void>;
|
|
1145
|
-
/**
|
|
1146
|
-
* Stops the health check server.
|
|
1147
|
-
*
|
|
1148
|
-
* @returns Promise that resolves when the server is closed
|
|
1149
|
-
*/
|
|
1150
|
-
stop(): Promise<void>;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
/**
|
|
1154
|
-
* Configuration options for CooldownManager.
|
|
1155
|
-
*/
|
|
1156
|
-
interface CooldownOptions {
|
|
1157
|
-
/** Cooldown window in milliseconds (default 1000) */
|
|
1158
|
-
cooldown?: number;
|
|
1159
|
-
/** Custom error class to throw when a key is still cooling down */
|
|
1160
|
-
err?: new (msg: string, ...args: any[]) => Error;
|
|
1161
|
-
/** Message passed to the error constructor (default "Cooldown active") */
|
|
1162
|
-
message?: string;
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* Lightweight utility for per-key cooldowns.
|
|
1166
|
-
*
|
|
1167
|
-
* Manages time-based restrictions on operations by key,
|
|
1168
|
-
* useful for rate limiting, command cooldowns, and spam prevention.
|
|
1169
|
-
*/
|
|
1170
|
-
declare class CooldownManager {
|
|
1171
|
-
private readonly window;
|
|
1172
|
-
private readonly Err;
|
|
1173
|
-
private readonly msg;
|
|
1174
|
-
private readonly map;
|
|
1175
|
-
/**
|
|
1176
|
-
* Creates a new CooldownManager instance.
|
|
1177
|
-
*
|
|
1178
|
-
* @param opts - Configuration options for the cooldown behavior
|
|
1179
|
-
*/
|
|
1180
|
-
constructor(opts?: CooldownOptions);
|
|
1181
|
-
/**
|
|
1182
|
-
* Records usage timestamp for a key without any cooldown checks.
|
|
1183
|
-
*
|
|
1184
|
-
* @param key - The unique identifier for the cooldown entry
|
|
1185
|
-
*/
|
|
1186
|
-
set(key: string): void;
|
|
1187
|
-
/**
|
|
1188
|
-
* Verifies cooldown status for a key and updates timestamp if not active.
|
|
1189
|
-
*
|
|
1190
|
-
* If the cooldown is still active, throws the configured error.
|
|
1191
|
-
* If not active, updates the timestamp and returns successfully.
|
|
1192
|
-
*
|
|
1193
|
-
* @param key - The unique identifier to check cooldown for
|
|
1194
|
-
* @throws An {@link Err} When the cooldown is still active for the given key
|
|
1195
|
-
*/
|
|
1196
|
-
check(key: string): void;
|
|
1197
|
-
/**
|
|
1198
|
-
* Checks if a key is currently cooling down without updating timestamp.
|
|
1199
|
-
*
|
|
1200
|
-
* @param key - The unique identifier to check
|
|
1201
|
-
* @returns True if the key is still cooling down, false otherwise
|
|
1202
|
-
*/
|
|
1203
|
-
isActive(key: string): boolean;
|
|
1204
|
-
/**
|
|
1205
|
-
* Removes a key from the cooldown map.
|
|
1206
|
-
*
|
|
1207
|
-
* @param key - The unique identifier to remove (useful for manual resets)
|
|
1208
|
-
*/
|
|
1209
|
-
clear(key: string): void;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Global configuration variables and environment settings
|
|
1214
|
-
*
|
|
1215
|
-
* Provides centralized access to environment variables and framework settings.
|
|
1216
|
-
* Extend this class in your bot to add custom environment variables.
|
|
1217
|
-
*/
|
|
1218
|
-
declare class Globals extends Envapter {
|
|
1219
|
-
static readonly botToken: string;
|
|
1220
|
-
static readonly healthCheckPort: number;
|
|
1221
|
-
static readonly healthCheckPath: string;
|
|
1222
|
-
static readonly shutdownIsEnabled: boolean;
|
|
1223
|
-
static readonly unknownExceptionWebhookUrl: string;
|
|
1224
|
-
/** Default color for bot embeds - can be overridden by setting Globals.botColor */
|
|
1225
|
-
static botColor: ColorResolvable;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
* Rounds a number to a specified number of decimal places.
|
|
1230
|
-
*
|
|
1231
|
-
* @param num - The number to be rounded.
|
|
1232
|
-
* @param decimalPlaces - The number of decimal places to round to.
|
|
1233
|
-
* @returns The rounded number.
|
|
1234
|
-
*/
|
|
1235
|
-
declare function numberFixer(num: number, decimalPlaces: number): number;
|
|
1236
|
-
/**
|
|
1237
|
-
* Takes two numbers and returns the percentage of the first number in the second number with two decimal places.
|
|
1238
|
-
*
|
|
1239
|
-
* @param num1 - The first number.
|
|
1240
|
-
* @param num2 - The second number.
|
|
1241
|
-
*
|
|
1242
|
-
* @returns The percentage of the first number in the second number with two decimal places.
|
|
1243
|
-
*/
|
|
1244
|
-
declare function percentage(num1: number, num2: number): number;
|
|
1245
|
-
/**
|
|
1246
|
-
* Generates an ASCII table from the provided data.
|
|
1247
|
-
*
|
|
1248
|
-
* @param data - The data to be displayed in the table.
|
|
1249
|
-
* @returns The generated ASCII table as a string.
|
|
1250
|
-
*/
|
|
1251
|
-
declare function generateAsciiTable(data: string[][]): string;
|
|
1252
|
-
/**
|
|
1253
|
-
* Returns the word with it's first letter capitalized and the rest in lowercase.
|
|
1254
|
-
* @param word - The word to be formatted.
|
|
1255
|
-
* @returns The formatted word.
|
|
1256
|
-
*/
|
|
1257
|
-
declare function formatWord(word: string): string;
|
|
1258
|
-
/**
|
|
1259
|
-
* Function takes an array of strings or numbers and returns the number of characters in the longest string/number
|
|
1260
|
-
* @param arr - The array of strings or numbers
|
|
1261
|
-
*/
|
|
1262
|
-
declare function longestStringLength(arr: (string | number)[]): number;
|
|
1263
|
-
/**
|
|
1264
|
-
* Return current time in seconds
|
|
1265
|
-
*/
|
|
1266
|
-
declare function currentTime(): number;
|
|
1267
|
-
/**
|
|
1268
|
-
* Returns the ordinal suffix for a given number.
|
|
1269
|
-
*
|
|
1270
|
-
* @param n - The number to get the ordinal for
|
|
1271
|
-
* @returns The number with its ordinal suffix
|
|
1272
|
-
*
|
|
1273
|
-
* @example
|
|
1274
|
-
* ordinal(1); // "1st"
|
|
1275
|
-
* ordinal(22); // "22nd"
|
|
1276
|
-
* ordinal(13); // "13th"
|
|
1277
|
-
*/
|
|
1278
|
-
declare function ordinal(n: number): string;
|
|
1279
|
-
/**
|
|
1280
|
-
* Calculates the difference between two numbers and formats it as a string with a '+' prefix for positive differences.
|
|
1281
|
-
*
|
|
1282
|
-
* @param numBefore - The initial number value
|
|
1283
|
-
* @param numAfter - The final number value
|
|
1284
|
-
* @returns A string representing the difference, with a '+' sign for positive differences
|
|
1285
|
-
*
|
|
1286
|
-
* @example
|
|
1287
|
-
* // Returns "+5"
|
|
1288
|
-
* prettyDifference(10, 15);
|
|
1289
|
-
*
|
|
1290
|
-
* @example
|
|
1291
|
-
* // Returns "-3"
|
|
1292
|
-
* prettyDifference(10, 7);
|
|
1293
|
-
*/
|
|
1294
|
-
declare function prettyDifference(numBefore: number, numAfter: number): string;
|
|
1295
|
-
/**
|
|
1296
|
-
* Determines if a directory entry is a TypeScript or JavaScript file.
|
|
1297
|
-
*
|
|
1298
|
-
* @param entry - The directory entry to check.
|
|
1299
|
-
* @returns True if the entry is a file ending with .ts or .js.
|
|
1300
|
-
*/
|
|
1301
|
-
declare function isTsOrJsFile(entry: fs.Dirent): boolean;
|
|
1302
|
-
/**
|
|
1303
|
-
* Recursively traverses through a directory, importing all .ts and .js files and applying a callback to each import.
|
|
1304
|
-
*
|
|
1305
|
-
* @param dir - The directory path to traverse.
|
|
1306
|
-
* @param callback - A function that will be called for each imported module. It receives the full file path, the file's relative path, and the imported module as arguments.
|
|
1307
|
-
* @returns A Promise that resolves when the traversal is complete.
|
|
1308
|
-
*/
|
|
1309
|
-
declare function traverseDirectory(dir: string, callback: (fullPath: string, relativePath: string, imported: Record<string, unknown>) => Promise<void> | void): Promise<void>;
|
|
1310
819
|
/**
|
|
1311
820
|
* Throws a custom error with a formatted message and optional UUID.
|
|
1312
821
|
*
|
|
@@ -1329,39 +838,6 @@ declare function traverseDirectory(dir: string, callback: (fullPath: string, rel
|
|
|
1329
838
|
* ```
|
|
1330
839
|
*/
|
|
1331
840
|
declare function throwCustomError<Ctor extends CustomErrorConstructor>(error: unknown, message: string, CustomError: Ctor): never;
|
|
1332
|
-
/**
|
|
1333
|
-
* Converts a camelCase or snake_case string into a human-readable format.
|
|
1334
|
-
*
|
|
1335
|
-
* This function inserts spaces before capital letters that follow lowercase
|
|
1336
|
-
* letters, replaces underscores with spaces, and trims any extra whitespace.
|
|
1337
|
-
*
|
|
1338
|
-
* @param key - The string to be converted to a human-readable format
|
|
1339
|
-
* @returns A prettified string with proper spacing
|
|
1340
|
-
*
|
|
1341
|
-
* @example
|
|
1342
|
-
* prettify("camelCaseString") // returns "camel Case String"
|
|
1343
|
-
* @example
|
|
1344
|
-
* prettify("snake_case_string") // returns "snake case string"
|
|
1345
|
-
*/
|
|
1346
|
-
declare function prettify(key: string): string;
|
|
1347
|
-
/**
|
|
1348
|
-
* Shuffles an array using the Fisher-Yates algorithm.
|
|
1349
|
-
* This function creates a new array with the same elements in a random order,
|
|
1350
|
-
* without modifying the original array.
|
|
1351
|
-
*
|
|
1352
|
-
* @typeParam TArray - The type of elements in the array
|
|
1353
|
-
* @param items - The array to shuffle
|
|
1354
|
-
* @returns A new array with the same elements in a random order
|
|
1355
|
-
*
|
|
1356
|
-
* @example
|
|
1357
|
-
* ```typescript
|
|
1358
|
-
* const numbers = [1, 2, 3, 4, 5];
|
|
1359
|
-
* const shuffled = fyShuffle(numbers);
|
|
1360
|
-
* // shuffled might be [3, 1, 5, 2, 4]
|
|
1361
|
-
* // numbers is still [1, 2, 3, 4, 5]
|
|
1362
|
-
* ```
|
|
1363
|
-
*/
|
|
1364
|
-
declare function fyShuffle<TArray>(items: TArray[]): TArray[];
|
|
1365
841
|
|
|
1366
842
|
/**
|
|
1367
843
|
* Type-safe event emitter for application effects.
|
|
@@ -1480,4 +956,4 @@ declare class DatabaseError extends CustomError {
|
|
|
1480
956
|
constructor(message: string, uuid: UUID);
|
|
1481
957
|
}
|
|
1482
958
|
|
|
1483
|
-
export { type AllEffects, AutocompleteHandler, type AutocompleteHandlerConstructor, AutocompleteRoute, BaseErrorEmbed, Bot, BuilderComponent, ButtonRoute, Catchable, Checkable, type CommandMeta, CommandMetadataKey, type Config, ContextMenuRoute,
|
|
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 };
|