@seedcord/http 0.9.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,8 +8,8 @@
8
8
  <div align="center">
9
9
  <h3>The whole Discord bot, typed end to end</h3>
10
10
  <a href="https://seedcord.org">Website</a> ·
11
- <a href="https://guide.seedcord.org">Guide</a> ·
12
- <a href="https://docs.seedcord.org">Reference</a> ·
11
+ <a href="https://seedcord.org/guide">Guide</a> ·
12
+ <a href="https://seedcord.org/docs">Reference</a> ·
13
13
  <a href="https://discord.gg/DzFxY58WXf">Discord</a>
14
14
  </div>
15
15
 
@@ -0,0 +1,476 @@
1
+ import { AutocompletableNames, AutocompleteRouteBrand, ChoiceValueOf, ComponentDefsBrand, ComponentKindBrand, EntryFor, FocusedField, HasComponentDefs, MatchArms, MiddlewareKindsBrand, SingleParams, StoredSubscriberCtor } from "@seedcord/core/internal";
2
+ import { REST } from "@discordjs/rest";
3
+ import { AutocompleteOptions, BaseHandler, BaseReplySender, Bus, CoreBase, DispatchContext, DispatchResult, InteractionKind, MiddlewareKind, ModalLike, RepliableHandler, SlashRegistry } from "@seedcord/core";
4
+ import { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandOptionChoice, APIChatInputApplicationCommandInteraction, APIContextMenuInteraction, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, APIMessage, APIMessageApplicationCommandInteraction, APIMessageChannelSelectInteractionData, APIMessageComponentButtonInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, APIMessageMentionableSelectInteractionData, APIMessageRoleSelectInteractionData, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIModalInteractionResponseCallbackData, APIModalSubmitInteraction, APIRole, APIUser, APIUserApplicationCommandInteraction } from "discord-api-types/v10";
5
+ import { API } from "@discordjs/core/http-only";
6
+ import { AnyCustomId } from "@seedcord/custom-id";
7
+ import { Collection } from "@discordjs/collection";
8
+ import { CoordinatedShutdown, CoordinatedStartup } from "@seedcord/core/node";
9
+ import { Config, DeferOpts, ReplyResponse, SendOpts, TypedConstructor } from "@seedcord/types";
10
+ import { Constructor, Promisable } from "type-fest";
11
+ //#region src/interfaces/Config.d.ts
12
+ /**
13
+ * Config for a long-running node server. Pass to `new Seedcord(config).start()`.
14
+ */
15
+ interface HttpServerConfig extends Config {
16
+ runtime?: 'server';
17
+ /**
18
+ * Port the interactions server uses.
19
+ *
20
+ * @defaultValue `3000`
21
+ */
22
+ port?: number;
23
+ }
24
+ /**
25
+ * Config for a bundled isolate deployment. `seedcord build` generates a worker entry that calls
26
+ * `createSeedcord`.
27
+ */
28
+ interface HttpEdgeConfig extends Config {
29
+ runtime: 'edge';
30
+ port?: never;
31
+ lifecycle?: never;
32
+ }
33
+ /**
34
+ * The http transport's configuration, discriminated on `runtime`.
35
+ */
36
+ type HttpConfig = HttpServerConfig | HttpEdgeConfig;
37
+ //#endregion
38
+ //#region src/interfaces/Core.d.ts
39
+ /**
40
+ * Main interface for Seedcord core functionality on the HTTP transport.
41
+ *
42
+ * This interface can be augmented via declaration merging to add type-safe plugin definitions when
43
+ * using `this.core` in handlers.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * declare module '@seedcord/http' {
48
+ * interface Core {
49
+ * db: Mongoose;
50
+ * }
51
+ * }
52
+ * ```
53
+ */
54
+ interface Core extends CoreBase {
55
+ readonly shutdown: Pick<CoordinatedShutdown, 'addTask'>;
56
+ readonly startup: Pick<CoordinatedStartup, 'addTask'>;
57
+ readonly config: HttpConfig;
58
+ }
59
+ //#endregion
60
+ //#region src/handlers/interaction/AutocompleteHandler.d.ts
61
+ type FocusedArms<Route extends keyof SlashRegistry, Ret> = { [Name in AutocompletableNames<Route>]: (value: string, respond: (choices: readonly APIApplicationCommandOptionChoice<ChoiceValueOf<EntryFor<Route, Name>>>[]) => Promise<void>) => Promisable<Ret>; };
62
+ /**
63
+ * Base class for an autocomplete handler on the HTTP transport.
64
+ *
65
+ * Pass the command route(s) from the generated registry as the generic. Branch on the focused field with
66
+ * `this.match`, read already-entered sibling options with `this.options`, and find which command fired
67
+ * with `this.route`.
68
+ *
69
+ * @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'search'`.
70
+ */
71
+ declare abstract class AutocompleteHandler<Route extends keyof SlashRegistry> extends BaseHandler<APIApplicationCommandAutocompleteInteraction, Core> {
72
+ constructor(event: APIApplicationCommandAutocompleteInteraction, core: Core, dispatch: DispatchContext);
73
+ /** @internal */
74
+ readonly [AutocompleteRouteBrand]?: Route;
75
+ /**
76
+ * Typed Discord REST API (`@discordjs/core/http-only`) over `core.rest`, one instance per core.
77
+ */
78
+ protected get api(): API;
79
+ private resolver?;
80
+ private get reader();
81
+ /**
82
+ * The focused option for this interaction. `value` is always the raw partial string the user is typing,
83
+ * even for an integer or number option, so coerce it yourself when you need a number.
84
+ */
85
+ protected get focused(): FocusedField<Route>;
86
+ /**
87
+ * Run the arm for the focused field. An autocomplete always dispatches by which field is focused.
88
+ * Match is how you read it.
89
+ *
90
+ * Provide one arm per autocompletable field across the registered commands, keyed by field name. Each
91
+ * arm receives the focused partial value and a `respond` typed to that field's choice value. The
92
+ * arms must cover every autocompletable field, a missing field or an unknown key is a compile error. A
93
+ * focused field with no arm, only reachable from a stale-deployed command, throws at runtime.
94
+ *
95
+ * @param arms - One handler per autocompletable field, keyed by field name.
96
+ * @returns The result of the arm that ran.
97
+ */
98
+ protected match<Ret>(arms: FocusedArms<Route, Ret>): Promise<Ret>;
99
+ /** Send autocomplete suggestions, callback type 8. Prefer {@link match}, which restricts each field's choices to its declared type. */
100
+ protected respond(choices: readonly APIApplicationCommandOptionChoice[]): Promise<void>;
101
+ /** The firing command route, for a field whose completion differs per registered command. */
102
+ protected get route(): Route;
103
+ /**
104
+ * The already-entered options on this command, restricted to the kinds Discord resolves during autocomplete
105
+ * (string, integer, number, boolean) with every read nullable, since a sibling is partial while the user
106
+ * types the focused field. The focused field is on `this.focused`.
107
+ */
108
+ protected get options(): AutocompleteOptions<Route>;
109
+ }
110
+ //#endregion
111
+ //#region src/reply/ReplySender.d.ts
112
+ /** The interaction payload fields the sender writes its wire from. */
113
+ interface InteractionRef {
114
+ readonly application_id: string;
115
+ readonly id: string;
116
+ readonly token: string;
117
+ }
118
+ /** The created message an http reply resolves to (the http `SentMessage` lens). */
119
+ type SentMessage = APIMessage;
120
+ /**
121
+ * Writes interaction responses over the Discord REST callback and webhook endpoints. Construction is
122
+ * internal to the repliable handler bases and the dispatcher.
123
+ */
124
+ declare class ReplySender extends BaseReplySender<SentMessage> {
125
+ private readonly ref;
126
+ private readonly rest;
127
+ constructor(ref: InteractionRef, rest: REST, dispatch: DispatchContext, bus: Bus);
128
+ protected writeReply(response: ReplyResponse | string, opts?: SendOpts): Promise<SentMessage | undefined>;
129
+ protected writeDefer(opts?: DeferOpts): Promise<void>;
130
+ protected writeDeferUpdate(): Promise<void>;
131
+ protected writeUpdate(response: ReplyResponse | string): Promise<SentMessage | undefined>;
132
+ protected writeFollowUp(response: ReplyResponse | string, opts?: SendOpts): Promise<SentMessage>;
133
+ protected writeEditOriginal(response: ReplyResponse | string): Promise<SentMessage>;
134
+ protected writeEditTarget(targetId: string, response: ReplyResponse | string): Promise<SentMessage>;
135
+ protected writeDeleteOriginal(): Promise<void>;
136
+ protected writeDeleteTarget(targetId: string): Promise<void>;
137
+ protected writeModal(data: APIModalInteractionResponseCallbackData): Promise<void>;
138
+ private callback;
139
+ private editMessage;
140
+ private rawFiles;
141
+ private createdMessage;
142
+ }
143
+ //#endregion
144
+ //#region src/handlers/interactionTypes.d.ts
145
+ type ValidInteractionTypes = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction | APIMessageComponentInteraction | APIModalSubmitInteraction | APIApplicationCommandAutocompleteInteraction;
146
+ type Repliables = Exclude<ValidInteractionTypes, APIApplicationCommandAutocompleteInteraction>;
147
+ //#endregion
148
+ //#region src/handlers/RepliableHandler.d.ts
149
+ /**
150
+ * Shared base the repliable HTTP interaction handlers extend.
151
+ *
152
+ * Not a public entry point. Extend {@link SlashHandler}, {@link ButtonHandler}, {@link ModalHandler},
153
+ * {@link ContextMenuHandler}, or one of the select menu bases instead. This class binds the core
154
+ * reply base to the http sender.
155
+ *
156
+ * @typeParam Event - The repliable interaction type this handler processes
157
+ */
158
+ declare abstract class RepliableHandler$1<Event extends Repliables> extends RepliableHandler<Event, Core, SentMessage, never, ReplySender> {
159
+ /** @internal */
160
+ getEvent(): Event;
161
+ protected buildSender(event: Event, core: Core, dispatch: DispatchContext): ReplySender;
162
+ /**
163
+ * Typed Discord REST API (`@discordjs/core/http-only`) over `core.rest`, one instance per core.
164
+ * The interaction callbacks on `api.interactions` bypass the reply surface. The
165
+ * `no-raw-interaction-acks` rule flags them in handler classes.
166
+ */
167
+ protected get api(): API;
168
+ }
169
+ //#endregion
170
+ //#region src/handlers/interaction/InteractionHandler.d.ts
171
+ /**
172
+ * Shared base the repliable interaction handlers extend.
173
+ *
174
+ * Not a public entry point. Extend {@link SlashHandler}, {@link ContextMenuHandler}, {@link ButtonHandler},
175
+ * {@link ModalHandler}, or one of the select menu bases instead. This class adds `showModal` on top
176
+ * of the reply members.
177
+ *
178
+ * @typeParam Event - The repliable interaction type this handler processes
179
+ */
180
+ declare abstract class InteractionHandler<Event extends Repliables> extends RepliableHandler$1<Event> {
181
+ constructor(event: Event, core: Core, dispatch: DispatchContext);
182
+ /**
183
+ * Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at
184
+ * compile time (Discord forbids a modal in response to a modal).
185
+ */
186
+ protected showModal(this: InteractionHandler<Exclude<Repliables, APIModalSubmitInteraction>>, modal: ModalLike): Promise<void>;
187
+ }
188
+ //#endregion
189
+ //#region src/handlers/interaction/components/ComponentHandler.d.ts
190
+ /**
191
+ * Shared base the customId-routed component handlers extend on the HTTP transport.
192
+ *
193
+ * Not a public entry point. Extend {@link ButtonHandler}, {@link ModalHandler}, or one of the select menu
194
+ * bases instead. This class defines the customId decode, the route matching, and the source-message
195
+ * verbs `update` and `deferUpdate`.
196
+ *
197
+ * @typeParam Event - The component or modal interaction type this handler processes
198
+ * @typeParam Defs - The customId route definitions registered on the concrete handler
199
+ */
200
+ declare abstract class ComponentHandler<Event extends APIMessageComponentInteraction | APIModalSubmitInteraction, Defs extends readonly AnyCustomId[]> extends InteractionHandler<Event> implements HasComponentDefs<Defs> {
201
+ /** @internal */
202
+ readonly [ComponentDefsBrand]?: Defs;
203
+ /** Rewrite the source message this component interaction came from. */
204
+ protected update(response: ReplyResponse | string): Promise<SentMessage>;
205
+ /** Acknowledge the component without changing the source message. */
206
+ protected deferUpdate(): Promise<void>;
207
+ private decoded?;
208
+ private get route();
209
+ /**
210
+ * The decoded params of the single route this handler is registered for.
211
+ *
212
+ * Reading this decodes `this.event.data.custom_id` once (cached after the first read) and throws
213
+ * `StaleCustomId` or `InvalidCustomId` when the wire no longer matches the current shape, which the
214
+ * dispatcher boundary turns into a reply. On a handler registered for several routes this is
215
+ * `never`, so use {@link match} instead.
216
+ */
217
+ protected get params(): SingleParams<Defs>;
218
+ /**
219
+ * Run the arm for whichever route the component was minted from. Use this only when the handler is
220
+ * registered for several routes. A single-route handler reads `this.params` directly. On a multi-route
221
+ * handler `this.params` is `never`, so match is the only way to read the decoded params.
222
+ *
223
+ * Provide one arm per registered route, keyed by its prefix, and each arm receives that route's own
224
+ * decoded params. The arms cover every registered route prefix, checked at compile time, and a prefix
225
+ * unmatched at runtime throws `CustomIdMatchArmMissing`. Decoding runs before any arm, so a stale or
226
+ * corrupt wire throws before an arm body executes.
227
+ *
228
+ * @param arms - One callback per registered route, keyed by prefix.
229
+ * @returns The result of the arm that ran.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * \@ButtonRoute(Approve, Reject)
234
+ * class ReviewButtons extends ButtonHandler<[typeof Approve, typeof Reject]> {
235
+ * async execute() {
236
+ * await this.match({
237
+ * approve: ({ userId }) => this.reply(`approved <@${userId}>`),
238
+ * reject: ({ userId }) => this.reply(`rejected <@${userId}>`)
239
+ * });
240
+ * }
241
+ * }
242
+ * ```
243
+ */
244
+ protected match<Ret>(arms: MatchArms<Defs, Ret>): Promise<Ret>;
245
+ }
246
+ //#endregion
247
+ //#region src/handlers/interaction/components/SelectMenuHandler.d.ts
248
+ /** @internal */
249
+ type SelectInteraction<Data> = APIMessageComponentSelectMenuInteraction & {
250
+ data: Data;
251
+ };
252
+ /**
253
+ * Shared base the select menu handlers extend on the HTTP transport.
254
+ *
255
+ * Not a public entry point. Extend {@link StringMenuHandler}, {@link UserMenuHandler},
256
+ * {@link RoleMenuHandler}, {@link ChannelMenuHandler}, or {@link MentionableMenuHandler} instead. This
257
+ * class defines the `values` getter those bases share.
258
+ *
259
+ * @typeParam Event - The select menu interaction type this handler processes
260
+ * @typeParam Defs - The customId route definitions registered on the concrete handler
261
+ */
262
+ declare abstract class SelectMenuHandler<Event extends APIMessageComponentSelectMenuInteraction, Defs extends readonly AnyCustomId[]> extends ComponentHandler<Event, Defs> {
263
+ /** The values this select picked. On every kind but the string menu they are snowflake ids. */
264
+ protected get values(): string[];
265
+ }
266
+ /**
267
+ * Base class for a string select menu handler on the HTTP transport.
268
+ *
269
+ * Register the customId definitions with `@StringMenuRoute`, list the same ones in the generic, then read
270
+ * the chosen option values from `this.values`. Read `this.params` for a single route or `this.match` for
271
+ * several. Reply through the handler members, or rewrite the source message with `this.update`.
272
+ *
273
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof TopicsId]`.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * \@StringMenuRoute(TopicsId)
278
+ * class Topics extends StringMenuHandler<[typeof TopicsId]> {
279
+ * async execute() {
280
+ * const { userId } = this.params;
281
+ * await this.update(`<@${userId}> now follows ${this.values.join(', ')}`);
282
+ * }
283
+ * }
284
+ * ```
285
+ */
286
+ declare abstract class StringMenuHandler<Defs extends readonly AnyCustomId[]> extends SelectMenuHandler<SelectInteraction<APIMessageStringSelectInteractionData>, Defs> {
287
+ /** @internal */
288
+ readonly [ComponentKindBrand]?: InteractionKind.StringMenu;
289
+ }
290
+ /**
291
+ * Base class for a user select menu handler on the HTTP transport.
292
+ *
293
+ * Beside `this.values` this handler declares `this.users` and `this.members`. Register the customId
294
+ * definitions with `@UserMenuRoute` and list the same ones in the generic.
295
+ *
296
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof AssignId]`.
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * \@UserMenuRoute(AssignId)
301
+ * class Assign extends UserMenuHandler<[typeof AssignId]> {
302
+ * async execute() {
303
+ * const { roleId } = this.params;
304
+ * await this.reply(`assigning ${this.users.size} member(s) to <@&${roleId}>`);
305
+ * }
306
+ * }
307
+ * ```
308
+ */
309
+ declare abstract class UserMenuHandler<Defs extends readonly AnyCustomId[]> extends SelectMenuHandler<SelectInteraction<APIMessageUserSelectInteractionData>, Defs> {
310
+ /** @internal */
311
+ readonly [ComponentKindBrand]?: InteractionKind.UserMenu;
312
+ /** The users this select picked. */
313
+ protected get users(): Collection<string, APIUser>;
314
+ /** The guild members behind the picked users. Discord resolves these only inside a guild. */
315
+ protected get members(): Collection<string, APIInteractionDataResolvedGuildMember>;
316
+ }
317
+ /**
318
+ * Base class for a role select menu handler on the HTTP transport.
319
+ *
320
+ * Beside `this.values` this handler declares `this.roles`. Register the customId definitions with
321
+ * `@RoleMenuRoute` and list the same ones in the generic.
322
+ *
323
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof GrantId]`.
324
+ *
325
+ * @example
326
+ * ```ts
327
+ * \@RoleMenuRoute(GrantId)
328
+ * class Grant extends RoleMenuHandler<[typeof GrantId]> {
329
+ * async execute() {
330
+ * await this.update(`granting ${this.roles.size} role(s)`);
331
+ * }
332
+ * }
333
+ * ```
334
+ */
335
+ declare abstract class RoleMenuHandler<Defs extends readonly AnyCustomId[]> extends SelectMenuHandler<SelectInteraction<APIMessageRoleSelectInteractionData>, Defs> {
336
+ /** @internal */
337
+ readonly [ComponentKindBrand]?: InteractionKind.RoleMenu;
338
+ /** The roles this select picked. */
339
+ protected get roles(): Collection<string, APIRole>;
340
+ }
341
+ /**
342
+ * Base class for a channel select menu handler on the HTTP transport.
343
+ *
344
+ * Beside `this.values` this handler declares `this.channels`. Register the customId definitions with
345
+ * `@ChannelMenuRoute` and list the same ones in the generic.
346
+ *
347
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof LogTargetId]`.
348
+ *
349
+ * @example
350
+ * ```ts
351
+ * \@ChannelMenuRoute(LogTargetId)
352
+ * class LogTarget extends ChannelMenuHandler<[typeof LogTargetId]> {
353
+ * async execute() {
354
+ * await this.update(`logging to ${this.channels.size} channel(s)`);
355
+ * }
356
+ * }
357
+ * ```
358
+ */
359
+ declare abstract class ChannelMenuHandler<Defs extends readonly AnyCustomId[]> extends SelectMenuHandler<SelectInteraction<APIMessageChannelSelectInteractionData>, Defs> {
360
+ /** @internal */
361
+ readonly [ComponentKindBrand]?: InteractionKind.ChannelMenu;
362
+ /** The channels this select picked. */
363
+ protected get channels(): Collection<string, APIInteractionDataResolvedChannel>;
364
+ }
365
+ /**
366
+ * Base class for a mentionable select menu handler on the HTTP transport.
367
+ *
368
+ * A mentionable menu accepts users and roles together. `this.users`, `this.members`, and `this.roles`
369
+ * can each come back empty.
370
+ *
371
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof InviteId]`.
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * \@MentionableMenuRoute(InviteId)
376
+ * class Invite extends MentionableMenuHandler<[typeof InviteId]> {
377
+ * async execute() {
378
+ * await this.update(`inviting ${this.users.size} user(s) and ${this.roles.size} role(s)`);
379
+ * }
380
+ * }
381
+ * ```
382
+ */
383
+ declare abstract class MentionableMenuHandler<Defs extends readonly AnyCustomId[]> extends SelectMenuHandler<SelectInteraction<APIMessageMentionableSelectInteractionData>, Defs> {
384
+ /** @internal */
385
+ readonly [ComponentKindBrand]?: InteractionKind.MentionableMenu;
386
+ /** The users this select picked. */
387
+ protected get users(): Collection<string, APIUser>;
388
+ /** The guild members behind the picked users. Discord resolves these only inside a guild. */
389
+ protected get members(): Collection<string, APIInteractionDataResolvedGuildMember>;
390
+ /** The roles this select picked. */
391
+ protected get roles(): Collection<string, APIRole>;
392
+ }
393
+ //#endregion
394
+ //#region src/handlers/interaction/middlewareKinds.d.ts
395
+ interface Payloads {
396
+ [InteractionKind.Slash]: APIChatInputApplicationCommandInteraction;
397
+ [InteractionKind.Button]: APIMessageComponentButtonInteraction;
398
+ [InteractionKind.Modal]: APIModalSubmitInteraction;
399
+ [InteractionKind.StringMenu]: SelectInteraction<APIMessageStringSelectInteractionData>;
400
+ [InteractionKind.UserMenu]: SelectInteraction<APIMessageUserSelectInteractionData>;
401
+ [InteractionKind.RoleMenu]: SelectInteraction<APIMessageRoleSelectInteractionData>;
402
+ [InteractionKind.ChannelMenu]: SelectInteraction<APIMessageChannelSelectInteractionData>;
403
+ [InteractionKind.MentionableMenu]: SelectInteraction<APIMessageMentionableSelectInteractionData>;
404
+ [InteractionKind.MessageContextMenu]: APIMessageApplicationCommandInteraction;
405
+ [InteractionKind.UserContextMenu]: APIUserApplicationCommandInteraction;
406
+ }
407
+ type InteractionForKind = { [Kind in MiddlewareKind]: Payloads[Kind]; };
408
+ /** @internal */
409
+ type InteractionOf<Kind extends MiddlewareKind> = InteractionForKind[Kind];
410
+ //#endregion
411
+ //#region src/handlers/interaction/InteractionMiddleware.d.ts
412
+ /**
413
+ * Base class for interaction middleware on the HTTP transport.
414
+ *
415
+ * Middleware runs after the dispatcher builds the handler and before the gates, over the handler's own
416
+ * reply surface. Name the kinds in the generic and list the same ones in `{ kinds }`. Several kinds give
417
+ * `this.event` a union. Narrow it on `type` and `data.component_type`. A catchall reads every repliable
418
+ * kind.
419
+ *
420
+ * @typeParam Kind - One or more {@link InteractionKind} members. Defaults to every repliable kind.
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * \@RegisterInteractionMiddleware({ kinds: [InteractionKind.Button] })
425
+ * class Audit extends InteractionMiddleware<InteractionKind.Button> {
426
+ * async execute() {
427
+ * this.logger.info(this.event.data.custom_id);
428
+ * }
429
+ * }
430
+ * ```
431
+ */
432
+ declare abstract class InteractionMiddleware<in out Kind extends MiddlewareKind = MiddlewareKind> extends RepliableHandler$1<InteractionOf<Kind>> {
433
+ /** @internal */
434
+ readonly [MiddlewareKindsBrand]?: Kind;
435
+ constructor(event: InteractionOf<Kind>, core: Core, dispatch: DispatchContext, sender: ReplySender);
436
+ /**
437
+ * Runs once the handler settles, newest middleware first. A refusal or a throw still reaches it,
438
+ * since seedcord calls it on every middleware whose `execute()` started. Implement it to release
439
+ * something this middleware took in `execute()`, such as a lock or an open span. A throw in here
440
+ * is logged and goes no further.
441
+ *
442
+ * @param result - How the dispatch ended. Either failure state carries the thrown value on `caught`.
443
+ *
444
+ * @example
445
+ * ```ts
446
+ * // the base declares it. an implementation carries `override`.
447
+ * override async after(result: DispatchResult) {
448
+ * this.lock.release();
449
+ * }
450
+ * ```
451
+ */
452
+ after?(result: DispatchResult): Promise<void>;
453
+ }
454
+ //#endregion
455
+ //#region src/handlers/constructors.d.ts
456
+ type AnyHandler = BaseHandler<unknown, Core> & {
457
+ readonly [MiddlewareKindsBrand]?: undefined;
458
+ };
459
+ /** @internal Typed parameters would exclude every handler that narrows `event`. */
460
+ type HandlerConstructor = Constructor<AnyHandler, never[]>;
461
+ /** @internal */
462
+ type InteractionMiddlewareConstructor = TypedConstructor<typeof InteractionMiddleware>;
463
+ //#endregion
464
+ //#region src/manifest/Manifest.d.ts
465
+ /**
466
+ * The classes a bundled isolate registers at startup, standing in for the filesystem scan an isolate
467
+ * cannot run. `seedcord build` emits it for an edge bot. A hand-mounted host writes it.
468
+ */
469
+ interface Manifest {
470
+ readonly handlers: readonly HandlerConstructor[];
471
+ readonly middleware: readonly InteractionMiddlewareConstructor[];
472
+ readonly subscribers: readonly StoredSubscriberCtor[];
473
+ }
474
+ //#endregion
475
+ export { Core as _, RoleMenuHandler as a, HttpServerConfig as b, UserMenuHandler as c, RepliableHandler$1 as d, Repliables as f, AutocompleteHandler as g, SentMessage as h, MentionableMenuHandler as i, ComponentHandler as l, ReplySender as m, InteractionMiddleware as n, SelectMenuHandler as o, InteractionRef as p, ChannelMenuHandler as r, StringMenuHandler as s, Manifest as t, InteractionHandler as u, HttpConfig as v, HttpEdgeConfig as y };
476
+ //# sourceMappingURL=Manifest-D61MNdcV.d.mts.map