@seedcord/gateway 0.1.0-next.1 → 0.1.0-next.2

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.d.mts CHANGED
@@ -1,18 +1,20 @@
1
1
  import { BuilderComponent, CoreBase, DispatchContext, Gate, GateContextBase, GateNoticeOptions, MessageContextMenuRegistry, Notice, OptionKind, PageView, RegisterCommand, RequiredOf, SlashOptionRegistry, UserContextMenuRegistry } from "@seedcord/core";
2
2
  import { AnyCustomId, DecodedParams, GateFitsWith, HasComponentDefs, PageCursor } from "@seedcord/core/internal";
3
3
  import { APIInteractionGuildMember, APIMessageComponentEmoji, AnySelectMenuInteraction, ApplicationCommand, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, ChannelType, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Collection, CommandInteractionOption, ContextMenuCommandInteraction, Events, Guild, GuildEmoji, GuildMember, Interaction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, Role, RoleSelectMenuInteraction, Snowflake, StringSelectMenuInteraction, TextChannel, TextChannelResolvable, User, UserContextMenuCommandInteraction, UserSelectMenuInteraction, WebhookClient } from "discord.js";
4
- import { CoordinatedShutdown, CoordinatedStartup, Logger, StartupPhase } from "@seedcord/services";
4
+ import { Logger } from "@seedcord/logger";
5
5
  import { ActionRowBuilder, ButtonBuilder, ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
6
6
  import { EventMap, NoEvents, TypedEventEmitter } from "@seedcord/event-emitter";
7
- import { HmrAware, HmrUpdateEvent, SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
7
+ import { CoordinatedShutdown, CoordinatedStartup, StartupPhase } from "@seedcord/services";
8
+ import { SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
8
9
  import { UUID } from "node:crypto";
9
- import { BotConfig, Config, EmojiMap, IRateLimiter, Nullable, ReplyResponse, Tail, V2Component } from "@seedcord/types";
10
+ import { BotConfig, Config, EmojiMap, HmrAware, HmrUpdateEvent, IRateLimiter, Nullable, ReplyResponse, Tail, V2Component } from "@seedcord/types";
10
11
  export * from "@seedcord/core";
11
12
  export * from "@seedcord/errors";
12
13
  export * from "@seedcord/utils";
13
- export * from "@seedcord/services";
14
+ export * from "@seedcord/logger";
14
15
  export * from "@seedcord/event-emitter";
15
16
  export * from "@seedcord/rate-limiter";
17
+ export * from "@seedcord/services";
16
18
  export type * from "@seedcord/types";
17
19
 
18
20
  //#region src/bot/utilities/miscellaneous/contextMenuLeaves.d.ts
@@ -57,7 +59,6 @@ interface GatewayConfig extends Config {
57
59
  }
58
60
  //#endregion
59
61
  //#region src/interfaces/Plugin.d.ts
60
- /** Interface for objects that can be initialized asynchronously */
61
62
  interface Initializeable {
62
63
  init(): Promise<void>;
63
64
  }
@@ -69,14 +70,10 @@ interface Initializeable {
69
70
  */
70
71
  declare abstract class Plugin<TPluginEvents extends EventMap<TPluginEvents> = NoEvents> extends TypedEventEmitter<TPluginEvents> implements Initializeable, HmrAware {
71
72
  protected pluggable: Core;
72
- /** Logger instance for this plugin. */
73
73
  abstract logger: Logger;
74
74
  name: string;
75
75
  constructor(pluggable: Core);
76
- /**
77
- * Initialize the plugin.
78
- * @virtual
79
- */
76
+ /** @virtual */
80
77
  abstract init(): Promise<void>;
81
78
  /**
82
79
  * Reloads plugin state on an HMR update. The base implementation is a no-op, override it in your plugin.
@@ -94,15 +91,13 @@ declare abstract class Plugin<TPluginEvents extends EventMap<TPluginEvents> = No
94
91
  removeAllListeners(event?: Extract<keyof TPluginEvents, string | symbol>): this;
95
92
  }
96
93
  /**
97
- * Constructor type for plugins that can accept additional arguments after Core
98
- * @typeParam TPlugin - The plugin type being constructed
94
+ * Constructor type for plugins that can accept extra arguments after Core.
99
95
  *
100
96
  * @internal
101
97
  */
102
98
  type PluginCtor<TPlugin extends Plugin = Plugin> = new (core: Core, ...args: any[]) => TPlugin;
103
99
  /**
104
- * Extracts the argument types for a plugin constructor (excluding the Core parameter)
105
- * @typeParam Ctor - The plugin constructor to extract arguments from
100
+ * Extracts the argument types for a plugin constructor, excluding the Core parameter.
106
101
  *
107
102
  * @internal
108
103
  */
@@ -343,12 +338,15 @@ declare class CommandRegistry implements Initializeable, HmrAware {
343
338
  readonly globalCommands: (SlashCommandBuilder | ContextMenuCommandBuilder)[];
344
339
  readonly guildCommands: Collection<string, (SlashCommandBuilder | ContextMenuCommandBuilder)[]>;
345
340
  private readonly ctorToCommand;
341
+ private loading;
342
+ private readonly loadedCommands;
346
343
  private readonly hmrHandler?;
347
344
  private readonly pendingEvents;
348
345
  constructor(core: Core, onDeployed?: ((result: DeployResult) => void) | undefined);
349
346
  private getArtifacts;
350
347
  /** @internal */
351
348
  init(): Promise<void>;
349
+ private reportLoad;
352
350
  /** @internal */
353
351
  refresh(shouldRefresh?: boolean): Promise<void>;
354
352
  /** @internal */
@@ -2415,72 +2413,6 @@ declare abstract class WebhookLog<KeyOfSubscribers extends SubscriptionKey> exte
2415
2413
  constructor(data: AllSubscriptions[KeyOfSubscribers], core: Core);
2416
2414
  }
2417
2415
  //#endregion
2418
- //#region src/hmr/HmrModuleHandler.d.ts
2419
- /**
2420
- * Options for configuring the HmrModuleHandler.
2421
- *
2422
- * This is only useful during development.
2423
- */
2424
- interface HmrModuleHandlerOptions<THandler, TMiddleware = void, TArtifacts = unknown> {
2425
- /** Directory containing handler modules. */
2426
- handlersDir: string;
2427
- /** Directory containing middleware modules. Optional because not all setups use middleware. */
2428
- middlewaresDir?: string;
2429
- /** Function to determine if a value is a handler module of type THandler. */
2430
- isHandler: (val: unknown) => val is THandler;
2431
- /** Function to determine if a value is a middleware module of type TMiddleware. Optional because not all setups use middleware. */
2432
- isMiddleware?: (val: unknown) => val is TMiddleware;
2433
- /** Function to register a handler module. */
2434
- registerHandler: (handler: THandler, file: string) => void;
2435
- /** Function to register a middleware module. Optional because not all setups use middleware. */
2436
- registerMiddleware?: (middleware: TMiddleware, file: string) => void;
2437
- /** Function to unregister a handler module. */
2438
- unregisterHandler: (handler: THandler, artifacts?: TArtifacts) => void;
2439
- /** Function to unregister a middleware module. Optional because not all setups use middleware. */
2440
- unregisterMiddleware?: (middleware: TMiddleware) => void;
2441
- /** Function to extract artifacts from a handler to be stored across hmr cache invalidations. */
2442
- getArtifacts?: (handler: THandler) => TArtifacts;
2443
- /** Logger instance for logging HMR activities.*/
2444
- logger: Logger;
2445
- }
2446
- /**
2447
- * Reloads THandler and optional TMiddleware modules on HMR updates.
2448
- *
2449
- * You can either implement a custom `onHmr()` method in your class by extending `HmrAware`, or if it's a plugin, override the existing `onHmr()` with fully custom logic. Or, use this class's `handle()` method inside your `onHmr()` to get standard HMR handling for your modules based on the provided options you give to the constructor.
2450
- *
2451
- * This is only useful during development.
2452
- */
2453
- declare class HmrModuleHandler<THandler, TMiddleware = void, TArtifacts = unknown> {
2454
- private readonly store;
2455
- private readonly options;
2456
- constructor(options: HmrModuleHandlerOptions<THandler, TMiddleware, TArtifacts>);
2457
- /**
2458
- * Handles an HMR update event by reloading affected modules based on the event details and config. It receives an {@link HmrUpdateEvent}, then checks the type of update.
2459
- *
2460
- * - If it's a deletion, it unloads the module.
2461
- * - If it's an update/creation, it checks if the file is tracked, unloads it if so, then reloads the file if it is in the handlers or middlewares directory and is a valid handler/middleware.
2462
- */
2463
- handle(event: HmrUpdateEvent): Promise<void>;
2464
- private reloadWithRollback;
2465
- /**
2466
- * Tracks a handler module as being loaded from a specific file.
2467
- * @param file - The file path the handler was loaded from.
2468
- * @param handler - The handler module instance.
2469
- */
2470
- trackHandler(file: string, handler: THandler): void;
2471
- /**
2472
- * Tracks a middleware module as being loaded from a specific file.
2473
- * @param file - The file path the middleware was loaded from.
2474
- * @param middleware - The middleware module instance.
2475
- */
2476
- trackMiddleware(file: string, middleware: TMiddleware): void;
2477
- private isTracked;
2478
- private unload;
2479
- private reloadFile;
2480
- private snapshotUnits;
2481
- private restoreUnits;
2482
- }
2483
- //#endregion
2484
2416
  //#region src/Seedcord.d.ts
2485
2417
  /**
2486
2418
  * Main Seedcord bot framework class
@@ -2497,6 +2429,8 @@ declare class Seedcord extends Pluggable implements Core {
2497
2429
  /** @internal */
2498
2430
  readonly version: string;
2499
2431
  private static isInstantiated;
2432
+ private readonly healthCheck;
2433
+ private readonly hmrManager;
2500
2434
  /** @see {@link CoordinatedShutdown} */
2501
2435
  readonly shutdown: CoordinatedShutdown;
2502
2436
  /** @see {@link CoordinatedStartup} */
@@ -2507,10 +2441,6 @@ declare class Seedcord extends Pluggable implements Core {
2507
2441
  readonly bot: Bot;
2508
2442
  /** @see {@link IRateLimiter} */
2509
2443
  readonly rateLimiter: IRateLimiter;
2510
- /** @see {@link HealthCheck} */
2511
- private readonly healthCheck;
2512
- /** @see {@link HmrManager} */
2513
- private readonly hmrManager;
2514
2444
  /**
2515
2445
  * Creates a new Seedcord instance
2516
2446
  *
@@ -2518,12 +2448,9 @@ declare class Seedcord extends Pluggable implements Core {
2518
2448
  * @throws A **SeedcordError** When attempting to create multiple instances (singleton)
2519
2449
  */
2520
2450
  constructor(config: GatewayConfig);
2521
- /** @internal */
2451
+ /** The bot's discord username, populated after login. */
2452
+ get username(): string | undefined;
2522
2453
  private static reset;
2523
- /**
2524
- * Registers default startup tasks
2525
- * @internal
2526
- */
2527
2454
  private registerStartupTasks;
2528
2455
  /**
2529
2456
  * Starts the bot and runs all initialization tasks
@@ -2538,5 +2465,5 @@ declare class Seedcord extends Pluggable implements Core {
2538
2465
  /** Package version */
2539
2466
  declare const version: string;
2540
2467
  //#endregion
2541
- export { type AllSubscriptions, ArraySource, AssignRoleErrorCtors, AutocompleteHandler, type AutocompleteOptions, AutocompleteRoute, type BotEvents, type BotPermissionScope, ButtonHandler, ButtonRoute, type CheckPermissionOptions, CommandMentions, type ConfirmOptions, ContextMenuHandler, ContextMenuRoute, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type FaultSource, FetchUserOptions, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, HasPermsToAssignOptions, HmrModuleHandler, IgnoreBots, type Initializeable, type InjectedEmojiMap, type InjectedMentionMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, ModalRoute, Nsfw, Paginator, type PaginatorControls, type PermissionErrorCtors, Pluggable, Plugin, type PluginArgs, type PluginCtor, RegisterCommand, RegisterEvent, type RegisterEventOptions, type Repliables, ReplySender, RequireBotPermissions, RequirePermissions, type RequirePermissionsOptions, RequireRole, type RequireRoleOptions, Seedcord, SelectMenuHandler, SelectMenuKind, SelectMenuRoute, SlashHandler, type SlashOptions, SlashRoute, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, fetchGuildMember, fetchManyGuildMembers, fetchManyUsers, fetchRole, fetchText, fetchUser, getBotRole, getConfirmation, hasPermsToAssign, updateMemberRoles, version };
2468
+ export { type AllSubscriptions, ArraySource, AssignRoleErrorCtors, AutocompleteHandler, type AutocompleteOptions, AutocompleteRoute, type BotEvents, type BotPermissionScope, ButtonHandler, ButtonRoute, type CheckPermissionOptions, CommandMentions, type ConfirmOptions, ContextMenuHandler, ContextMenuRoute, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type FaultSource, FetchUserOptions, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, HasPermsToAssignOptions, IgnoreBots, type Initializeable, type InjectedEmojiMap, type InjectedMentionMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, ModalRoute, Nsfw, Paginator, type PaginatorControls, type PermissionErrorCtors, Pluggable, Plugin, type PluginArgs, type PluginCtor, RegisterCommand, RegisterEvent, type RegisterEventOptions, type Repliables, ReplySender, RequireBotPermissions, RequirePermissions, type RequirePermissionsOptions, RequireRole, type RequireRoleOptions, Seedcord, SelectMenuHandler, SelectMenuKind, SelectMenuRoute, SlashHandler, type SlashOptions, SlashRoute, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, fetchGuildMember, fetchManyGuildMembers, fetchManyUsers, fetchRole, fetchText, fetchUser, getBotRole, getConfirmation, hasPermsToAssign, updateMemberRoles, version };
2542
2469
  //# sourceMappingURL=index.d.mts.map