@seedcord/gateway 0.1.0-next.4 → 0.1.0-next.5

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,20 +1,18 @@
1
1
  import { AnyCustomId, AutocompletableNames, BaseReplySender, ChoiceValueOf, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, MatchArms, ModalLike, PageCursor, SingleParams, SlashOptions as SlashOptions$1 } from "@seedcord/core/internal";
2
- import { AutocompleteOptions, BaseHandler, BuilderComponent, CoreBase, DispatchContext, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, Initializeable, Notice, PageView, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, SelectMenuKind, SlashOptionRegistry } from "@seedcord/core";
2
+ import { AutocompleteOptions, BaseHandler, BuilderComponent, Bus, CoreBase, DispatchContext, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, Initializeable, Notice, PageView, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, SelectMenuKind, SlashOptionRegistry, Subscriber as Subscriber$1, SubscriptionKey, WebhookLog as WebhookLog$1 } from "@seedcord/core";
3
3
  import { Logger } from "@seedcord/logger";
4
4
  import { ActionRowBuilder, ButtonBuilder, ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
5
5
  import { APIInteractionGuildMember, APIMessageComponentEmoji, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommand, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, 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 } from "discord.js";
6
- import { UUID } from "node:crypto";
7
- import { APIMessageTopLevelComponent } from "discord-api-types/v10";
8
- import { REST } from "@discordjs/rest";
6
+ import { Plugin as Plugin$1, PluginContext, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
9
7
  import { CoordinatedShutdown, CoordinatedStartup, Pluggable, PluginCapabilities } from "@seedcord/core/node/internal";
10
8
  import { SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
11
- import { TypedEventEmitter } from "@seedcord/event-emitter";
12
- import { BotConfig, Config, DeferOpts, EmojiMap, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter, ReplyResponse, SendOpts, V2Component } from "@seedcord/types";
9
+ import { REST } from "@discordjs/rest";
10
+ import { BotConfig, Config, DeferOpts, EmojiMap, EventFrequency, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter, ReplyResponse, SendOpts, TypedOmit, V2Component } from "@seedcord/types";
13
11
  export * from "@seedcord/errors";
14
12
  export * from "@seedcord/core";
15
13
  export * from "@seedcord/logger";
16
- export * from "@seedcord/utils";
17
14
  export * from "@seedcord/rate-limiter";
15
+ export * from "@seedcord/utils";
18
16
  export * from "@seedcord/event-emitter";
19
17
  export type * from "@seedcord/types";
20
18
 
@@ -26,11 +24,23 @@ declare module '@seedcord/core' {
26
24
  }
27
25
  }
28
26
  //#endregion
29
- //#region src/bot/utilities/miscellaneous/contextMenuLeaves.d.ts
30
- /** The registered context-menu command names, split by kind, deduplicated. @internal */
31
- interface ContextMenuLeaves {
32
- readonly user: Set<string>;
33
- readonly message: Set<string>;
27
+ //#region src/subscriptions.d.ts
28
+ declare module '@seedcord/core/internal' {
29
+ interface DefaultSubscriptions {
30
+ /** Triggered when an event dispatch throws past the fault boundary. */
31
+ unhandledEventError: {
32
+ error: Error;
33
+ };
34
+ /** Triggered for every client event the bot receives, before its handlers run. */
35
+ anyEvent: { [Name in keyof ClientEvents]: {
36
+ name: Name;
37
+ args: ClientEvents[Name];
38
+ } }[keyof ClientEvents];
39
+ /** Triggered for every interaction the bot receives, before routing. */
40
+ anyInteraction: {
41
+ interaction: Interaction;
42
+ };
43
+ }
34
44
  }
35
45
  //#endregion
36
46
  //#region src/interfaces/Config.d.ts
@@ -74,159 +84,11 @@ interface GatewayConfig extends Config {
74
84
  healthCheck?: HealthCheckOption;
75
85
  }
76
86
  //#endregion
77
- //#region src/subscribers/types/Subscriptions.d.ts
78
- /**
79
- * Where a reported fault came from.
80
- */
81
- type FaultSource = InteractionFaultSource | EventFaultSource;
82
- /**
83
- * A fault that came from a discord interaction, JSON-safe for a webhook payload.
84
- */
85
- interface InteractionFaultSource {
86
- kind: 'interaction';
87
- interactionKind: 'slash' | 'context-menu' | 'button' | 'select' | 'modal';
88
- /** Slash or context-menu command name, null for component and modal interactions. */
89
- command: string | null;
90
- /** Component or modal customId, null for slash and context-menu interactions. */
91
- customId: string | null;
92
- userId: string;
93
- /** Guild the interaction came from, null in DMs. */
94
- guildId: string | null;
95
- /** Channel the interaction came from, null when unavailable. */
96
- channelId: string | null;
97
- interactionId: string;
98
- /** The raw interaction, made JSON-safe at serialization with filterCirculars. */
99
- raw: unknown;
100
- }
101
- /**
102
- * A fault that came from a client event, JSON-safe for a webhook payload. The actor, guild, and channel
103
- * are best-effort, derived from the event args, so each is nullable. The raw args carry the full detail.
104
- */
105
- interface EventFaultSource {
106
- kind: 'event';
107
- eventName: string;
108
- handler: string;
109
- userId: string | null;
110
- /** Null outside a guild. */
111
- guildId: string | null;
112
- channelId: string | null;
113
- /** The raw event args, made JSON-safe at serialization with filterCirculars. */
114
- raw: unknown;
115
- }
116
- interface DefaultSubscriptions {
117
- /** Triggered when an unhandled exception (a raw non-Notice throw) occurs */
118
- unknownException: {
119
- uuid: UUID;
120
- error: Error;
121
- guild?: {
122
- id: string;
123
- name: string;
124
- } | undefined;
125
- user?: {
126
- id: string;
127
- username: string;
128
- } | undefined;
129
- metadata?: unknown;
130
- };
131
- /** Triggered when a reported Notice (`report: true`) is caught */
132
- handledException: {
133
- denial: Notice;
134
- uuid: UUID;
135
- source: FaultSource;
136
- };
137
- }
138
- /**
139
- * Custom subscribers defined by the application. Augment it via declaration merging to type your
140
- * own subscriber payloads.
141
- *
142
- * @example
143
- * ```typescript
144
- * declare module '@seedcord/gateway' {
145
- * interface Subscriptions {
146
- * 'userJoin': { userId: string; guildId: string };
147
- * 'levelUp': { userId: string; level: number };
148
- * }
149
- * }
150
- * ```
151
- */
152
- interface Subscriptions {}
153
- interface AllSubscriptions extends DefaultSubscriptions, Subscriptions {}
154
- /** All subscriber event names available to publish and augment. */
155
- type SubscriptionKey = keyof AllSubscriptions;
156
- /**
157
- * The payload type for a subscriber event.
158
- *
159
- * @typeParam KeyOfSubscribers - The subscriber event name
160
- */
161
- type SubscriptionData<KeyOfSubscribers extends SubscriptionKey> = AllSubscriptions[KeyOfSubscribers];
162
- type SubscriptionTuples = { [K in SubscriptionKey]: [AllSubscriptions[K]] };
163
- //#endregion
164
- //#region src/subscribers/Bus.d.ts
165
- /**
166
- * Registers and dispatches subscribers. Subscribers load from the configured directories and run
167
- * on a programmatic or framework-event publish. Accessed via `core.bus`. Do not construct it directly.
168
- */
169
- declare class Bus extends TypedEventEmitter<SubscriptionTuples> implements Initializeable, HmrAware {
170
- protected core: Core;
171
- readonly logger: Logger;
172
- private isInitialized;
173
- private readonly subscribersMap;
174
- private readonly executedOnceHandlers;
175
- private readonly webhookProbes;
176
- private readonly hmrHandler?;
177
- constructor(core: Core);
178
- private getArtifacts;
179
- /** @internal */
180
- init(): Promise<void>;
181
- /** @internal Exposed for tests. */
182
- verifyWebhooks(): Promise<void>;
183
- /** @internal */
184
- onHmr(event: HmrUpdateEvent): Promise<void>;
185
- private loadSubscribers;
186
- private registerSubscriber;
187
- private unregisterSubscriber;
188
- private isSubscriber;
189
- /**
190
- * Publishes an event to its subscribers and native listeners.
191
- *
192
- * Fire-and-forget, so subscriber handlers run asynchronously and this returns before they
193
- * complete, and callers must not assume side effects have landed. Errors thrown by a subscriber
194
- * are caught and logged, never surfaced here. A `'once'` subscriber is marked as executed when
195
- * it starts (even if it throws), so it never runs twice.
196
- *
197
- * @param event - The subscription key to publish
198
- * @param data - Payload passed to each subscriber
199
- * @returns Whether the underlying emitter had native listeners for the event
200
- */
201
- publish<KeyOfSubscribers extends SubscriptionKey>(event: KeyOfSubscribers, data: AllSubscriptions[KeyOfSubscribers]): boolean;
202
- private processSubscriber;
203
- }
204
- //#endregion
205
- //#region src/interfaces/Core.d.ts
206
- /**
207
- * Main interface for Seedcord core functionality
208
- *
209
- * This interface can be augmented via declaration merging to add
210
- * type-safe plugin definitions when using `this.core#` in handlers.
211
- *
212
- * Only add classes that extend {@link Plugin} to this
213
- *
214
- * @example
215
- * ```typescript
216
- * declare module '@seedcord/gateway' {
217
- * interface Core {
218
- * db: Mongo;
219
- * }
220
- * }
221
- * ```
222
- * */
223
- interface Core extends CoreBase, SeedcordInstance {
224
- readonly shutdown: CoordinatedShutdown;
225
- readonly startup: CoordinatedStartup;
226
- readonly bot: Bot;
227
- readonly bus: Bus;
228
- readonly config: GatewayConfig;
229
- start(): Promise<this>;
87
+ //#region src/bot/utilities/miscellaneous/contextMenuLeaves.d.ts
88
+ /** The registered context-menu command names, split by kind, deduplicated. @internal */
89
+ interface ContextMenuLeaves {
90
+ readonly user: Set<string>;
91
+ readonly message: Set<string>;
230
92
  }
231
93
  //#endregion
232
94
  //#region src/bot/controllers/CommandRegistry.d.ts
@@ -299,25 +161,10 @@ type InjectedEmojiMap = { [K in keyof EmojiMap]: EmojiMap[K] extends 'guild' ? G
299
161
  declare const Emojis: InjectedEmojiMap;
300
162
  //#endregion
301
163
  //#region src/bot/Bot.d.ts
302
- /**
303
- * Types of events emitted by the {@link Core.bot} instance.
304
- */
305
- interface BotEvents {
306
- /** Emitted when an unhandled interaction error occurs */
307
- 'error:unhandled:interaction': [error: Error];
308
- /** Emitted when an unhandled event error occurs */
309
- 'error:unhandled:event': [error: Error];
310
- /** Emitted for any event */
311
- 'any:event': { [K in keyof ClientEvents]: [K, ...ClientEvents[K]] }[keyof ClientEvents];
312
- /** Emitted for any interaction */
313
- 'any:interaction': [interaction: Interaction];
314
- /** @internal */
315
- ready: [];
316
- }
317
164
  /**
318
165
  * The Discord client and its controllers. Access it through `core.bot`.
319
166
  */
320
- declare class Bot extends TypedEventEmitter<BotEvents> implements Initializeable, HmrAware {
167
+ declare class Bot implements Initializeable, HmrAware {
321
168
  readonly botToken: string;
322
169
  /** @internal */
323
170
  readonly logger: Logger;
@@ -343,15 +190,31 @@ declare class Bot extends TypedEventEmitter<BotEvents> implements Initializeable
343
190
  private login;
344
191
  private logout;
345
192
  get client(): Client;
346
- /** @internal */
347
- emit<TKey extends keyof ClientEvents>(event: 'any:event', name: TKey, ...args: ClientEvents[TKey]): boolean;
348
- /** @internal */
349
- emit<TEventKey extends keyof BotEvents>(event: TEventKey, ...args: BotEvents[TEventKey]): boolean;
350
- /** @internal */
351
- emitSafe<TKey extends keyof ClientEvents>(event: 'any:event', name: TKey, ...args: ClientEvents[TKey]): boolean;
352
- /** @internal */
353
- emitSafe<TEventKey extends keyof BotEvents>(event: TEventKey, ...args: BotEvents[TEventKey]): boolean;
354
- protected onListenerError(error: unknown, event: string | symbol): void;
193
+ }
194
+ //#endregion
195
+ //#region src/interfaces/Core.d.ts
196
+ /**
197
+ * Main interface for Seedcord core functionality
198
+ *
199
+ * This interface can be augmented via declaration merging to add
200
+ * type-safe plugin definitions when using `this.core#` in handlers.
201
+ *
202
+ * Only add classes that extend {@link Plugin} to this
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * declare module '@seedcord/gateway' {
207
+ * interface Core {
208
+ * db: Mongoose;
209
+ * }
210
+ * }
211
+ * ```
212
+ * */
213
+ interface Core extends CoreBase {
214
+ readonly shutdown: Pick<CoordinatedShutdown, 'addTask'>;
215
+ readonly startup: Pick<CoordinatedStartup, 'addTask'>;
216
+ readonly bot: Bot;
217
+ readonly config: GatewayConfig;
355
218
  }
356
219
  //#endregion
357
220
  //#region src/handlers/interactionTypes.d.ts
@@ -569,7 +432,7 @@ type EventMatchArms<Names extends ValidNonInteractionKeys, Ret> = { [Name in Nam
569
432
  * }
570
433
  * ```
571
434
  */
572
- declare abstract class EventHandler<Names extends ValidNonInteractionKeys> extends BaseHandler$1<ClientEvents[Names]> {
435
+ declare abstract class EventHandler<in out Names extends ValidNonInteractionKeys> extends BaseHandler$1<ClientEvents[Names]> {
573
436
  private readonly firedEvent;
574
437
  constructor(event: ClientEvents[Names], core: Core, eventName?: Names);
575
438
  protected readonly event: SingleEventPayload<Names>;
@@ -625,12 +488,6 @@ declare abstract class EventMiddleware<in out EventName extends ValidNonInteract
625
488
  protected get eventName(): EventName;
626
489
  }
627
490
  //#endregion
628
- //#region src/miscellaneous/types.d.ts
629
- /**
630
- * The frequency at which the event handler should be executed.
631
- */
632
- type EventFrequency = 'once' | 'on';
633
- //#endregion
634
491
  //#region src/bot/decorators/Events.d.ts
635
492
  /** Options accepted by the event registration decorator. */
636
493
  interface RegisterEventOptions {
@@ -781,7 +638,7 @@ type SentMessage = Message;
781
638
  */
782
639
  declare class ReplySender extends BaseReplySender<SentMessage> {
783
640
  private readonly interaction;
784
- constructor(interaction: Repliables, routeId: string);
641
+ constructor(interaction: Repliables, routeId: string, bus?: Bus);
785
642
  protected writeReply(response: ReplyResponse | string, opts?: SendOpts): Promise<SentMessage | undefined>;
786
643
  protected writeDefer(opts?: DeferOpts): Promise<void>;
787
644
  protected writeDeferUpdate(): Promise<void>;
@@ -814,7 +671,7 @@ declare class ReplySender extends BaseReplySender<SentMessage> {
814
671
  declare abstract class RepliableHandler<Event extends Repliables> extends RepliableHandler$1<Event, Core, SentMessage, ReplySender> {
815
672
  /** @internal */
816
673
  getEvent(): Event;
817
- protected buildSender(event: Event, _core: Core, routeId: string): ReplySender;
674
+ protected buildSender(event: Event, core: Core, routeId: string): ReplySender;
818
675
  }
819
676
  //#endregion
820
677
  //#region src/handlers/interaction/InteractionHandler.d.ts
@@ -1258,7 +1115,7 @@ interface MiddlewareOptions<MType extends MiddlewareType, Events extends readonl
1258
1115
  * Interaction middleware cannot specify event filters.
1259
1116
  *
1260
1117
  * @param type - Middleware kind from {@link MiddlewareType}
1261
- * @param priority - Ordering value where lower runs earlier. {@default `0`}
1118
+ * @param priority - Ordering value where lower runs earlier. {@default `0` }
1262
1119
  * @param options - Additional registration options
1263
1120
  *
1264
1121
  * @decorator
@@ -1881,177 +1738,52 @@ declare class Paginator<Item, const Prefix extends string> {
1881
1738
  readonly Handler: PaginatorHandlerCtor<Prefix>;
1882
1739
  private readonly config;
1883
1740
  constructor(config: PaginatorConfig<Item, Prefix>);
1884
- /** Render page 0 and send it, picking reply or followUp from the interaction's state. */
1885
- start(interaction: Repliables, core?: Core): Promise<Message>;
1886
- /** Render a page as a {@link ReplyResponse}. To post it elsewhere, add `flags: MessageFlags.IsComponentsV2`. */
1887
- page(ctx: PageContext, n: number): Promise<ReplyResponse>;
1888
- }
1889
- //#endregion
1890
- //#region src/subscribers/Subscriber.d.ts
1891
- /**
1892
- * Abstract base class for handling application subscribers.
1893
- *
1894
- * Provides type-safe access to subscribers data and the core framework instance.
1895
- * Extend this class to create custom subscriber handlers.
1896
- *
1897
- * @typeParam KeyOfSubscribers - The specific subscriber type this handler processes
1898
- */
1899
- declare abstract class Subscriber<KeyOfSubscribers extends SubscriptionKey> {
1900
- protected readonly data: AllSubscriptions[KeyOfSubscribers];
1901
- protected readonly core: Core;
1902
- protected readonly logger: Logger;
1903
1741
  /**
1904
- * Instantiates the subscriber with event data and core.
1742
+ * Render page 0 and send it through the handler's sender, picking reply or followUp from its ack state.
1905
1743
  *
1906
- * @param data - The subscriber event data
1907
- * @param core - The core framework instance
1744
+ * @param handler - The handler starting the paginator, normally `this`.
1908
1745
  */
1909
- constructor(data: AllSubscriptions[KeyOfSubscribers], core: Core);
1910
- /**
1911
- * Executes the subscriber handler logic.
1912
- */
1913
- abstract execute(): Promise<void>;
1914
- }
1915
- //#endregion
1916
- //#region src/subscribers/decorators/Subscribe.d.ts
1917
- /**
1918
- * Options accepted by the `@Subscribe` decorator.
1919
- */
1920
- interface SubscribeOptions {
1921
- /**
1922
- * Frequency: `'once'` or `'on'`.
1923
- *
1924
- * @defaultValue `'on'`
1925
- */
1926
- readonly frequency?: EventFrequency | undefined;
1746
+ start(handler: RepliableHandler<Repliables>): Promise<Message>;
1747
+ /** Render a page as a {@link ReplyResponse}. To post it elsewhere, add `flags: MessageFlags.IsComponentsV2`. */
1748
+ page(ctx: PageContext, n: number): Promise<ReplyResponse>;
1927
1749
  }
1928
- /**
1929
- * Registers a subscriber handler class with a specific subscriber event.
1930
- *
1931
- * Associates the decorated class with a subscriber event type for automatic
1932
- * registration and execution when the subscriber is emitted.
1933
- *
1934
- * @typeParam TSubscriber - The subscriber event name to register for
1935
- * @param subscriber - The subscriber event name to register for
1936
- * @param options - Options to configure the subscriber handler registration.
1937
- * @decorator
1938
- * @example
1939
- * ```typescript
1940
- * \@Subscribe('userJoin')
1941
- * class WelcomeHandler extends Subscriber<'userJoin'> {
1942
- * async execute() {
1943
- * // Handle user join event
1944
- * }
1945
- * }
1946
- * ```
1947
- * @example
1948
- * ```ts
1949
- * \@Subscribe('userJoin', { frequency: 'once' })
1950
- * // or
1951
- * \@Subscribe('userJoin')
1952
- * ```
1953
- */
1954
- declare function Subscribe<TSubscriber extends SubscriptionKey>(subscriber: TSubscriber, options?: SubscribeOptions): <HandlerCtor extends Constructor<Subscriber<TSubscriber>>>(constructor: HandlerCtor) => void;
1955
1750
  //#endregion
1956
- //#region src/subscribers/bases/WebhookSender.d.ts
1751
+ //#region src/subscribers/index.d.ts
1957
1752
  /**
1958
- * A file attached to a webhook report.
1959
- */
1960
- interface WebhookFile {
1961
- name: string;
1962
- description: string;
1963
- data: Buffer;
1964
- }
1965
- /**
1966
- * The payload {@link WebhookSender.send} posts.
1967
- */
1968
- interface WebhookSendOptions {
1969
- flags: number;
1970
- username: string;
1971
- components: readonly {
1972
- toJSON(): APIMessageTopLevelComponent;
1973
- }[];
1974
- files?: readonly WebhookFile[] | undefined;
1975
- }
1976
- /**
1977
- * Sends component messages to a Discord webhook through `@discordjs/rest`.
1753
+ * Base class for a gateway subscriber, binding `this.core` to the gateway {@link Core}.
1978
1754
  *
1979
- * @throws A `SeedcordError` when the url does not carry a webhook id and token.
1980
- */
1981
- declare class WebhookSender {
1982
- private readonly rest;
1983
- private readonly route;
1984
- constructor(url: string);
1985
- /**
1986
- * Fetches the webhook object, sending no message. Returns `missing` on a 404 or 401 from
1987
- * Discord and `unreachable` on any other failure.
1988
- */
1989
- verify(): Promise<'ok' | 'missing' | 'unreachable'>;
1990
- send(options: WebhookSendOptions): Promise<void>;
1991
- }
1992
- //#endregion
1993
- //#region src/subscribers/bases/WebhookLog.d.ts
1994
- /**
1995
- * The content a reporter returns from {@link WebhookLog.report}.
1755
+ * @typeParam KeyOfSubscribers - The subscription key this handler receives
1996
1756
  */
1997
- interface WebhookReport {
1998
- /** Shown as the webhook message author. Defaults to the reporter's class name. */
1999
- username?: string;
2000
- components: readonly {
2001
- toJSON(): APIMessageTopLevelComponent;
2002
- }[];
2003
- files?: readonly WebhookFile[] | undefined;
2004
- }
1757
+ declare abstract class Subscriber<KeyOfSubscribers extends SubscriptionKey> extends Subscriber$1<KeyOfSubscribers, Core> {}
2005
1758
  /**
2006
- * Base class for subscribers that deliver their event to a Discord webhook.
2007
- *
2008
- * Declare the url's environment variable with `@WebhookUrl` and implement {@link report}. Url
2009
- * resolution, validation, sender reuse, and sending run in the base. When the variable is unset
2010
- * the reporter is skipped at registration with a boot warning.
1759
+ * Base class for a gateway subscriber that delivers its event to a Discord webhook, binding
1760
+ * `this.core` to the gateway {@link Core}.
2011
1761
  *
2012
1762
  * @typeParam KeyOfSubscribers - The subscription key this reporter receives
2013
1763
  */
2014
- declare abstract class WebhookLog<KeyOfSubscribers extends SubscriptionKey> extends Subscriber<KeyOfSubscribers> {
2015
- private static readonly senders;
2016
- /** Builds the message for one published event. */
2017
- abstract report(): WebhookReport | Promise<WebhookReport>;
2018
- execute(): Promise<void>;
2019
- /** @internal */
2020
- static senderFor(url: string): WebhookSender;
2021
- /** @internal */
2022
- static envKeyOf(ctor: NewableFunction): string;
2023
- /** @internal Returns null when the env var is unset, throws when set but malformed. */
2024
- static urlOf(envKey: string): string | null;
2025
- }
1764
+ declare abstract class WebhookLog<KeyOfSubscribers extends SubscriptionKey> extends WebhookLog$1<KeyOfSubscribers, Core> {}
2026
1765
  //#endregion
2027
- //#region src/subscribers/decorators/WebhookUrl.d.ts
1766
+ //#region src/plugin.d.ts
1767
+ /** The options a gateway plugin declares, narrowed to the transports this base serves. */
1768
+ type GatewayPluginOptions = TypedOmit<PluginOptions$1, 'transport'> & {
1769
+ transport?: 'gateway' | 'any';
1770
+ };
2028
1771
  /**
2029
- * Declares the environment variable a {@link WebhookLog} reporter reads its webhook url from.
1772
+ * Base class for a gateway plugin, binding `this.core` to the gateway {@link Core}.
2030
1773
  *
2031
- * An unset variable disables the reporter with a boot warning. A set but malformed value throws
2032
- * at boot.
1774
+ * A plugin that runs on either transport extends the base from `@seedcord/core/plugin`, whose
1775
+ * `this.core` carries the shared members only.
2033
1776
  *
2034
- * @param envKey - The environment variable name holding the webhook url
2035
- * @decorator
2036
- * @example
2037
- * ```ts
2038
- * \@Subscribe('memberBanned')
2039
- * \@WebhookUrl('BAN_LOG_WEBHOOK_URL')
2040
- * class BanLog extends WebhookLog<'memberBanned'> {
2041
- * report() {
2042
- * return { components: [new BanCard(this.data).component] };
2043
- * }
2044
- * }
2045
- * ```
1777
+ * @typeParam Opts - The transport, runtime, and capabilities the plugin declares.
2046
1778
  */
2047
- declare function WebhookUrl(envKey: string): <HandlerCtor extends Constructor<WebhookLog<SubscriptionKey>>>(constructor: HandlerCtor) => void;
1779
+ declare abstract class Plugin<Opts extends GatewayPluginOptions = {}> extends Plugin$1<Opts, Core> {}
2048
1780
  //#endregion
2049
1781
  //#region src/Seedcord.d.ts
2050
1782
  /**
2051
1783
  * The gateway bot host. Opens a discord.js gateway session, discovers handlers, and runs
2052
1784
  * coordinated startup and shutdown. Attach plugins with `attach()`.
2053
1785
  */
2054
- declare class Seedcord extends Pluggable implements Core {
1786
+ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, SeedcordInstance {
2055
1787
  readonly config: GatewayConfig;
2056
1788
  /** @internal */
2057
1789
  readonly [SeedcordBrand] = true;
@@ -2061,12 +1793,9 @@ declare class Seedcord extends Pluggable implements Core {
2061
1793
  readonly version: string;
2062
1794
  private readonly healthCheck?;
2063
1795
  private readonly hmrManager;
2064
- /** @see {@link CoordinatedShutdown} */
2065
- readonly shutdown: CoordinatedShutdown;
2066
- /** @see {@link CoordinatedStartup} */
2067
- readonly startup: CoordinatedStartup;
2068
1796
  /** @see {@link Bus} */
2069
1797
  readonly bus: Bus;
1798
+ private readonly subscribers;
2070
1799
  /** @see {@link Bot} */
2071
1800
  readonly bot: Bot;
2072
1801
  /** @see {@link IRateLimiter} */
@@ -2094,5 +1823,5 @@ declare class Seedcord extends Pluggable implements Core {
2094
1823
  /** Package version */
2095
1824
  declare const version: string;
2096
1825
  //#endregion
2097
- export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, type BotEvents, ButtonHandler, type CheckPermissionOptions, CommandMentions, type ConfirmOptions, ContextMenuHandler, 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 InjectedEmojiMap, type InjectedMentionMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, Nsfw, Paginator, type PaginatorControls, type PermissionErrorNoticeOverrides, RegisterEvent, type RegisterEventOptions, RepliableHandler, type Repliables, Seedcord, SelectMenuHandler, SlashHandler, type SlashOptions, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, type WebhookFile, WebhookLog, type WebhookReport, WebhookUrl, checkBotPermissions, checkPermissions, fetchGuildMember, fetchManyGuildMembers, fetchManyUsers, fetchRole, fetchText, fetchUser, getBotRole, getConfirmation, hasPermsToAssign, updateMemberRoles, version };
1826
+ export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, ButtonHandler, type CheckPermissionOptions, CommandMentions, type ConfirmOptions, ContextMenuHandler, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, FetchUserOptions, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, type GatewayPluginOptions, HasPermsToAssignOptions, IgnoreBots, type InjectedEmojiMap, type InjectedMentionMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, Nsfw, Paginator, type PaginatorControls, type PermissionErrorNoticeOverrides, Plugin, type PluginContext, type PluginLifecycleSpec, type PluginOptions, RegisterEvent, type RegisterEventOptions, RepliableHandler, type Repliables, Seedcord, SelectMenuHandler, SlashHandler, type SlashOptions, Subscriber, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, fetchGuildMember, fetchManyGuildMembers, fetchManyUsers, fetchRole, fetchText, fetchUser, getBotRole, getConfirmation, hasPermsToAssign, updateMemberRoles, version };
2098
1827
  //# sourceMappingURL=index.d.mts.map