@seedcord/gateway 0.9.0-next.0 → 0.9.0-next.3

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,15 +1,15 @@
1
1
  import "reflect-metadata";
2
2
  import { InFlight } from "@seedcord/core/node/internal";
3
3
  import { WinstonConsoleSink, WinstonFileSink } from "@seedcord/logger/node";
4
- import { AutocompletableNames, AutocompleteRouteBrand, CacheFor, ChoiceValueOf, CommandRegistry, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, ContextMenuLeaves, ContextMenuNamesBrand, EntryFor, FixedScope, FocusedField, GateFitsWith, HasComponentDefs, Initializeable, MatchArms, MenuCacheFor, MiddlewareKindsBrand, NamesFor, PageCursor, SingleParams, SlashOptions as SlashOptions$1, SlashRouteBrand } from "@seedcord/core/internal";
5
- import { ArraySourceBase, AutocompleteOptions, BaseHandler as BaseHandler$1, BaseReplySender, Bus, CoreBase, CursorSourceBase, DispatchContext, DispatchOutcome, DispatchResult, EventDispatchResult, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, HandlerOutcome, InteractionKind, MiddlewareKind, ModalLike, Notice, PageSourceBase, PaginatorBase, PaginatorConfig, PermissionNoticeOverrides, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, ResolvedEmoji, SlashRegistry, Subscriber as Subscriber$1, SubscriptionKey, WebhookLog as WebhookLog$1 } from "@seedcord/core";
4
+ import { AutocompletableNames, AutocompleteResponder, AutocompleteRouteBrand, CacheFor, CaseReturn, ChoiceValueOf, CommandRegistry, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, ContextMenuLeaves, ContextMenuNamesBrand, EntryFor, FixedScope, FocusedField, GateFitsWith, HasComponentDefs, Initializeable, MatchCases, MatchResult, MenuCacheFor, MiddlewareKindsBrand, MiddlewareRoute, NamesFor, OnlyCases, PageCursor, SingleParams, SlashOptions as SlashOptions$1, SlashRouteBrand } from "@seedcord/core/internal";
5
+ import { AppPermissionsContext, ArraySourceBase, AutocompleteOptions, BaseHandler as BaseHandler$1, BaseReplySender, Bus, CoreBase, CursorSourceBase, DispatchContext as DispatchContext$1, DispatchOutcome, DispatchResult, EventDispatchResult, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, HandlerOutcome, InteractionKind, MiddlewareKind, ModalLike, NoticeConstructor, PageSourceBase, PaginatorBase, PaginatorConfig, PermissionNoticeConstructor, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, ResolvedEmoji, SlashRegistry, Subscriber as Subscriber$1, SubscriptionKey, WebhookLog as WebhookLog$1 } from "@seedcord/core";
6
+ import { APIInteractionGuildMember, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BaseMessageOptions, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, CommandInteractionOption, ContextMenuCommandInteraction, Events, Guild, GuildBasedChannel, GuildEmoji, GuildMember, Interaction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitFields, ModalSubmitInteraction, Role, RoleSelectMenuInteraction, StringSelectMenuInteraction, User, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from "discord.js";
6
7
  import { Logger } from "@seedcord/logger";
7
- import { APIInteractionGuildMember, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BaseMessageOptions, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, CommandInteractionOption, ContextMenuCommandInteraction, Events, Guild, GuildEmoji, GuildMember, Interaction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitFields, ModalSubmitInteraction, Role, RoleSelectMenuInteraction, StringSelectMenuInteraction, TextChannel, User, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from "discord.js";
8
8
  import { Plugin as Plugin$1, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
9
9
  import { ServerHost, ShutdownTasks, StartupTasks } from "@seedcord/core/node";
10
10
  import { HostAugmentTarget, HostVersion, SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
11
- import { HmrModuleHandler } from "@seedcord/core/hmr";
12
11
  import { AnyCustomId } from "@seedcord/custom-id";
12
+ import { HmrModuleHandler } from "@seedcord/core/hmr";
13
13
  import { BotConfig, Config, DeferOpts, EmojiMap, EventFrequency, HealthCheckOption, HmrAware, HmrUpdateEvent, ReplyResponse, SendOpts, TypedOmit } from "@seedcord/types";
14
14
  import { Constructor, IsUnion, NonEmptyTuple, Promisable } from "type-fest";
15
15
  import { REST } from "@discordjs/rest";
@@ -109,25 +109,18 @@ declare class EventDispatcher implements Initializeable, HmrAware {
109
109
  private readonly middlewares;
110
110
  private readonly onceRuns;
111
111
  private readonly attachedEvents;
112
- private loading;
113
- private readonly loadedHandlers;
114
- private readonly loadedMiddlewares;
115
- private readonly hmrHandler?;
112
+ private readonly loader;
116
113
  constructor(core: Core, inFlight: InFlight);
117
114
  private getArtifacts;
118
115
  init(): Promise<void>;
119
116
  private reportLoad;
120
- private loadHandlers;
121
- private loadMiddlewares;
122
117
  /** @internal */
123
118
  onHmr(event: HmrUpdateEvent): Promise<void>;
124
119
  private unregisterHandler;
125
- private unregisterMiddleware;
126
- private registerMiddleware;
127
120
  private runMiddlewares;
128
121
  private isEventHandlerClass;
129
122
  private isMiddlewareClass;
130
- private registerHandler;
123
+ private storeHandler;
131
124
  private attachToClient;
132
125
  private attachListener;
133
126
  private reportUnhandled;
@@ -141,50 +134,23 @@ declare class InteractionDispatcher implements Initializeable, HmrAware {
141
134
  private readonly inFlight;
142
135
  private readonly logger;
143
136
  private isInitialized;
144
- private readonly maps;
145
- private readonly handlerFiles;
137
+ private readonly routes;
138
+ private get maps();
146
139
  private readonly keysToIgnore;
147
140
  private readonly middlewares;
148
- private loading;
149
- private readonly loadedHandlers;
150
- private readonly loadedMiddlewares;
151
- private readonly hmrHandler?;
141
+ private readonly loader;
152
142
  constructor(core: Core, inFlight: InFlight);
153
143
  warnUnhandledRoutes(commandLeaves: Iterable<string>): void;
154
144
  warnUnhandledContextMenuRoutes(leaves: ContextMenuLeaves): void;
155
- private getArtifacts;
156
145
  init(): Promise<void>;
157
146
  private reportLoad;
158
- private loadHandlers;
159
- private loadMiddlewares;
160
- private registerMiddleware;
161
147
  private isHandlerClass;
162
148
  private isMiddlewareClass;
163
- private registerHandler;
164
149
  onHmr(event: HmrUpdateEvent): Promise<void>;
165
- private unregisterHandler;
166
- private unregisterMiddleware;
167
150
  private attachToClient;
168
151
  private handleCustomIdInteraction;
169
152
  private processInteraction;
170
- private answer;
171
- private buildHandler;
172
- private reporterFor;
173
- private refusalBeforeHandler;
174
- private runMiddlewares;
175
- private gateRefusal;
176
153
  private handleInteraction;
177
- private handleSlashCommand;
178
- private handleButton;
179
- private handleModal;
180
- private handleStringSelectMenu;
181
- private handleUserSelectMenu;
182
- private handleRoleSelectMenu;
183
- private handleChannelSelectMenu;
184
- private handleMentionableSelectMenu;
185
- private handleMessageContextMenu;
186
- private handleUserContextMenu;
187
- private handleAutocomplete;
188
154
  }
189
155
  //#endregion
190
156
  //#region src/bot/Bot.d.ts
@@ -282,12 +248,12 @@ export declare abstract class BaseHandler<ValidEvent extends ValidEventTypes> ex
282
248
  type SingleEventPayload<Names extends ValidNonInteractionKeys> = IsUnion<Names> extends true ? never : ClientEvents[Names];
283
249
  //#endregion
284
250
  //#region src/handlers/event/EventHandler.d.ts
285
- type EventMatchArms<Names extends ValidNonInteractionKeys, Ret> = { [Name in Names]: (...args: ClientEvents[Name]) => Promisable<Ret>; };
251
+ type EventMatchCases<Names extends ValidNonInteractionKeys, Ret> = { [Name in Names]: (...args: ClientEvents[Name]) => CaseReturn<Ret>; };
286
252
  /**
287
253
  * Base class for a Discord client event handler.
288
254
  *
289
- * Pass the event name(s) as the generic, the same one(s) as `@RegisterEvent`. A single-event handler reads
290
- * `this.event` (the payload tuple) directly. A handler registered for several events branches with `this.match`,
255
+ * Pass the event name(s) as the generic, the same one(s) as `@RegisterEvent`. On a single-event handler, read
256
+ * `this.event` (the payload tuple) directly. On a handler registered for several events, branch with `this.match`,
291
257
  * keyed by event name, since the union of payload tuples is not directly readable.
292
258
  *
293
259
  * @typeParam Names - One or more `ClientEvents` keys, e.g. `Events.MessageCreate` or `Events.MessageCreate | Events.MessageUpdate`.
@@ -306,20 +272,22 @@ type EventMatchArms<Names extends ValidNonInteractionKeys, Ret> = { [Name in Nam
306
272
  * ```
307
273
  */
308
274
  export declare abstract class EventHandler<in out Names extends ValidNonInteractionKeys> extends BaseHandler<ClientEvents[Names]> {
309
- private readonly firedEvent;
310
- constructor(event: ClientEvents[Names], core: Core, dispatch: DispatchContext, eventName?: Names);
275
+ constructor(event: ClientEvents[Names], core: Core, dispatch: DispatchContext$1);
311
276
  protected readonly event: SingleEventPayload<Names>;
277
+ /** The event that started this dispatch, one of the names in the generic. */
278
+ protected readonly route: Names;
312
279
  /**
313
- * Run the arm for the current event. Use this only when the handler is registered for several
314
- * events. A single-event handler reads `this.event` directly. On a multi-event handler `this.event` is
280
+ * Run the case for the current event. Use this only when the handler is registered for several
281
+ * events. On a single-event handler, read `this.event` directly. On a multi-event handler `this.event` is
315
282
  * `never`, so match is the only way to read the payload.
316
283
  *
317
- * Provide one arm per registered event, keyed by its name, and each arm receives that event's own
318
- * payload tuple. The arms must cover every event in the generic, a missing event or an unknown key is a
284
+ * Provide one case per registered event, keyed by its name, and each case receives that event's own
285
+ * payload tuple. The cases must cover every event in the generic. A missing event or an unknown key is a
319
286
  * compile error.
320
287
  *
321
- * @param arms - One handler per registered event, keyed by event name.
322
- * @returns The result of the arm that ran.
288
+ * @param cases - One handler per registered event, keyed by event name.
289
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
290
+ * @returns The result of the case that ran.
323
291
  *
324
292
  * @example
325
293
  * ```ts
@@ -334,7 +302,7 @@ export declare abstract class EventHandler<in out Names extends ValidNonInteract
334
302
  * }
335
303
  * ```
336
304
  */
337
- protected match<Ret>(arms: EventMatchArms<Names, Ret>): Promise<Ret>;
305
+ protected match<Ret = never, Cases extends EventMatchCases<Names, Ret> = EventMatchCases<Names, Ret>>(cases: OnlyCases<Cases, EventMatchCases<Names, Ret>>): Promise<MatchResult<Ret, Cases>>;
338
306
  }
339
307
  //#endregion
340
308
  //#region src/handlers/event/EventMiddleware.d.ts
@@ -343,22 +311,20 @@ export declare abstract class EventHandler<in out Names extends ValidNonInteract
343
311
  *
344
312
  * Middleware runs before event handlers and can stop the event by throwing a `Silence`. Unlike `EventHandler`, it
345
313
  * runs the SAME for every event it is registered for, so it has no `match`. Specify a single event in the
346
- * generic and `{ events }` to read `this.event` fully typed. Span several events (or omit `{ events }` for a
347
- * catchall) and `this.event` narrows to `never`, read `this.eventName` and do work that does not depend on the
348
- * payload shape. A middleware that needs each event's payload is written one event per class.
314
+ * generic and `{ events }` to read `this.event` fully typed. If you span several events (or omit `{ events }` for
315
+ * a catchall), `this.event` narrows to `never`. Read `this.route` there, for work that doesn't depend on the
316
+ * payload shape. Write one class per event for a middleware that needs each event's payload.
349
317
  *
350
318
  * @typeParam EventName - One or more `ClientEvents` keys. Defaults to every event (catchall).
351
319
  */
352
320
  export declare abstract class EventMiddleware<in out EventName extends ValidNonInteractionKeys = ValidNonInteractionKeys> extends BaseHandler<ClientEvents[EventName]> {
353
- private readonly firedEvent;
354
- constructor(event: ClientEvents[EventName], core: Core, dispatch: DispatchContext, eventName?: EventName);
321
+ constructor(event: ClientEvents[EventName], core: Core, dispatch: DispatchContext$1);
355
322
  protected readonly event: SingleEventPayload<EventName>;
356
323
  /**
357
- * The name of the event being processed. Read it on a catchall or multi-event middleware, where `this.event`
358
- * is `never`, to do work that does not depend on the payload shape. A single-event middleware reads
359
- * `this.event` directly and does not need this.
324
+ * The event that started this dispatch, one of the names in the generic. Read it on a catchall or multi-event
325
+ * middleware, where `this.event` is `never`, to do work that doesn't depend on the payload shape.
360
326
  */
361
- protected get eventName(): EventName;
327
+ protected readonly route: EventName;
362
328
  /**
363
329
  * Runs once the event finishes, newest middleware first. Every middleware whose `execute()`
364
330
  * started gets the call, a stopped chain and a throw included. Implement it to release something
@@ -375,7 +341,7 @@ export declare abstract class EventMiddleware<in out EventName extends ValidNonI
375
341
  * }
376
342
  * ```
377
343
  */
378
- after?(result: EventDispatchResult): Promise<void>;
344
+ after?(result: EventDispatchResult): Promisable<void>;
379
345
  }
380
346
  //#endregion
381
347
  //#region src/bot/decorators/Events.d.ts
@@ -437,7 +403,7 @@ type SentMessage = Message;
437
403
  /** Writes interaction responses through discord.js. The repliable handler bases and the dispatcher construct it. */
438
404
  export declare class ReplySender extends BaseReplySender<SentMessage, GatewayFile> {
439
405
  private readonly interaction;
440
- constructor(interaction: Repliables, dispatch: DispatchContext, bus: Bus);
406
+ constructor(interaction: Repliables, dispatch: DispatchContext$1, bus: Bus);
441
407
  protected writeReply(response: GatewayReplyResponse | string, opts?: SendOpts): Promise<SentMessage | undefined>;
442
408
  protected writeDefer(opts?: DeferOpts): Promise<void>;
443
409
  protected writeDeferUpdate(): Promise<void>;
@@ -470,7 +436,8 @@ export declare class ReplySender extends BaseReplySender<SentMessage, GatewayFil
470
436
  export declare abstract class RepliableHandler<Event extends Repliables> extends RepliableHandler$1<Event, Core, SentMessage, GatewayFile, ReplySender> {
471
437
  /** @internal */
472
438
  getEvent(): Event;
473
- protected buildSender(event: Event, core: Core, dispatch: DispatchContext): ReplySender;
439
+ /** The user who sent this interaction. */
440
+ protected get user(): User;
474
441
  }
475
442
  //#endregion
476
443
  //#region src/handlers/interaction/InteractionHandler.d.ts
@@ -484,7 +451,7 @@ export declare abstract class RepliableHandler<Event extends Repliables> extends
484
451
  * @typeParam Repliable - The interaction type this handler processes
485
452
  */
486
453
  export declare abstract class InteractionHandler<Repliable extends Repliables> extends RepliableHandler<Repliable> {
487
- constructor(event: Repliable, core: Core, dispatch: DispatchContext);
454
+ constructor(event: Repliable, core: Core, dispatch: DispatchContext$1, sender: ReplySender);
488
455
  /**
489
456
  * Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at
490
457
  * compile time (Discord forbids a modal in response to a modal).
@@ -494,7 +461,7 @@ export declare abstract class InteractionHandler<Repliable extends Repliables> e
494
461
  //#endregion
495
462
  //#region src/bot/gates/Gate.d.ts
496
463
  /**
497
- * The interaction arm. It extends {@link GuildPermissionsContext} with the live interaction and
464
+ * The context a gate gets on an interaction. It extends {@link GuildPermissionsContext} with the live interaction and
498
465
  * the djs objects resolved from the gateway cache. `Repliable` is the interaction type the gate
499
466
  * supports, inferred from the `ctx` annotation, so a gate reading button-specific fields is rejected
500
467
  * on a slash handler. `interaction` is the reply target, so `user` is always present. Use
@@ -513,7 +480,7 @@ export declare abstract class InteractionHandler<Repliable extends Repliables> e
513
480
  * });
514
481
  * ```
515
482
  */
516
- interface InteractionGateContext<Repliable extends Repliables = Repliables> extends GuildPermissionsContext {
483
+ interface InteractionGateContext<Repliable extends Repliables = Repliables> extends GuildPermissionsContext, AppPermissionsContext {
517
484
  /** The literal `'interaction'`. Narrow on it before reading `interaction`. */
518
485
  readonly kind: 'interaction';
519
486
  /** The running framework, with the gateway's bot and bus. */
@@ -528,7 +495,7 @@ interface InteractionGateContext<Repliable extends Repliables = Repliables> exte
528
495
  readonly member: GuildMember | null;
529
496
  }
530
497
  /**
531
- * The event arm. It extends {@link GuildPermissionsContext} with the event payload and the djs
498
+ * The context a gate gets on an event. It extends {@link GuildPermissionsContext} with the event payload and the djs
532
499
  * objects derived from it. `Names` is the event(s) the gate supports, inferred from the `ctx`
533
500
  * annotation, so a gate that reads one event's `payload` is rejected on a handler for a different
534
501
  * event. The default supports every event.
@@ -570,7 +537,7 @@ interface EventGateContext<Names extends ValidNonInteractionKeys = ValidNonInter
570
537
  *
571
538
  * @example
572
539
  * ```ts
573
- * // a gate that handles either arm narrows on ctx.kind
540
+ * // a gate that takes either context narrows on ctx.kind
574
541
  * const Either = defineGate('either', (ctx: GateContext) => {
575
542
  * if (ctx.kind === 'interaction') void ctx.interaction;
576
543
  * else void ctx.payload;
@@ -589,7 +556,7 @@ interface Ungateable {
589
556
  readonly [UngateableBrand]: true;
590
557
  }
591
558
  type ProvidedContext<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends InteractionHandler<infer Repliable> ? InteractionGateContext<Repliable> : InstanceType<TCtor> extends EventHandler<infer Names> ? EventGateContext<Names> : Ungateable;
592
- type KindName<Ctx> = Ctx extends Ungateable ? 'autocomplete' : Ctx extends InteractionGateContext<infer R> ? R extends ChatInputCommandInteraction ? 'Slash' : R extends MessageContextMenuCommandInteraction ? 'MessageContextMenu' : R extends UserContextMenuCommandInteraction ? 'UserContextMenu' : R extends StringSelectMenuInteraction ? 'StringMenu' : R extends UserSelectMenuInteraction ? 'UserMenu' : R extends RoleSelectMenuInteraction ? 'RoleMenu' : R extends ChannelSelectMenuInteraction ? 'ChannelMenu' : R extends MentionableSelectMenuInteraction ? 'MentionableMenu' : R extends ButtonInteraction ? 'Button' : R extends ModalSubmitInteraction ? 'Modal' : 'an interaction' : Ctx extends EventGateContext<infer N> ? `${N & string} event` : 'an agnostic';
559
+ type KindName<Ctx> = Ctx extends Ungateable ? 'autocomplete' : Ctx extends InteractionGateContext<infer R> ? Repliables extends R ? 'generic interaction' : R extends ChatInputCommandInteraction ? 'Slash' : R extends MessageContextMenuCommandInteraction ? 'MessageContextMenu' : R extends UserContextMenuCommandInteraction ? 'UserContextMenu' : R extends StringSelectMenuInteraction ? 'StringMenu' : R extends UserSelectMenuInteraction ? 'UserMenu' : R extends RoleSelectMenuInteraction ? 'RoleMenu' : R extends ChannelSelectMenuInteraction ? 'ChannelMenu' : R extends MentionableSelectMenuInteraction ? 'MentionableMenu' : R extends ButtonInteraction ? 'Button' : R extends ModalSubmitInteraction ? 'Modal' : 'generic interaction' : Ctx extends EventGateContext<infer N> ? `${N & string} event` : Ctx extends AppPermissionsContext ? 'generic interaction' : 'any';
593
560
  type FitAll<TCtor extends AnyHandlerCtor, Gates extends readonly Gate<GateContextBase>[]> = { [Index in keyof Gates]: GateFitsWith<ProvidedContext<TCtor>, KindName<ProvidedContext<TCtor>>, Gates[Index], KindName<RequiredOf<Gates[Index]>>>; };
594
561
  //#endregion
595
562
  //#region src/bot/decorators/Gated.d.ts
@@ -600,7 +567,7 @@ type FitAll<TCtor extends AnyHandlerCtor, Gates extends readonly Gate<GateContex
600
567
  * handler) is a compile error at this line, and the error message shows the gate and the handler kind. Place it
601
568
  * above the route decorator.
602
569
  *
603
- * Combine gates with {@link and} or {@link or} to build a single gate from multiple arms.
570
+ * Combine gates into a single gate with {@link and} or {@link or}.
604
571
  *
605
572
  * @example
606
573
  * ```ts
@@ -683,13 +650,42 @@ export declare function RegisterEventMiddleware<const Events extends NonEmptyTup
683
650
  */
684
651
  export declare const IgnoreBots: import("@seedcord/core").Gate<EventGateContext<ValidNonInteractionKeys>, "IgnoreBots">;
685
652
  //#endregion
653
+ //#region src/bot/gates/catalog/MentionPrefix.d.ts
654
+ /**
655
+ * Passes only a message that starts with a mention of the bot, like `@bot ping`. It ignores every other message
656
+ * with a {@link Silence}, including a reply that pings the bot, a role mention, and a mention later in the text.
657
+ *
658
+ * On `messageUpdate` it passes only when the edit adds the mention. An edit that keeps the mention doesn't run the
659
+ * handler again. With `Partials.Message` on, discord.js also emits an edit to a message it didn't cache. That edit
660
+ * runs the handler again. Attach the gate without calling it, since it doesn't take options.
661
+ *
662
+ * A handler behind this gate can read `content` without the Message Content intent, because Discord sends the text of
663
+ * a message that mentions the bot.
664
+ *
665
+ * @see {@link Gated}
666
+ *
667
+ * @example
668
+ * ```ts
669
+ * import { Events } from 'discord.js';
670
+ *
671
+ * \@Gated(IgnoreBots, MentionPrefix)
672
+ * \@RegisterEvent([Events.MessageCreate], [Events.MessageUpdate])
673
+ * class MentionCommands extends EventHandler<Events.MessageCreate | Events.MessageUpdate> {
674
+ * async execute() {
675
+ * // ...
676
+ * }
677
+ * }
678
+ * ```
679
+ */
680
+ export declare const MentionPrefix: import("@seedcord/core").Gate<EventGateContext<"messageCreate" | "messageUpdate">, "MentionPrefix">;
681
+ //#endregion
686
682
  //#region src/bot/gates/catalog/Nsfw.d.ts
687
683
  /**
688
- * Requires an age-restricted channel, else refuses. Pass {@link GateNoticeOptions} to reword or replace the refusal.
684
+ * Requires an age-restricted channel, else refuses. Pass a Notice class as `notice` to replace the refusal.
689
685
  *
690
686
  * A thread inherits its parent channel's nsfw flag. ModalSubmit has no reliable channel, so it is excluded.
691
687
  *
692
- * @param options - Reword the default refusal with `message`, or replace it with `notice`.
688
+ * @param options - Replace the refusal with a Notice class as `notice`.
693
689
  *
694
690
  * @see {@link Gated}
695
691
  *
@@ -728,130 +724,97 @@ type InjectedEmojiMap = { [K in keyof EmojiMap]: EmojiMap[K] extends 'guild' ? G
728
724
  */
729
725
  export declare const Emojis: InjectedEmojiMap;
730
726
  //#endregion
731
- //#region src/bot/utilities/permissions/checkBotPermissions.d.ts
732
- /**
733
- * Checks the bot's own permissions in a {@link Guild} or {@link TextChannel}. Refuses when a permission in
734
- * `scope` is missing, or with `inverse` when one is present. When the bot member is uncached, the refusal
735
- * reports every permission in `scope` as missing.
736
- *
737
- * @example
738
- * ```ts
739
- * import { PermissionFlagsBits } from 'discord.js';
740
- * import { checkBotPermissions } from '@seedcord/gateway';
741
- *
742
- * checkBotPermissions(textChannel, [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel]);
743
- * ```
744
- */
745
- export declare function checkBotPermissions(target: Guild | TextChannel, scope: PermissionScope, inverse?: boolean, errors?: PermissionNoticeOverrides): void;
746
- //#endregion
747
727
  //#region src/bot/utilities/permissions/checkPermissions.d.ts
748
728
  /** Options for {@link checkPermissions}. */
749
- interface CheckPermissionOptions extends PermissionNoticeOverrides {
729
+ interface CheckPermissionOptions {
750
730
  /** The role or member to check. */
751
731
  for: Role | GuildMember;
752
- /** A guild reads the base bits from roles, a text channel reads the overwrite-resolved set. */
753
- in: Guild | TextChannel;
732
+ /** A channel or thread, to read the set after its overwrites. Leave it out to read the base set from roles. */
733
+ in?: GuildBasedChannel | undefined;
754
734
  /** The permission flag bits to check. */
755
735
  scope: PermissionScope;
756
736
  /** Refuse when the target holds a scope bit. */
757
737
  inverse?: boolean;
738
+ /** Your Notice class, thrown in place of the default refusal. seedcord constructs it with the target's mention and the refused names. */
739
+ notice?: PermissionNoticeConstructor | undefined;
758
740
  }
759
741
  /**
760
- * Checks a {@link Role} or a {@link GuildMember} against the base permission bits in a {@link Guild},
761
- * before channel overwrites. Refuses when a permission in `scope` is missing, or with `inverse` when one
762
- * is present.
742
+ * Checks a {@link Role} or a {@link GuildMember} against the base permission set from roles, or against a
743
+ * channel's set when `in` is given. Refuses when a permission in `scope` is missing, or with `inverse` when
744
+ * one is present.
745
+ *
746
+ * @throws A {@link Notice} when the check refuses. It lists the missing or present permissions.
763
747
  *
764
748
  * @example
765
749
  * ```ts
766
750
  * import { PermissionFlagsBits } from 'discord.js';
767
751
  * import { checkPermissions } from '@seedcord/gateway';
768
752
  *
769
- * checkPermissions(role, guild, [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.KickMembers]);
753
+ * checkPermissions({ for: member, scope: [PermissionFlagsBits.KickMembers] });
754
+ * checkPermissions({ for: role, in: channel, scope: [PermissionFlagsBits.SendMessages] });
770
755
  * ```
771
756
  *
772
757
  * @example
773
758
  * ```ts
774
- * // refuse when the member holds Administrator, and replace the refusal
775
- * checkPermissions(member, guild, [PermissionFlagsBits.Administrator], true, {
776
- * dangerousNotice: CustomDangerousNotice
777
- * });
759
+ * // refuse when the member holds Administrator, with your own Notice class
760
+ * checkPermissions({ for: member, scope: [PermissionFlagsBits.Administrator], inverse: true, notice: TooPowerful });
778
761
  * ```
779
762
  */
780
- export declare function checkPermissions(target: Role | GuildMember, ctx: Guild, scope: PermissionScope, inverse?: boolean, errors?: PermissionNoticeOverrides): void;
763
+ export declare function checkPermissions({ for: target, in: channel, scope, inverse, notice }: CheckPermissionOptions): void;
764
+ //#endregion
765
+ //#region src/bot/utilities/permissions/checkBotPermissions.d.ts
766
+ /** Options for {@link checkBotPermissions}. */
767
+ interface CheckBotPermissionOptions extends TypedOmit<CheckPermissionOptions, 'for' | 'in'> {
768
+ /** A guild, to read the bot's base set from roles, or a channel or thread, to read its set there. */
769
+ in: Guild | GuildBasedChannel;
770
+ }
781
771
  /**
782
- * Checks a {@link Role} or a {@link GuildMember} against the overwrite-resolved set in a
783
- * {@link TextChannel}. Refuses when a permission in `scope` is missing, or with `inverse` when one is
784
- * present.
785
- *
786
- * @example
787
- * ```ts
788
- * import { PermissionFlagsBits } from 'discord.js';
789
- * import { checkPermissions } from '@seedcord/gateway';
772
+ * Checks the bot's own permissions in a {@link Guild}, or in a channel or thread. Refuses when a permission
773
+ * in `scope` is missing, or with `inverse` when one is present.
790
774
  *
791
- * checkPermissions(role, textChannel, [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel]);
792
- * ```
793
- */
794
- export declare function checkPermissions(target: Role | GuildMember, ctx: TextChannel, scope: PermissionScope, inverse?: boolean, errors?: PermissionNoticeOverrides): void;
795
- /**
796
- * Checks permissions with an options object. Refuses when a permission in
797
- * {@link CheckPermissionOptions.scope} is missing, or with `options.inverse` when one is present.
775
+ * @throws A {@link Notice} when the check refuses. It lists the missing or present permissions.
776
+ * @throws A **SeedcordError** when the guild's member cache doesn't hold the bot's member.
798
777
  *
799
778
  * @example
800
779
  * ```ts
801
780
  * import { PermissionFlagsBits } from 'discord.js';
802
- * import { checkPermissions } from '@seedcord/gateway';
781
+ * import { checkBotPermissions } from '@seedcord/gateway';
803
782
  *
804
- * checkPermissions({
805
- * for: member,
806
- * in: textChannel,
807
- * scope: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel]
808
- * });
783
+ * checkBotPermissions({ in: channel, scope: [PermissionFlagsBits.SendMessages, PermissionFlagsBits.ViewChannel] });
809
784
  * ```
810
785
  */
811
- export declare function checkPermissions(options: CheckPermissionOptions): void;
786
+ export declare function checkBotPermissions({ in: where, ...check }: CheckBotPermissionOptions): void;
812
787
  //#endregion
813
788
  //#region src/bot/utilities/permissions/hasPermsToAssign.d.ts
814
- /**
815
- * Optional custom error constructors for {@link HasPermsToAssignOptions}.
816
- */
817
- export interface AssignRoleNoticeOverrides {
818
- higherNotice?: new (message: string, role: Role, botRole: Role) => Notice;
819
- managedNotice?: new (message: string) => Notice;
820
- missingNotice?: new (message: string | undefined, subject: string, missingPerms: readonly string[]) => Notice;
821
- }
822
- /**
823
- * Options for {@link hasPermsToAssign}.
824
- */
789
+ /** Options for {@link hasPermsToAssign}. */
825
790
  export interface HasPermsToAssignOptions {
826
- targetRole: Role;
827
- noticeOverrides?: AssignRoleNoticeOverrides;
791
+ /** The role the bot would assign. */
792
+ role: Role;
793
+ /** Your Notice class, constructed with both roles and thrown in place of the refusal when the role is at or above the bot's. */
794
+ higher?: NoticeConstructor<[role: Role, botRole: Role]>;
795
+ /** Your Notice class, constructed with the role and thrown in place of the refusal when an integration manages the role. */
796
+ managed?: NoticeConstructor<[role: Role]>;
797
+ /** Your Notice class, thrown when the bot lacks Manage Roles. seedcord constructs it with the bot's mention and that permission's name. */
798
+ missing?: PermissionNoticeConstructor;
828
799
  }
829
800
  /**
830
- * Validates that the bot can assign a target role. Refuses when the target role is above the bot's, is managed, or the bot lacks Manage Roles.
801
+ * Validates that the bot can assign a role. Refuses when the role is at or above the bot's, when an
802
+ * integration manages it, or when the bot lacks Manage Roles.
831
803
  *
832
- * @param roleOrOptions - Target role or complete options for the check
833
804
  * @throws A {@link Notice} when the check refuses.
834
- * @throws A **SeedcordError** when the bot has no role in the guild's role cache.
805
+ * @throws A **SeedcordError** when the guild's caches don't hold the bot's role or member.
835
806
  *
836
807
  * @example
837
808
  * ```ts
838
809
  * import { hasPermsToAssign } from '@seedcord/gateway';
839
810
  *
840
- * // Check if the bot can assign a specific role
841
- * hasPermsToAssign(role);
811
+ * hasPermsToAssign({ role });
842
812
  *
843
- * // Check with custom error handling
844
- * hasPermsToAssign({
845
- * targetRole: role,
846
- * noticeOverrides: {
847
- * higherNotice: CustomHigherNotice,
848
- * managedNotice: CustomManagedNotice,
849
- * missingNotice: CustomMissingPermissionsNotice
850
- * }
851
- * });
813
+ * // with your own Notice classes
814
+ * hasPermsToAssign({ role, higher: RoleTooHigh, managed: RoleIsManaged, missing: CannotManageRoles });
852
815
  * ```
853
816
  */
854
- export declare function hasPermsToAssign(roleOrOptions: Role | HasPermsToAssignOptions): void;
817
+ export declare function hasPermsToAssign({ role, higher, managed, missing }: HasPermsToAssignOptions): void;
855
818
  //#endregion
856
819
  //#region src/bot/confirm/getConfirmation.d.ts
857
820
  type Outcome = ReplyResponse | (() => Promisable<ReplyResponse>);
@@ -1022,7 +985,15 @@ type InteractionOf<Kind extends MiddlewareKind> = InteractionForKind[Kind];
1022
985
  export declare abstract class InteractionMiddleware<in out Kind extends MiddlewareKind = MiddlewareKind> extends RepliableHandler<InteractionOf<Kind>> {
1023
986
  /** @internal */
1024
987
  readonly [MiddlewareKindsBrand]?: Kind;
1025
- constructor(event: InteractionOf<Kind>, core: Core, dispatch: DispatchContext, sender: ReplySender);
988
+ constructor(event: InteractionOf<Kind>, core: Core, dispatch: DispatchContext$1, sender: ReplySender);
989
+ /**
990
+ * What started this dispatch: a slash command path like `config/set`, a context menu command's
991
+ * name, or a custom-ID prefix. When the generic lists only slash or context menu kinds, your editor
992
+ * offers your registered commands. It can still be any string, since middleware also runs when no
993
+ * handler matched, like on a deleted command that Discord still shows. For a custom ID that seedcord
994
+ * didn't make, it can be empty or a cut-off piece of that ID.
995
+ */
996
+ protected readonly route: MiddlewareRoute<Kind>;
1026
997
  /**
1027
998
  * Runs once the handler settles, newest middleware first. A refusal or a throw still reaches it,
1028
999
  * since seedcord calls it on every middleware whose `execute()` started. Implement it to release
@@ -1039,7 +1010,7 @@ export declare abstract class InteractionMiddleware<in out Kind extends Middlewa
1039
1010
  * }
1040
1011
  * ```
1041
1012
  */
1042
- after?(result: DispatchResult): Promise<void>;
1013
+ after?(result: DispatchResult): Promisable<void>;
1043
1014
  }
1044
1015
  //#endregion
1045
1016
  //#region src/inputs/SlashOptions.d.ts
@@ -1066,13 +1037,14 @@ interface GatewayLens<Cache extends CacheType> {
1066
1037
  type SlashOptions<Route extends keyof SlashRegistry, Cache extends CacheType = CacheFor<Route>> = SlashOptions$1<Route, GatewayLens<Cache>>;
1067
1038
  //#endregion
1068
1039
  //#region src/handlers/interaction/SlashHandler.d.ts
1069
- type SlashMatchArms<Route extends keyof SlashRegistry, Cache extends CacheType, Ret> = { [Key in Route]: (options: SlashOptions<Key, Cache>) => Promisable<Ret>; };
1040
+ type CaseCache<Route extends keyof SlashRegistry, Cache extends CacheType, Key extends Route> = [Cache] extends [CacheFor<Route>] ? CacheFor<Key> : Cache;
1041
+ type SlashMatchCases<Route extends keyof SlashRegistry, Cache extends CacheType, Ret> = { [Key in Route]: (options: SlashOptions<Key, CaseCache<Route, Cache, Key>>) => CaseReturn<Ret>; };
1070
1042
  /**
1071
1043
  * Base class for a chat-input (slash) command handler.
1072
1044
  *
1073
1045
  * Pass the route from the generated registry as the generic, the same string as `@SlashRoute`, then read
1074
1046
  * `this.options` for a single command or `this.match` for several. Command authoring stays plain
1075
- * discord.js, `seedcord codegen` reads its `toJSON()` to type these options.
1047
+ * discord.js. `seedcord codegen` reads its `toJSON()` to type these options.
1076
1048
  *
1077
1049
  * @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'ban'` or `'ban' | 'kick'`.
1078
1050
  * @typeParam Cache - The interaction cache state. The command's contexts set it.
@@ -1092,31 +1064,31 @@ export declare abstract class SlashHandler<Route extends keyof SlashRegistry, Ca
1092
1064
  /** @internal */
1093
1065
  readonly [SlashRouteBrand]?: Route;
1094
1066
  /** The selected command's path, such as `search/docs`. */
1095
- protected get route(): Route;
1067
+ protected readonly route: Route;
1096
1068
  /**
1097
1069
  * The typed options for this command's route. Only the getters for kinds this command declares appear.
1098
1070
  * Each getter's name argument is restricted to that command's options of its kind.
1099
1071
  *
1100
- * - A required option drops the null.
1072
+ * - A required option's getter never returns `null`.
1101
1073
  *
1102
1074
  * - Choices narrow to their literal union.
1103
1075
  *
1104
1076
  * - A channel option declared with `addChannelTypes` narrows to those types.
1105
1077
  *
1106
1078
  * Use `this.event.options` directly for anything outside this view, such as `getSubcommand()`.
1107
- * However, for the common case, the methods in this would suffice.
1108
1079
  */
1109
1080
  protected get options(): SlashOptions<Route, Cache>;
1110
1081
  /**
1111
- * Run the arm for the selected command. Use this only when the handler is registered for several
1082
+ * Run the case for the selected command. Use this only when the handler is registered for several
1112
1083
  * routes.
1113
1084
  *
1114
- * Provide one arm per registered route, keyed by its route string, and each arm receives that route's
1115
- * own narrowed options. The arms must cover every route in the generic, a missing route or an unknown
1085
+ * Provide one case per registered route, keyed by its route string, and each case receives that route's
1086
+ * own narrowed options. The cases must cover every route in the generic. A missing route or an unknown
1116
1087
  * key is a compile error.
1117
1088
  *
1118
- * @param arms - One handler per registered route, keyed by route string.
1119
- * @returns The result of the arm that ran.
1089
+ * @param cases - One handler per registered route, keyed by route string.
1090
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
1091
+ * @returns The result of the case that ran.
1120
1092
  *
1121
1093
  * @example
1122
1094
  * ```ts
@@ -1131,12 +1103,12 @@ export declare abstract class SlashHandler<Route extends keyof SlashRegistry, Ca
1131
1103
  * }
1132
1104
  * ```
1133
1105
  */
1134
- protected match<Ret>(arms: SlashMatchArms<Route, Cache, Ret>): Promise<Ret>;
1106
+ protected match<Ret = never, Cases extends SlashMatchCases<Route, Cache, Ret> = SlashMatchCases<Route, Cache, Ret>>(cases: OnlyCases<Cases, SlashMatchCases<Route, Cache, Ret>>): Promise<MatchResult<Ret, Cases>>;
1135
1107
  }
1136
1108
  //#endregion
1137
1109
  //#region src/handlers/interaction/ContextMenuHandler.d.ts
1138
- type UserMenuArms<Names extends NamesFor<ApplicationCommandType.User>, Ret> = { [Name in Names]: (target: User, member: CacheTypeReducer<MenuCacheFor<ApplicationCommandType.User, Name>, GuildMember, APIInteractionGuildMember> | null) => Promisable<Ret>; };
1139
- type MessageMenuArms<Names extends NamesFor<ApplicationCommandType.Message>, Ret> = { [Name in Names]: (target: Message<BooleanCache<MenuCacheFor<ApplicationCommandType.Message, Name>>>) => Promisable<Ret>; };
1110
+ type UserMenuCases<Names extends NamesFor<ApplicationCommandType.User>, Ret> = { [Name in Names]: (target: User, member: CacheTypeReducer<MenuCacheFor<ApplicationCommandType.User, Name>, GuildMember, APIInteractionGuildMember> | null) => CaseReturn<Ret>; };
1111
+ type MessageMenuCases<Names extends NamesFor<ApplicationCommandType.Message>, Ret> = { [Name in Names]: (target: Message<BooleanCache<MenuCacheFor<ApplicationCommandType.Message, Name>>>) => CaseReturn<Ret>; };
1140
1112
  /**
1141
1113
  * Base class for a user context-menu command handler (right-click a user).
1142
1114
  *
@@ -1165,18 +1137,19 @@ export declare abstract class UserContextMenuHandler<Names extends NamesFor<Appl
1165
1137
  /** The right-clicked user's guild member, null outside a guild. */
1166
1138
  protected get targetMember(): CacheTypeReducer<Cache, GuildMember, APIInteractionGuildMember> | null;
1167
1139
  /** The selected context-menu command's name, without the interaction-kind prefix. */
1168
- protected get route(): Names;
1140
+ protected readonly route: Names;
1169
1141
  /**
1170
- * Run the arm for the selected command. Use this only when the handler is registered for several
1142
+ * Run the case for the selected command. Use this only when the handler is registered for several
1171
1143
  * names.
1172
1144
  *
1173
- * Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
1174
- * arm receives the clicked user and that user's guild member, both narrowed to the cache state of that
1175
- * one command. The arms must cover every name in the generic. A missing name or an unknown key is a
1145
+ * Provide one case per registered name, keyed by the name Discord shows in the right-click menu. Each
1146
+ * case receives the clicked user and that user's guild member, both narrowed to the cache state of that
1147
+ * one command. The cases must cover every name in the generic. A missing name or an unknown key is a
1176
1148
  * compile error.
1177
1149
  *
1178
- * @param arms - One handler per registered command name.
1179
- * @returns The result of the arm that ran.
1150
+ * @param cases - One handler per registered command name.
1151
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
1152
+ * @returns The result of the case that ran.
1180
1153
  *
1181
1154
  * @example
1182
1155
  * ```ts
@@ -1191,7 +1164,7 @@ export declare abstract class UserContextMenuHandler<Names extends NamesFor<Appl
1191
1164
  * }
1192
1165
  * ```
1193
1166
  */
1194
- protected match<Ret>(arms: UserMenuArms<Names, Ret>): Promise<Ret>;
1167
+ protected match<Ret = never, Cases extends UserMenuCases<Names, Ret> = UserMenuCases<Names, Ret>>(cases: OnlyCases<Cases, UserMenuCases<Names, Ret>>): Promise<MatchResult<Ret, Cases>>;
1195
1168
  }
1196
1169
  /**
1197
1170
  * Base class for a message context-menu command handler (right-click a message).
@@ -1219,17 +1192,18 @@ export declare abstract class MessageContextMenuHandler<Names extends NamesFor<A
1219
1192
  readonly [ContextMenuNamesBrand]?: Names;
1220
1193
  protected get target(): Message<BooleanCache<Cache>>;
1221
1194
  /** The selected context-menu command's name, without the interaction-kind prefix. */
1222
- protected get route(): Names;
1195
+ protected readonly route: Names;
1223
1196
  /**
1224
- * Run the arm for the selected command. Use this only when the handler is registered for several
1197
+ * Run the case for the selected command. Use this only when the handler is registered for several
1225
1198
  * names.
1226
1199
  *
1227
- * Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
1228
- * arm receives the clicked message, narrowed to the cache state of that one command. The arms must
1200
+ * Provide one case per registered name, keyed by the name Discord shows in the right-click menu. Each
1201
+ * case receives the clicked message, narrowed to the cache state of that one command. The cases must
1229
1202
  * cover every name in the generic. A missing name or an unknown key is a compile error.
1230
1203
  *
1231
- * @param arms - One handler per registered command name.
1232
- * @returns The result of the arm that ran.
1204
+ * @param cases - One handler per registered command name.
1205
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
1206
+ * @returns The result of the case that ran.
1233
1207
  *
1234
1208
  * @example
1235
1209
  * ```ts
@@ -1244,11 +1218,11 @@ export declare abstract class MessageContextMenuHandler<Names extends NamesFor<A
1244
1218
  * }
1245
1219
  * ```
1246
1220
  */
1247
- protected match<Ret>(arms: MessageMenuArms<Names, Ret>): Promise<Ret>;
1221
+ protected match<Ret = never, Cases extends MessageMenuCases<Names, Ret> = MessageMenuCases<Names, Ret>>(cases: OnlyCases<Cases, MessageMenuCases<Names, Ret>>): Promise<MatchResult<Ret, Cases>>;
1248
1222
  }
1249
1223
  //#endregion
1250
1224
  //#region src/handlers/interaction/AutocompleteHandler.d.ts
1251
- type FocusedArms<Route extends keyof SlashRegistry, Ret> = { [Name in AutocompletableNames<Route>]: (value: string, respond: (choices: readonly ApplicationCommandOptionChoiceData<ChoiceValueOf<EntryFor<Route, Name>>>[]) => Promise<void>) => Promisable<Ret>; };
1225
+ type FocusedCases<Route extends keyof SlashRegistry, Ret> = { [Name in AutocompletableNames<Route>]: (value: string, respond: (choices: readonly ApplicationCommandOptionChoiceData<ChoiceValueOf<EntryFor<Route, Name>>>[]) => Promise<void>) => CaseReturn<Ret>; };
1252
1226
  /**
1253
1227
  * Base class for a Discord autocomplete handler.
1254
1228
  *
@@ -1272,9 +1246,12 @@ type FocusedArms<Route extends keyof SlashRegistry, Ret> = { [Name in Autocomple
1272
1246
  * ```
1273
1247
  */
1274
1248
  export declare abstract class AutocompleteHandler<Route extends keyof SlashRegistry, Cache extends CacheType = CacheFor<Route>> extends BaseHandler<AutocompleteInteraction<Cache>> {
1249
+ #private;
1275
1250
  /** @internal */
1276
1251
  readonly [AutocompleteRouteBrand]?: Route;
1277
- constructor(event: AutocompleteInteraction<Cache>, core: Core, dispatch: DispatchContext);
1252
+ constructor(event: AutocompleteInteraction<Cache>, core: Core, dispatch: DispatchContext$1, responder: AutocompleteResponder<ApplicationCommandOptionChoiceData>);
1253
+ /** The user who sent this interaction. */
1254
+ protected get user(): User;
1278
1255
  private decodedFocused?;
1279
1256
  /**
1280
1257
  * The focused option for this interaction. `value` is always the raw partial string the user is typing,
@@ -1282,16 +1259,17 @@ export declare abstract class AutocompleteHandler<Route extends keyof SlashRegis
1282
1259
  */
1283
1260
  protected get focused(): FocusedField<Route>;
1284
1261
  /**
1285
- * Run the arm for the focused field. Because an autocomplete always dispatches by which field is
1262
+ * Run the case for the focused field. Because an autocomplete always dispatches by which field is
1286
1263
  * focused, match is how you read it. There is no single-field shortcut the way slash/component handlers have one.
1287
1264
  *
1288
- * Provide one arm per autocompletable field across the registered commands, keyed by field name. Each
1289
- * arm receives the focused partial value and a `respond` typed to that field's choice value. The
1290
- * arms must cover every autocompletable field. A missing field or an unknown key is a compile error.
1265
+ * Provide one case per autocompletable field across the registered commands, keyed by field name. Each
1266
+ * case receives the focused partial value and a `respond` typed to that field's choice value. The
1267
+ * cases must cover every autocompletable field. A missing field or an unknown key is a compile error.
1291
1268
  *
1292
- * @param arms - One handler per autocompletable field, keyed by field name.
1293
- * @returns The result of the arm that ran.
1294
- * @throws A **SeedcordTypeError** with `MatchArmMissing` when the focused field has no arm. Only a stale-deployed command can send one.
1269
+ * @param cases - One handler per autocompletable field, keyed by field name.
1270
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
1271
+ * @returns The result of the case that ran.
1272
+ * @throws A **SeedcordTypeError** with `MatchCaseMissing` when the focused field doesn't have a case. Only a stale-deployed command can send one.
1295
1273
  *
1296
1274
  * @example
1297
1275
  * ```ts
@@ -1306,11 +1284,11 @@ export declare abstract class AutocompleteHandler<Route extends keyof SlashRegis
1306
1284
  * }
1307
1285
  * ```
1308
1286
  */
1309
- protected match<Ret>(arms: FocusedArms<Route, Ret>): Promise<Ret>;
1287
+ protected match<Ret = never, Cases extends FocusedCases<Route, Ret> = FocusedCases<Route, Ret>>(cases: OnlyCases<Cases, FocusedCases<Route, Ret>>): Promise<MatchResult<Ret, Cases>>;
1310
1288
  /** Send autocomplete suggestions, callback type 8. Prefer {@link match}, which restricts each field's choices to its declared type. */
1311
1289
  protected respond(choices: readonly ApplicationCommandOptionChoiceData[]): Promise<void>;
1312
1290
  /** The selected command's path, such as `search/docs`, without the interaction-kind prefix. */
1313
- protected get route(): Route;
1291
+ protected readonly route: Route;
1314
1292
  /**
1315
1293
  * The already-entered options on this command, restricted to the kinds Discord resolves during autocomplete
1316
1294
  * (string, integer, number, boolean) with every read nullable, since a sibling is partial while the user
@@ -1339,13 +1317,8 @@ export declare abstract class ComponentHandler<Event extends ComponentInteractio
1339
1317
  protected deferUpdate(): Promise<void>;
1340
1318
  private decoded?;
1341
1319
  private get decodedRoute();
1342
- /**
1343
- * The matched custom-ID prefix, such as `approve`, without encoded params.
1344
- *
1345
- * @throws A **StaleCustomId** when the wire was encoded under an older shape.
1346
- * @throws An **InvalidCustomId** when the wire is corrupt.
1347
- */
1348
- protected get route(): Defs[number]['prefix'];
1320
+ /** The matched custom-ID prefix, such as `approve`, without encoded params. */
1321
+ protected readonly route: Defs[number]['prefix'];
1349
1322
  /**
1350
1323
  * The decoded params of the single route this handler is registered for.
1351
1324
  *
@@ -1357,17 +1330,18 @@ export declare abstract class ComponentHandler<Event extends ComponentInteractio
1357
1330
  */
1358
1331
  protected get params(): SingleParams<Defs>;
1359
1332
  /**
1360
- * Run the arm for whichever route the component was minted from. Use this only when the handler is
1361
- * registered for several routes. A single-route handler reads `this.params` directly. On a multi-route
1333
+ * Run the case for whichever route the component was minted from. Use this only when the handler is
1334
+ * registered for several routes. On a single-route handler, read `this.params` directly. On a multi-route
1362
1335
  * handler `this.params` is `never`, leaving match as the only way to read the decoded params.
1363
1336
  *
1364
- * Provide one arm per registered route, keyed by its prefix, and each arm receives that route's own
1365
- * decoded params. The compiler checks that the arms cover every registered route prefix. `match`
1366
- * decodes the wire before it runs an arm.
1337
+ * Provide one case per registered route, keyed by its prefix, and each case receives that route's own
1338
+ * decoded params. The compiler checks that the cases cover every registered route prefix. `match`
1339
+ * decodes the wire before it runs a case.
1367
1340
  *
1368
- * @param arms - One callback per registered route, keyed by prefix.
1369
- * @returns The result of the arm that ran.
1370
- * @throws A **SeedcordTypeError** with `MatchArmMissing` when the wire's prefix has no arm.
1341
+ * @param cases - One callback per registered route, keyed by prefix.
1342
+ * @typeParam Ret - The type that every case must return. Leave it out to get the union of what the cases return.
1343
+ * @returns The result of the case that ran.
1344
+ * @throws A **SeedcordTypeError** with `MatchCaseMissing` when the wire's prefix doesn't have a case.
1371
1345
  * @throws A **StaleCustomId** when the wire was encoded under an older shape.
1372
1346
  * @throws An **InvalidCustomId** when the wire is corrupt.
1373
1347
  *
@@ -1384,7 +1358,7 @@ export declare abstract class ComponentHandler<Event extends ComponentInteractio
1384
1358
  * }
1385
1359
  * ```
1386
1360
  */
1387
- protected match<Ret>(arms: MatchArms<Defs, Ret>): Promise<Ret>;
1361
+ protected match<Ret = never, Cases extends MatchCases<Defs, Ret> = MatchCases<Defs, Ret>>(cases: OnlyCases<Cases, MatchCases<Defs, Ret>>): Promise<MatchResult<Ret, Cases>>;
1388
1362
  }
1389
1363
  //#endregion
1390
1364
  //#region src/handlers/interaction/components/ButtonHandler.d.ts
@@ -1687,14 +1661,14 @@ export declare class CursorSource<Item> extends CursorSourceBase<Item, PageConte
1687
1661
  /**
1688
1662
  * Base class for a gateway subscriber, binding `this.core` to the gateway {@link Core}.
1689
1663
  *
1690
- * @typeParam KeyOfSubscribers - The subscription key this handler receives
1664
+ * @typeParam KeyOfSubscribers - The subscription key or keys that this handler receives, the same ones as `@Subscribe`
1691
1665
  */
1692
1666
  export declare abstract class Subscriber<KeyOfSubscribers extends SubscriptionKey> extends Subscriber$1<KeyOfSubscribers, Core> {}
1693
1667
  /**
1694
1668
  * Base class for a gateway subscriber that delivers its event to a Discord webhook, binding
1695
1669
  * `this.core` to the gateway {@link Core}.
1696
1670
  *
1697
- * @typeParam KeyOfSubscribers - The subscription key this reporter receives
1671
+ * @typeParam KeyOfSubscribers - The subscription key or keys that this reporter receives, the same ones as `@Subscribe`
1698
1672
  */
1699
1673
  export declare abstract class WebhookLog<KeyOfSubscribers extends SubscriptionKey> extends WebhookLog$1<KeyOfSubscribers, Core> {}
1700
1674
  //#endregion
@@ -1714,8 +1688,8 @@ declare const GATEWAY_SCOPE: {
1714
1688
  /**
1715
1689
  * Base class for a gateway plugin, binding `this.core` to the gateway {@link Core}.
1716
1690
  *
1717
- * A plugin that runs on either transport extends the base from `@seedcord/core/plugin`, whose
1718
- * `this.core` is typed to the shared members only.
1691
+ * To run on either transport, extend the base from `@seedcord/core/plugin`. Its `this.core` carries
1692
+ * only the shared members.
1719
1693
  *
1720
1694
  * @typeParam Opts - The transport and runtime the plugin declares.
1721
1695
  */
@@ -1772,5 +1746,5 @@ export declare class Seedcord extends ServerHost<'gateway'> implements SeedcordI
1772
1746
  /** Package version */
1773
1747
  export declare const version: string;
1774
1748
  //#endregion
1775
- export { type CheckPermissionOptions, type ConfirmOptions, type Core, type DefaultConfirmOptions, type EventGateContext, type EventMiddlewareOptions, type EventSpec, type EventsConfig, type GateContext, type GatewayBotConfig, type GatewayConfig, type GatewayFile, type GatewayPluginOptions, type GatewayReplyResponse, HmrModuleHandler, type InjectedEmojiMap, type InteractionGateContext, type PageContext, type PageSource, type PluginLifecycleSpec, type PluginOptions, type RegisterEventOptions, type Repliables, type SentMessage, type SlashOptions, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WinstonConsoleSink, WinstonFileSink };
1749
+ export { type CheckBotPermissionOptions, type CheckPermissionOptions, type ConfirmOptions, type Core, type DefaultConfirmOptions, type EventGateContext, type EventMiddlewareOptions, type EventSpec, type EventsConfig, type GateContext, type GatewayBotConfig, type GatewayConfig, type GatewayFile, type GatewayPluginOptions, type GatewayReplyResponse, HmrModuleHandler, type InjectedEmojiMap, type InteractionGateContext, type PageContext, type PageSource, type PluginLifecycleSpec, type PluginOptions, type RegisterEventOptions, type Repliables, type SentMessage, type SlashOptions, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WinstonConsoleSink, WinstonFileSink };
1776
1750
  //# sourceMappingURL=index.d.mts.map