@seedcord/http 0.0.1 → 0.1.0-next.1

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.
@@ -0,0 +1,501 @@
1
+ import { t as RouteManifest } from "./RouteManifest-BHdAeyLG.mjs";
2
+ import { REST } from "@discordjs/rest";
3
+ import { AutocompleteOptions, BaseHandler, CoreBase, DispatchContext, Gate, GateContextBase, GuildPermissionsContext, RepliableHandler, RequiredOf, SelectMenuKind, SlashOptionRegistry } from "@seedcord/core";
4
+ import { AnyCustomId, AutocompletableNames, BaseReplySender, ChoiceValueOf, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, InteractionRoutes, MatchArms, ModalLike, SingleParams, SlashOptions } from "@seedcord/core/internal";
5
+ import { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandOptionChoice, APIAttachment, APIChatInputApplicationCommandInteraction, APIContextMenuInteraction, APIInteractionDataResolvedChannelBase, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageApplicationCommandInteraction, APIMessageChannelSelectInteractionData, APIMessageComponentButtonInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, APIMessageMentionableSelectInteractionData, APIMessageRoleSelectInteractionData, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIModalInteractionResponseCallbackData, APIModalSubmitInteraction, APIRole, APIThreadChannel, APIUser, APIUserApplicationCommandInteraction, ApplicationCommandType, ChannelType, ThreadChannelType } from "discord-api-types/v10";
6
+ import { API } from "@discordjs/core/http-only";
7
+ import { SeedcordInstance } from "@seedcord/types/internal";
8
+ import { Config, DeferOpts, HealthCheckOption, ReplyResponse, SendOpts } from "@seedcord/types";
9
+ import { NonEmptyTuple, Promisable } from "type-fest";
10
+
11
+ //#region src/plugin-capabilities.d.ts
12
+ declare module '@seedcord/core' {
13
+ interface PluginCapabilityTypes {
14
+ rest: REST;
15
+ }
16
+ }
17
+ //#endregion
18
+ //#region src/interfaces/Core.d.ts
19
+ /**
20
+ * Main interface for Seedcord core functionality on the HTTP transport.
21
+ *
22
+ * This interface can be augmented via declaration merging to add type-safe plugin definitions when
23
+ * using `this.core` in handlers.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * declare module '@seedcord/http' {
28
+ * interface Core {
29
+ * db: Mongo;
30
+ * }
31
+ * }
32
+ * ```
33
+ */
34
+ interface Core extends CoreBase, SeedcordInstance {
35
+ /** Workerd-compatible Discord REST client. */
36
+ readonly rest: REST;
37
+ readonly config: Config;
38
+ }
39
+ //#endregion
40
+ //#region src/engine.d.ts
41
+ /** Structural match for the Workers `ExecutionContext`. Pass it from the edge entry so post-202 work runs under `waitUntil`. */
42
+ interface EngineContext {
43
+ waitUntil(promise: Promise<unknown>): void;
44
+ }
45
+ //#endregion
46
+ //#region src/createSeedcord.d.ts
47
+ /**
48
+ * Builds the HTTP-interactions engine, a `(request, ctx?) => Promise<Response>` handler.
49
+ *
50
+ * The handler verifies the Ed25519 signature over the raw request bytes, rejects stale or replayed
51
+ * requests, answers a PING with an in-body PONG, and acks every other interaction with an empty 202.
52
+ * The engine dispatches a matched interaction through the manifest before the 202 goes out. Gates run
53
+ * first and the sender posts any refusal over the REST callback. `execute()` continues past the 202 under
54
+ * `ctx.waitUntil` when the caller passes one (the edge entry), and an engine-held in-flight set tracks
55
+ * it otherwise (node paths). It reads only the method, headers, and body. Mount it at any path.
56
+ *
57
+ * Reads `DISCORD_PUBLIC_KEY` and `DISCORD_BOT_TOKEN` from the environment through envapt and throws a
58
+ * `SeedcordError` when either is missing or malformed.
59
+ */
60
+ declare function createSeedcord(config: Config, manifest: RouteManifest): (request: Request, ctx?: EngineContext) => Promise<Response>;
61
+ //#endregion
62
+ //#region src/interfaces/Config.d.ts
63
+ /**
64
+ * Config for a long-running node server. Pass to `new Seedcord(config).start(port)`.
65
+ */
66
+ interface HttpServerConfig extends Config {
67
+ runtime?: 'server';
68
+ /**
69
+ * The health-check server. `false` disables it, `true` or omit for the defaults, an object
70
+ * configures it.
71
+ */
72
+ healthCheck?: HealthCheckOption;
73
+ }
74
+ /**
75
+ * Config for a bundled isolate deployment. `seedcord build` generates a worker entry that calls
76
+ * `createSeedcord`.
77
+ */
78
+ interface HttpEdgeConfig extends Config {
79
+ runtime: 'edge';
80
+ healthCheck?: never;
81
+ }
82
+ /**
83
+ * The http transport's configuration, discriminated on `runtime`.
84
+ */
85
+ type HttpConfig = HttpServerConfig | HttpEdgeConfig;
86
+ //#endregion
87
+ //#region src/inputs/SlashOptions.d.ts
88
+ type ResolvedChannelOf<Type extends ChannelType> = APIInteractionDataResolvedChannelBase<Type> & (Type extends ThreadChannelType ? Pick<APIThreadChannel, 'parent_id' | 'thread_metadata'> : unknown);
89
+ type AnyResolvedChannel = { [Type in ChannelType]: ResolvedChannelOf<Type> }[ChannelType];
90
+ interface HttpLens {
91
+ user: APIUser;
92
+ member: APIInteractionDataResolvedGuildMember;
93
+ channel: AnyResolvedChannel;
94
+ role: APIRole;
95
+ mentionable: APIUser | APIInteractionDataResolvedGuildMember | APIRole;
96
+ attachment: APIAttachment;
97
+ }
98
+ /**
99
+ * The typed view over a chat-input command's options for one route on the HTTP transport. Each getter
100
+ * restricts its `name` to that route's options of the matching kind, drops the null on required options,
101
+ * narrows `choices` to their literal union, and only appears when the route has an option of that kind.
102
+ * The rich kinds return `discord-api-types` payloads resolved from the interaction's `resolved` data.
103
+ *
104
+ * A channel option declared with `addChannelTypes` narrows `getChannel` to the matching resolved-channel
105
+ * subtype.
106
+ *
107
+ * @typeParam Route - A route key from the generated {@link SlashOptionRegistry}.
108
+ */
109
+ type SlashOptions$1<Route extends keyof SlashOptionRegistry> = SlashOptions<Route, HttpLens>;
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, routeId: string);
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 SelectMenuHandler}, or {@link ContextMenuHandler} instead. This class binds the core reply base
154
+ * 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, ReplySender> {
159
+ protected buildSender(event: Event, core: Core, routeId: string): ReplySender;
160
+ /**
161
+ * Typed Discord REST API (`@discordjs/core/http-only`) over `core.rest`, one instance per core.
162
+ * The interaction callbacks on `api.interactions` bypass the reply surface. The
163
+ * `no-raw-interaction-acks` rule flags them in handler classes.
164
+ */
165
+ protected get api(): API;
166
+ }
167
+ //#endregion
168
+ //#region src/handlers/interaction/InteractionHandler.d.ts
169
+ /**
170
+ * Shared base the repliable interaction handlers extend.
171
+ *
172
+ * Not a public entry point. Extend {@link SlashHandler}, {@link ContextMenuHandler}, {@link ButtonHandler},
173
+ * {@link SelectMenuHandler}, or {@link ModalHandler} instead. This class adds `showModal` on top of the
174
+ * reply members.
175
+ *
176
+ * @typeParam Event - The repliable interaction type this handler processes
177
+ */
178
+ declare abstract class InteractionHandler<Event extends Repliables> extends RepliableHandler$1<Event> {
179
+ constructor(event: Event, core: Core, dispatch?: DispatchContext);
180
+ /**
181
+ * Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at
182
+ * compile time (Discord forbids a modal in response to a modal).
183
+ */
184
+ protected showModal(this: InteractionHandler<Exclude<Repliables, APIModalSubmitInteraction>>, modal: ModalLike): Promise<void>;
185
+ }
186
+ //#endregion
187
+ //#region src/handlers/interaction/SlashHandler.d.ts
188
+ type SlashMatchArms<Route extends keyof SlashOptionRegistry, Ret> = { [Key in Route]: (options: SlashOptions$1<Key>) => Promisable<Ret> };
189
+ /**
190
+ * Base class for a chat-input (slash) command handler on the HTTP transport.
191
+ *
192
+ * Pass the route from the generated registry as the generic, then read `this.options` for a single
193
+ * command or `this.match` for several. Command authoring stays plain discord.js, `seedcord codegen`
194
+ * reads its `toJSON()` to type these options.
195
+ *
196
+ * @typeParam Route - One or more route keys from {@link SlashOptionRegistry}, e.g. `'ban'` or `'ban' | 'kick'`.
197
+ */
198
+ declare abstract class SlashHandler<Route extends keyof SlashOptionRegistry> extends InteractionHandler<APIChatInputApplicationCommandInteraction> {
199
+ /** @internal */
200
+ readonly __slashRoute?: Route;
201
+ private resolver?;
202
+ /**
203
+ * The typed options for this command's route. Required options drop the null, choices narrow to their
204
+ * literal union, and only the getters for kinds this command actually uses appear. Rich kinds resolve
205
+ * from the interaction's `resolved` data.
206
+ */
207
+ protected get options(): SlashOptions$1<Route>;
208
+ /**
209
+ * Run the arm for whichever command fired. Use this only when the handler is registered for several
210
+ * routes.
211
+ *
212
+ * Provide one arm per registered route, keyed by its route string, and each arm receives that route's
213
+ * own narrowed options. The arms must cover every route in the generic, a missing route or an unknown
214
+ * key is a compile error.
215
+ *
216
+ * @param arms - One handler per registered route, keyed by route string.
217
+ * @returns The result of the arm that ran.
218
+ */
219
+ protected match<Ret>(arms: SlashMatchArms<Route, Ret>): Promise<Ret>;
220
+ }
221
+ //#endregion
222
+ //#region src/handlers/interaction/ContextMenuHandler.d.ts
223
+ type ContextMenuKind = ApplicationCommandType.User | ApplicationCommandType.Message;
224
+ type InteractionFor<Kind extends ContextMenuKind> = Kind extends ApplicationCommandType.User ? APIUserApplicationCommandInteraction : APIMessageApplicationCommandInteraction;
225
+ type TargetFor<Kind extends ContextMenuKind> = Kind extends ApplicationCommandType.User ? APIUser : APIMessage;
226
+ type TargetMemberFor<Kind extends ContextMenuKind> = Kind extends ApplicationCommandType.User ? APIInteractionDataResolvedGuildMember | null : never;
227
+ /**
228
+ * Base class for a context-menu command handler on the HTTP transport (right-click a user or a message).
229
+ *
230
+ * Pass the kind from {@link ApplicationCommandType} as the generic. Read the right-clicked entity from
231
+ * `this.target`, an `APIUser` for a user menu and an `APIMessage` for a message menu. Context menus carry
232
+ * no options, so a handler registered for several names reads `this.target` uniformly with no per-name
233
+ * branch.
234
+ *
235
+ * @typeParam Kind - `ApplicationCommandType.User` or `ApplicationCommandType.Message`.
236
+ */
237
+ declare abstract class ContextMenuHandler<Kind extends ContextMenuKind> extends InteractionHandler<InteractionFor<Kind>> {
238
+ /** @internal */
239
+ readonly __ctxKind?: Kind;
240
+ protected get target(): TargetFor<Kind>;
241
+ /**
242
+ * The right-clicked user's guild member, resolved only on user menus fired in a guild. Reading it on a
243
+ * message menu is a compile error.
244
+ */
245
+ protected get targetMember(): TargetMemberFor<Kind>;
246
+ }
247
+ //#endregion
248
+ //#region src/handlers/interaction/AutocompleteHandler.d.ts
249
+ type FocusedArms<Route extends keyof SlashOptionRegistry, Ret> = { [Name in AutocompletableNames<Route>]: (value: string, respond: (choices: readonly APIApplicationCommandOptionChoice<ChoiceValueOf<EntryFor<Route, Name>>>[]) => Promise<void>) => Promisable<Ret> };
250
+ /**
251
+ * Base class for an autocomplete handler on the HTTP transport.
252
+ *
253
+ * Pass the command route(s) from the generated registry as the generic. Branch on the focused field with
254
+ * `this.match`, read already-entered sibling options with `this.options`, and find which command fired
255
+ * with `this.route`.
256
+ *
257
+ * @typeParam Route - One or more route keys from {@link SlashOptionRegistry}, e.g. `'search'`.
258
+ */
259
+ declare abstract class AutocompleteHandler<Route extends keyof SlashOptionRegistry> extends BaseHandler<APIApplicationCommandAutocompleteInteraction, Core> {
260
+ constructor(event: APIApplicationCommandAutocompleteInteraction, core: Core, dispatch?: DispatchContext);
261
+ /** @internal */
262
+ readonly __autocompleteRoute?: Route;
263
+ /**
264
+ * Typed Discord REST API (`@discordjs/core/http-only`) over `core.rest`, one instance per core.
265
+ */
266
+ protected get api(): API;
267
+ private resolver?;
268
+ private get reader();
269
+ /**
270
+ * The focused option for this interaction. `value` is always the raw partial string the user is typing,
271
+ * even for an integer or number option, so coerce it yourself when you need a number.
272
+ */
273
+ protected get focused(): FocusedField<Route>;
274
+ /**
275
+ * Run the arm for the focused field. An autocomplete always dispatches by which field is focused, so
276
+ * match is how you read it.
277
+ *
278
+ * Provide one arm per autocompletable field across the registered commands, keyed by field name. Each
279
+ * arm receives the focused partial value and a `respond` typed to that field's choice value. The
280
+ * arms must cover every autocompletable field, a missing field or an unknown key is a compile error. A
281
+ * focused field with no arm, only reachable from a stale-deployed command, throws at runtime.
282
+ *
283
+ * @param arms - One handler per autocompletable field, keyed by field name.
284
+ * @returns The result of the arm that ran.
285
+ */
286
+ protected match<Ret>(arms: FocusedArms<Route, Ret>): Promise<Ret>;
287
+ /** Send autocomplete suggestions, callback type 8. Prefer {@link match}, which restricts each field's choices to its declared type. */
288
+ protected respond(choices: readonly APIApplicationCommandOptionChoice[]): Promise<void>;
289
+ /** The firing command route, for a field whose completion differs per registered command. */
290
+ protected get route(): Route;
291
+ /**
292
+ * The already-entered options on this command, restricted to the kinds Discord resolves during autocomplete
293
+ * (string, integer, number, boolean) with every read nullable, since a sibling is partial while the user
294
+ * types the focused field. The focused field is on `this.focused`.
295
+ */
296
+ protected get options(): AutocompleteOptions<Route>;
297
+ }
298
+ //#endregion
299
+ //#region src/handlers/interaction/components/ComponentHandler.d.ts
300
+ /**
301
+ * Shared base the customId-routed component handlers extend on the HTTP transport.
302
+ *
303
+ * Not a public entry point. Extend {@link ButtonHandler}, {@link SelectMenuHandler}, or {@link ModalHandler}
304
+ * instead. This class defines the customId decode, the route matching, and the source-message verbs
305
+ * `update` and `deferUpdate`.
306
+ *
307
+ * @typeParam Event - The component or modal interaction type this handler processes
308
+ * @typeParam Defs - The customId route definitions registered on the concrete handler
309
+ */
310
+ declare abstract class ComponentHandler<Event extends APIMessageComponentInteraction | APIModalSubmitInteraction, Defs extends readonly AnyCustomId[]> extends InteractionHandler<Event> implements HasComponentDefs<Defs> {
311
+ /** @internal */
312
+ readonly __componentDefs?: Defs;
313
+ /** Rewrite the source message this component interaction came from. */
314
+ protected update(response: ReplyResponse | string): Promise<SentMessage>;
315
+ /** Acknowledge the component without changing the source message. */
316
+ protected deferUpdate(): Promise<void>;
317
+ private decoded?;
318
+ private get route();
319
+ /**
320
+ * The decoded params of the single route this handler is registered for.
321
+ *
322
+ * Reading this decodes `this.event.data.custom_id` once (cached after the first read) and throws
323
+ * `StaleCustomId` or `InvalidCustomId` when the wire no longer matches the current shape, which the
324
+ * dispatcher boundary turns into a reply. On a handler registered for several routes this is
325
+ * `never`, so use {@link match} instead.
326
+ */
327
+ protected get params(): SingleParams<Defs>;
328
+ /**
329
+ * Run the arm for whichever route the component was minted from. Use this only when the handler is
330
+ * registered for several routes. A single-route handler reads `this.params` directly. On a multi-route
331
+ * handler `this.params` is `never`, so match is the only way to read the decoded params.
332
+ *
333
+ * Provide one arm per registered route, keyed by its prefix, and each arm receives that route's own
334
+ * decoded params. The arms cover every registered route prefix, checked at compile time, and a prefix
335
+ * unmatched at runtime throws `CustomIdMatchArmMissing`. Decoding runs before any arm, so a stale or
336
+ * corrupt wire throws before an arm body executes.
337
+ *
338
+ * @param arms - One callback per registered route, keyed by prefix.
339
+ * @returns The result of the arm that ran.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * \@ButtonRoute(Approve, Reject)
344
+ * class ReviewButtons extends ButtonHandler<[typeof Approve, typeof Reject]> {
345
+ * async execute() {
346
+ * await this.match({
347
+ * approve: ({ userId }) => this.reply(`approved <@${userId}>`),
348
+ * reject: ({ userId }) => this.reply(`rejected <@${userId}>`)
349
+ * });
350
+ * }
351
+ * }
352
+ * ```
353
+ */
354
+ protected match<Ret>(arms: MatchArms<Defs, Ret>): Promise<Ret>;
355
+ }
356
+ //#endregion
357
+ //#region src/handlers/interaction/components/ButtonHandler.d.ts
358
+ /**
359
+ * Base class for a button interaction handler on the HTTP transport.
360
+ *
361
+ * Register the customId definitions this handler decodes with `@ButtonRoute`, list the same ones in the
362
+ * generic, then read `this.params` for a single route or `this.match` for several. Reply through the
363
+ * handler members, or rewrite the source message with `this.update`. Passing different definitions to the
364
+ * decorator and the generic is a compile error.
365
+ *
366
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ApproveId]`.
367
+ */
368
+ declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[]> extends ComponentHandler<APIMessageComponentButtonInteraction, Defs> {
369
+ /** @internal */
370
+ readonly __component?: 'button';
371
+ }
372
+ //#endregion
373
+ //#region src/handlers/interaction/components/SelectMenuHandler.d.ts
374
+ type SelectMenuInteractionFor<Kind extends SelectMenuKind> = APIMessageComponentSelectMenuInteraction & {
375
+ data: Kind extends SelectMenuKind.String ? APIMessageStringSelectInteractionData : Kind extends SelectMenuKind.User ? APIMessageUserSelectInteractionData : Kind extends SelectMenuKind.Role ? APIMessageRoleSelectInteractionData : Kind extends SelectMenuKind.Channel ? APIMessageChannelSelectInteractionData : Kind extends SelectMenuKind.Mentionable ? APIMessageMentionableSelectInteractionData : never;
376
+ };
377
+ /**
378
+ * Base class for a select menu handler on the HTTP transport.
379
+ *
380
+ * Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute`,
381
+ * so `this.event.data` and its `values`/`resolved` are narrowed to that kind. Read `this.params` for a
382
+ * single route or `this.match` for several, and reply through the handler members or rewrite the source
383
+ * message with `this.update`.
384
+ *
385
+ * @typeParam Kind - The select kind from {@link SelectMenuKind}, e.g. `SelectMenuKind.User`.
386
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof AssignId]`.
387
+ */
388
+ declare abstract class SelectMenuHandler<Kind extends SelectMenuKind, Defs extends readonly AnyCustomId[]> extends ComponentHandler<SelectMenuInteractionFor<Kind>, Defs> {
389
+ /** @internal */
390
+ readonly __component?: Kind;
391
+ }
392
+ //#endregion
393
+ //#region src/handlers/interaction/components/ModalHandler.d.ts
394
+ /**
395
+ * Base class for a modal submit handler on the HTTP transport.
396
+ *
397
+ * Register the customId definitions this handler decodes with `@ModalRoute` and list the same ones in the
398
+ * generic. Read the submitted inputs off `this.event.data.components`. Reply through the handler members.
399
+ * Discord forbids opening a modal in response to a modal, so `showModal` fails compilation on this kind.
400
+ *
401
+ * @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ConfigId]`.
402
+ */
403
+ declare abstract class ModalHandler<Defs extends readonly AnyCustomId[]> extends ComponentHandler<APIModalSubmitInteraction, Defs> {
404
+ /** @internal */
405
+ readonly __component?: 'modal';
406
+ /** Rewrite the message this modal was opened from (only when a component opened it). */
407
+ protected update(response: ReplyResponse | string): Promise<SentMessage>;
408
+ /** Silently acknowledge, leaving the source message untouched. */
409
+ protected deferUpdate(): Promise<void>;
410
+ private ensureSourceMessage;
411
+ }
412
+ //#endregion
413
+ //#region src/gates/Gate.d.ts
414
+ /**
415
+ * The interaction gate context on the HTTP transport. It extends the scalar {@link GateContextBase} with the
416
+ * raw interaction payload and the user and member the payload carries. `Repliable` narrows which handlers a
417
+ * gate attaches to, inferred from the `ctx` annotation, so a gate reading button fields is rejected on a
418
+ * slash handler.
419
+ *
420
+ * The http transport delivers no role-derived permission sets, so `memberGuildPermissions` and
421
+ * `appGuildPermissions` are absent. A gate requiring `GuildPermissionsContext` (a permission gate with
422
+ * `in: 'guild'`) is a compile error on an http handler.
423
+ *
424
+ * @typeParam Repliable - The interaction type the gate reads, narrowing which handlers accept it.
425
+ *
426
+ * @example
427
+ * ```ts
428
+ * import type { APIMessageComponentButtonInteraction } from 'discord-api-types/v10';
429
+ *
430
+ * // a button-only gate: the Repliable generic narrows which handlers accept it
431
+ * const ButtonGate = defineGate('btn', (ctx: InteractionGateContext<APIMessageComponentButtonInteraction>) => {
432
+ * void ctx.interaction; // APIMessageComponentButtonInteraction
433
+ * });
434
+ * ```
435
+ */
436
+ interface InteractionGateContext<Repliable extends Repliables = Repliables> extends GateContextBase {
437
+ /** Narrow on this before reading `interaction`. */
438
+ readonly kind: 'interaction';
439
+ readonly core: Core;
440
+ /** The raw interaction payload, which is the reply target. */
441
+ readonly interaction: Repliable;
442
+ /** Every repliable interaction contains a user, so this is never null. */
443
+ readonly user: APIUser;
444
+ /** The invoking member, or null in a DM. */
445
+ readonly member: APIInteractionGuildMember | null;
446
+ }
447
+ //#endregion
448
+ //#region src/gates/matching.d.ts
449
+ type AnyHandlerCtor = abstract new (...args: never[]) => {
450
+ execute(): Promise<void>;
451
+ };
452
+ declare const UngateableBrand: unique symbol;
453
+ interface Ungateable {
454
+ readonly [UngateableBrand]: true;
455
+ }
456
+ type ProvidedContext<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends RepliableHandler$1<infer Event> ? InteractionGateContext<Event> : Ungateable;
457
+ type SelectData<Repliable> = Repliable extends APIMessageComponentSelectMenuInteraction ? Repliable['data'] : never;
458
+ type KindName<Ctx> = Ctx extends Ungateable ? 'autocomplete' : Ctx extends GuildPermissionsContext ? 'gateway (guild permissions)' : Ctx extends InteractionGateContext<infer Repliable> ? Repliable extends APIChatInputApplicationCommandInteraction ? 'Slash' : Repliable extends APIMessageApplicationCommandInteraction ? 'MessageMenu' : Repliable extends APIUserApplicationCommandInteraction ? 'UserMenu' : SelectData<Repliable> extends APIMessageStringSelectInteractionData ? 'StringSelect' : SelectData<Repliable> extends APIMessageUserSelectInteractionData ? 'UserSelect' : SelectData<Repliable> extends APIMessageRoleSelectInteractionData ? 'RoleSelect' : SelectData<Repliable> extends APIMessageChannelSelectInteractionData ? 'ChannelSelect' : SelectData<Repliable> extends APIMessageMentionableSelectInteractionData ? 'MentionableSelect' : Repliable extends APIMessageComponentButtonInteraction ? 'Button' : Repliable extends APIModalSubmitInteraction ? 'Modal' : 'an interaction' : 'an agnostic';
459
+ 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]>>> };
460
+ //#endregion
461
+ //#region src/gates/Gated.d.ts
462
+ /**
463
+ * Attaches gates to an HTTP interaction handler. The gates run before `execute`, and a gate refusing stops
464
+ * the handler with the reply or drop the gate threw. Multiple gates are ANDed, so each must pass. A gate
465
+ * that requires a context the handler does not provide (a button gate on a slash handler, a gate on an
466
+ * autocomplete handler, or a `RequirePermissions([...], { in: 'guild' })` gate the http transport cannot
467
+ * satisfy) is a compile error at this line, and the error names the gate and the handler kind. Place it
468
+ * above the route decorator.
469
+ *
470
+ * Combine gates with {@link and} or {@link or} to build a single gate from multiple arms.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * import { PermissionFlagsBits } from 'discord-api-types/v10';
475
+ *
476
+ * \@Gated(GuildOnly(), RequirePermissions([PermissionFlagsBits.ManageMessages]))
477
+ * \@SlashRoute('purge')
478
+ * class Purge extends SlashHandler<'purge'> {
479
+ * async execute() {
480
+ * // both gates passed, so this runs in a guild with a caller who can moderate this channel
481
+ * }
482
+ * }
483
+ * ```
484
+ *
485
+ * @typeParam Gates - The non-empty tuple of gates to run, in order, against the handler's context.
486
+ * @typeParam TCtor - The decorated handler's constructor, checked against every gate's required context.
487
+ * @param gates - One or more gates to attach, each ANDed so the handler runs only when all pass.
488
+ * @param ctor - The handler class being decorated, rejected at compile time when a gate requires a context it lacks.
489
+ *
490
+ * @see {@link defineGate}
491
+ * @see {@link defineEffectGate}
492
+ * @decorator
493
+ */
494
+ declare function Gated<const Gates extends NonEmptyTuple<Gate<GateContextBase>>>(...gates: Gates): <TCtor extends AnyHandlerCtor>(ctor: FitAll<TCtor, Gates> extends Gates ? TCtor : FitAll<TCtor, Gates>) => void;
495
+ //#endregion
496
+ //#region src/version.d.ts
497
+ /** Package version */
498
+ declare const version: string;
499
+ //#endregion
500
+ export { createSeedcord as _, SelectMenuHandler as a, AutocompleteHandler as c, InteractionHandler as d, RepliableHandler$1 as f, HttpServerConfig as g, HttpEdgeConfig as h, ModalHandler as i, ContextMenuHandler as l, HttpConfig as m, Gated as n, ButtonHandler as o, SlashOptions$1 as p, InteractionGateContext as r, ComponentHandler as s, version as t, SlashHandler as u, EngineContext as v, Core as y };
501
+ //# sourceMappingURL=edge.index-CTOyjsO4.d.mts.map