@seedcord/core 0.5.0 → 0.7.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/dist/{Bus-dGy6xq3F.mjs → Bus-Djm6688b.mjs} +6 -5
- package/dist/Bus-Djm6688b.mjs.map +1 -0
- package/dist/{Pluggable-BKe2uCa0.d.mts → Pluggable-CqKvMXm5.d.mts} +11 -4
- package/dist/{Pluggable-CtMiOP3p.mjs → Pluggable-keys1cVr.mjs} +34 -10
- package/dist/Pluggable-keys1cVr.mjs.map +1 -0
- package/dist/Plugin-BJfRk0s_.mjs.map +1 -1
- package/dist/{Plugin-iAaWcLaD.d.mts → Plugin-BdqfRjU0.d.mts} +9 -3
- package/dist/{cursor-8Y2zpF-Y.d.mts → cursor-BY5dmiz6.d.mts} +121 -7
- package/dist/{cursor-BkI9lxy2.mjs → cursor-CFNKLVlk.mjs} +49 -11
- package/dist/cursor-CFNKLVlk.mjs.map +1 -0
- package/dist/{index-CD8l15aZ.d.mts → index-BS1hH9Sh.d.mts} +2 -2
- package/dist/index.d.mts +27 -46
- package/dist/index.mjs +31 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.d.mts +79 -8
- package/dist/internal.index.mjs +121 -16
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.d.mts +10 -5
- package/dist/node-internal.index.mjs +18 -9
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/node.index.d.mts +1 -1
- package/dist/node.index.mjs +31 -10
- package/dist/node.index.mjs.map +1 -1
- package/dist/{phases-D0a8BV9Z.d.mts → phases-DJf12l5T.d.mts} +48 -9
- package/dist/plugin.index.d.mts +1 -1
- package/dist/{slashRouteLeaves-C1msUE9Q.mjs → slashRouteLeaves-DTFHzCKN.mjs} +2 -2
- package/dist/{slashRouteLeaves-C1msUE9Q.mjs.map → slashRouteLeaves-DTFHzCKN.mjs.map} +1 -1
- package/dist/{subscribers-A8lNU5yM.mjs → subscribers-Bf4cBTvK.mjs} +2 -2
- package/dist/{subscribers-A8lNU5yM.mjs.map → subscribers-Bf4cBTvK.mjs.map} +1 -1
- package/package.json +14 -14
- package/dist/Bus-dGy6xq3F.mjs.map +0 -1
- package/dist/Pluggable-CtMiOP3p.mjs.map +0 -1
- package/dist/cursor-BkI9lxy2.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as
|
|
1
|
+
import { G as Notice, H as MiddlewareKind, N as DispatchContext, R as InteractionKind, S as AckState, _ as SubscriptionData, b as ReplyTelemetry, c as Subscriber, d as DispatchOutcome, f as FaultSource, g as ResponseSent, h as ResponseOutcome, i as Bus, l as AttemptedWrite, m as ResponseFailed, n as StartupPhase, p as ResponseAttempt, r as CoreBase, t as ShutdownPhase, v as SubscriptionKey, y as Subscriptions } from "./phases-DJf12l5T.mjs";
|
|
2
|
+
import { $ as BuilderType, B as AutocompleteRouteBrand, C as Gate, D as defineEffectGate, E as RequiredOf, H as ComponentKindBrand, J as RegisterCommand, K as SlashRouteBrand, L as InteractionMiddlewareOptions, M as EventDispatchResult, N as HandlerOutcome, O as defineGate, P as HandlerResult, Q as RowComponent, R as RegisterInteractionMiddleware, S as EffectGate, T as GuildPermissionsContext, U as ContextMenuKindBrand, V as ComponentDefsBrand, W as ContextMenuNamesBrand, Y as Promisable, Z as BuilderComponent, a as AutocompleteOptions, at as SlashRegistry, b as JoinNames, d as RequirePermissionsOptions, dt as UserContextMenuRegistry, et as RowType, f as RequireRole, g as GateNoticeOptions, h as PermissionScope, j as DispatchResult, k as SerializedReply, l as RequireBotPermissions, lt as MessageContextMenuRegistry, n as PageCursor, p as RequireRoleOptions, st as ContextMenuKind, u as RequirePermissions, ut as NamesFor, w as GateContextBase, x as TwoOrMore, y as IntersectRequired } from "./cursor-BY5dmiz6.mjs";
|
|
3
3
|
import { t as Constructor } from "./basic-Dng__Ena.mjs";
|
|
4
|
-
import { a as Subscribe, i as WebhookFile, n as WebhookLog, o as SubscribeOptions, r as WebhookReport, t as WebhookUrl } from "./index-
|
|
4
|
+
import { a as Subscribe, i as WebhookFile, n as WebhookLog, o as SubscribeOptions, r as WebhookReport, t as WebhookUrl } from "./index-BS1hH9Sh.mjs";
|
|
5
5
|
import "reflect-metadata";
|
|
6
|
-
import { AnyCustomId, CustomId, FieldOptions, setCustomIdErrors } from "@seedcord/custom-id";
|
|
6
|
+
import { AnyCustomId, AnyCustomId as AnyCustomId$1, CustomId, CustomIdField, CustomIdShape, DecodedParams, DecodedRoute, FieldOptions, decodeFor, prefixOf, setCustomIdErrors } from "@seedcord/custom-id";
|
|
7
7
|
import { ActionRowBuilder, ButtonBuilder } from "@discordjs/builders";
|
|
8
8
|
import { APIMessageComponentEmoji, APIModalInteractionResponseCallbackData, ApplicationCommandType, ButtonStyle } from "discord-api-types/v10";
|
|
9
9
|
import { Logger } from "@seedcord/logger";
|
|
@@ -83,12 +83,12 @@ type ComponentOf<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends {
|
|
|
83
83
|
[ComponentKindBrand]?: infer Brand extends ComponentBrand;
|
|
84
84
|
} ? Brand : never;
|
|
85
85
|
type DefsOf<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends {
|
|
86
|
-
[ComponentDefsBrand]?: infer Defs extends readonly AnyCustomId[];
|
|
86
|
+
[ComponentDefsBrand]?: infer Defs extends readonly AnyCustomId$1[];
|
|
87
87
|
} ? Defs : never;
|
|
88
|
-
type AssertSlashRoute<Route extends keyof SlashRegistry, TCtor extends AnyHandlerCtor> = [Route] extends [SlashRouteOf<TCtor>] ? [SlashRouteOf<TCtor>] extends [Route] ? TCtor : Constructor<['SlashHandler declares a route the SlashRoute decorator does not list', SlashRouteOf<TCtor>]> : Constructor<['SlashRoute does not match the SlashHandler generic', Route]>;
|
|
89
|
-
type AssertAutocompleteRoute<Route extends keyof SlashRegistry, TCtor extends AnyHandlerCtor> = [Route] extends [AutocompleteRouteOf<TCtor>] ? [AutocompleteRouteOf<TCtor>] extends [Route] ? TCtor : Constructor<['AutocompleteHandler declares a command the AutocompleteRoute decorator does not list', AutocompleteRouteOf<TCtor>]> : Constructor<['AutocompleteRoute does not match the AutocompleteHandler generic', Route]>;
|
|
90
|
-
type AssertContextMenuRoute<Kind extends ContextMenuKind, Names extends NamesFor<Kind>, TCtor extends AnyHandlerCtor> = [Kind] extends [ContextMenuKindOf<TCtor>] ? [ContextMenuKindOf<TCtor>] extends [Kind] ? [Names] extends [ContextMenuNamesOf<TCtor>] ? [ContextMenuNamesOf<TCtor>] extends [Names] ? TCtor : Constructor<['ContextMenuHandler declares a name the ContextMenuRoute decorator does not list', ContextMenuNamesOf<TCtor>]> : Constructor<['ContextMenuRoute lists a name the ContextMenuHandler generic does not declare', Names]> : Constructor<['ContextMenuHandler declares a kind the ContextMenuRoute decorator does not match', ContextMenuKindOf<TCtor>]> : Constructor<['ContextMenuRoute does not match the ContextMenuHandler generic', Kind]>;
|
|
91
|
-
type AssertComponentRoute<Brand extends ComponentBrand, Defs extends readonly AnyCustomId[], TCtor extends AnyHandlerCtor> = [ComponentOf<TCtor>] extends [Brand] ? [Brand] extends [ComponentOf<TCtor>] ? [DefsOf<TCtor>] extends [Defs] ? TCtor : Constructor<['the customId definitions do not match the handler generic', DefsOf<TCtor>]> : Constructor<['the decorator does not match the handler kind', ComponentOf<TCtor>]> : Constructor<['the decorator does not match the handler kind', ComponentOf<TCtor>]>;
|
|
88
|
+
type AssertSlashRoute<Route extends keyof SlashRegistry, TCtor extends AnyHandlerCtor> = [Route] extends [SlashRouteOf<TCtor>] ? [SlashRouteOf<TCtor>] extends [Route] ? TCtor : Constructor<['SlashHandler declares a route that the SlashRoute decorator does not list', SlashRouteOf<TCtor>]> : Constructor<['SlashRoute does not match the SlashHandler generic', Route]>;
|
|
89
|
+
type AssertAutocompleteRoute<Route extends keyof SlashRegistry, TCtor extends AnyHandlerCtor> = [Route] extends [AutocompleteRouteOf<TCtor>] ? [AutocompleteRouteOf<TCtor>] extends [Route] ? TCtor : Constructor<['AutocompleteHandler declares a command that the AutocompleteRoute decorator does not list', AutocompleteRouteOf<TCtor>]> : Constructor<['AutocompleteRoute does not match the AutocompleteHandler generic', Route]>;
|
|
90
|
+
type AssertContextMenuRoute<Kind extends ContextMenuKind, Names extends NamesFor<Kind>, TCtor extends AnyHandlerCtor> = [Kind] extends [ContextMenuKindOf<TCtor>] ? [ContextMenuKindOf<TCtor>] extends [Kind] ? [Names] extends [ContextMenuNamesOf<TCtor>] ? [ContextMenuNamesOf<TCtor>] extends [Names] ? TCtor : Constructor<['ContextMenuHandler declares a name that the ContextMenuRoute decorator does not list', ContextMenuNamesOf<TCtor>]> : Constructor<['ContextMenuRoute lists a name that the ContextMenuHandler generic does not declare', Names]> : Constructor<['ContextMenuHandler declares a kind that the ContextMenuRoute decorator does not match', ContextMenuKindOf<TCtor>]> : Constructor<['ContextMenuRoute does not match the ContextMenuHandler generic', Kind]>;
|
|
91
|
+
type AssertComponentRoute<Brand extends ComponentBrand, Defs extends readonly AnyCustomId$1[], TCtor extends AnyHandlerCtor> = [ComponentOf<TCtor>] extends [Brand] ? [Brand] extends [ComponentOf<TCtor>] ? [DefsOf<TCtor>] extends [Defs] ? TCtor : Constructor<['the customId definitions do not match the handler generic', DefsOf<TCtor>]> : Constructor<['the decorator does not match the handler kind', ComponentOf<TCtor>]> : Constructor<['the decorator does not match the handler kind', ComponentOf<TCtor>]>;
|
|
92
92
|
/**
|
|
93
93
|
* Routes one or more slash commands to a `SlashHandler`.
|
|
94
94
|
*
|
|
@@ -179,7 +179,7 @@ declare function MessageContextMenuRoute<const Names extends NamesFor<Applicatio
|
|
|
179
179
|
* @param defs - The customId definition(s) this handler decodes, one per route.
|
|
180
180
|
* @decorator
|
|
181
181
|
*/
|
|
182
|
-
declare function ButtonRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.Button, Defs, TCtor>) => void;
|
|
182
|
+
declare function ButtonRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.Button, Defs, TCtor>) => void;
|
|
183
183
|
/**
|
|
184
184
|
* Routes modal submissions to handler classes.
|
|
185
185
|
*
|
|
@@ -190,7 +190,7 @@ declare function ButtonRoute<const Defs extends readonly AnyCustomId[]>(...defs:
|
|
|
190
190
|
* @param defs - The customId definition(s) this handler decodes, one per route.
|
|
191
191
|
* @decorator
|
|
192
192
|
*/
|
|
193
|
-
declare function ModalRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.Modal, Defs, TCtor>) => void;
|
|
193
|
+
declare function ModalRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.Modal, Defs, TCtor>) => void;
|
|
194
194
|
/**
|
|
195
195
|
* Routes string select menu interactions to a `StringMenuHandler`.
|
|
196
196
|
*
|
|
@@ -209,7 +209,7 @@ declare function ModalRoute<const Defs extends readonly AnyCustomId[]>(...defs:
|
|
|
209
209
|
* }
|
|
210
210
|
* ```
|
|
211
211
|
*/
|
|
212
|
-
declare function StringMenuRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.StringMenu, Defs, TCtor>) => void;
|
|
212
|
+
declare function StringMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.StringMenu, Defs, TCtor>) => void;
|
|
213
213
|
/**
|
|
214
214
|
* Routes user select menu interactions to a `UserMenuHandler`.
|
|
215
215
|
*
|
|
@@ -230,7 +230,7 @@ declare function StringMenuRoute<const Defs extends readonly AnyCustomId[]>(...d
|
|
|
230
230
|
* }
|
|
231
231
|
* ```
|
|
232
232
|
*/
|
|
233
|
-
declare function UserMenuRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.UserMenu, Defs, TCtor>) => void;
|
|
233
|
+
declare function UserMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.UserMenu, Defs, TCtor>) => void;
|
|
234
234
|
/**
|
|
235
235
|
* Routes role select menu interactions to a `RoleMenuHandler`.
|
|
236
236
|
*
|
|
@@ -249,7 +249,7 @@ declare function UserMenuRoute<const Defs extends readonly AnyCustomId[]>(...def
|
|
|
249
249
|
* }
|
|
250
250
|
* ```
|
|
251
251
|
*/
|
|
252
|
-
declare function RoleMenuRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.RoleMenu, Defs, TCtor>) => void;
|
|
252
|
+
declare function RoleMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.RoleMenu, Defs, TCtor>) => void;
|
|
253
253
|
/**
|
|
254
254
|
* Routes channel select menu interactions to a `ChannelMenuHandler`.
|
|
255
255
|
*
|
|
@@ -268,7 +268,7 @@ declare function RoleMenuRoute<const Defs extends readonly AnyCustomId[]>(...def
|
|
|
268
268
|
* }
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
|
-
declare function ChannelMenuRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.ChannelMenu, Defs, TCtor>) => void;
|
|
271
|
+
declare function ChannelMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.ChannelMenu, Defs, TCtor>) => void;
|
|
272
272
|
/**
|
|
273
273
|
* Routes mentionable select menu interactions to a `MentionableMenuHandler`.
|
|
274
274
|
*
|
|
@@ -288,27 +288,7 @@ declare function ChannelMenuRoute<const Defs extends readonly AnyCustomId[]>(...
|
|
|
288
288
|
* }
|
|
289
289
|
* ```
|
|
290
290
|
*/
|
|
291
|
-
declare function MentionableMenuRoute<const Defs extends readonly AnyCustomId[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.MentionableMenu, Defs, TCtor>) => void;
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/dispatch/DispatchContext.d.ts
|
|
294
|
-
/**
|
|
295
|
-
* The per-dispatch bag. Any code can merge fields into it by declaration merging, the
|
|
296
|
-
* same pattern as {@link SlashRegistry}. It stays empty until one does, so `keyof DispatchState` is
|
|
297
|
-
* `never` and the bag is inert.
|
|
298
|
-
*/
|
|
299
|
-
interface DispatchState {}
|
|
300
|
-
/**
|
|
301
|
-
* A typed bag allocated once per interaction dispatch and handed to the handler. The middleware and i18n
|
|
302
|
-
* work reads and writes it through {@link DispatchState}. Today the bag is empty, so it only carries the
|
|
303
|
-
* dispatched `routeId`.
|
|
304
|
-
*/
|
|
305
|
-
declare class DispatchContext {
|
|
306
|
-
readonly routeId: string | null;
|
|
307
|
-
private readonly state;
|
|
308
|
-
constructor(routeId: string | null);
|
|
309
|
-
set<Key extends keyof DispatchState>(key: Key, value: DispatchState[Key]): void;
|
|
310
|
-
get<Key extends keyof DispatchState>(key: Key): DispatchState[Key] | undefined;
|
|
311
|
-
}
|
|
291
|
+
declare function MentionableMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.MentionableMenu, Defs, TCtor>) => void;
|
|
312
292
|
//#endregion
|
|
313
293
|
//#region src/handlers/BaseHandler.d.ts
|
|
314
294
|
/**
|
|
@@ -322,8 +302,9 @@ declare abstract class BaseHandler<Event, TCore extends CoreBase> {
|
|
|
322
302
|
readonly core: TCore;
|
|
323
303
|
protected readonly event: Event;
|
|
324
304
|
protected readonly logger: Logger;
|
|
325
|
-
|
|
326
|
-
protected
|
|
305
|
+
/** The bag for this dispatch. Each interaction gets its own. Every handler for one event shares a single bag. */
|
|
306
|
+
protected readonly dispatch: DispatchContext;
|
|
307
|
+
protected constructor(event: Event, core: TCore, dispatch: DispatchContext, channel?: LoggerChannelId);
|
|
327
308
|
/**
|
|
328
309
|
* Holds the main logic of your handler. The dispatcher calls it after the handler's gates pass, so a
|
|
329
310
|
* gate that refuses stops `execute()` from running.
|
|
@@ -345,12 +326,12 @@ interface ModalLike {
|
|
|
345
326
|
declare abstract class BaseReplySender<TMessage extends {
|
|
346
327
|
id: string;
|
|
347
328
|
}, TNative = never> {
|
|
348
|
-
protected readonly routeId: string;
|
|
349
329
|
private readonly telemetry;
|
|
350
330
|
private state;
|
|
351
331
|
private readonly sent;
|
|
352
332
|
private ackedBy?;
|
|
353
|
-
protected constructor(
|
|
333
|
+
protected constructor(telemetry: ReplyTelemetry, initialState?: AckState);
|
|
334
|
+
protected get routeId(): string;
|
|
354
335
|
private report;
|
|
355
336
|
private attempt;
|
|
356
337
|
reply(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
|
|
@@ -392,8 +373,8 @@ declare abstract class BaseReplySender<TMessage extends {
|
|
|
392
373
|
//#endregion
|
|
393
374
|
//#region src/handlers/RepliableHandler.d.ts
|
|
394
375
|
/**
|
|
395
|
-
* Shared base the repliable handlers on both transports extend. Defines the reply members over
|
|
396
|
-
*
|
|
376
|
+
* Shared base the repliable handlers on both transports extend. Defines the reply members over one sender.
|
|
377
|
+
* A handler builds its own through `buildSender`. A middleware takes the handler's.
|
|
397
378
|
*
|
|
398
379
|
* @typeParam Event - The repliable interaction type this handler processes
|
|
399
380
|
* @typeParam TCore - The transport's Core
|
|
@@ -407,8 +388,8 @@ declare abstract class RepliableHandler<Event, TCore extends CoreBase, TMessage
|
|
|
407
388
|
/** The reply surface for this interaction. Pass the handler to reply from outside its class. */
|
|
408
389
|
readonly sender: TSender;
|
|
409
390
|
protected readonly routeId: string;
|
|
410
|
-
protected constructor(event: Event, core: TCore, dispatch?:
|
|
411
|
-
protected abstract buildSender(event: Event, core: TCore,
|
|
391
|
+
protected constructor(event: Event, core: TCore, dispatch: DispatchContext, sender?: TSender);
|
|
392
|
+
protected abstract buildSender(event: Event, core: TCore, dispatch: DispatchContext): TSender;
|
|
412
393
|
/** Send the initial response, exactly once. */
|
|
413
394
|
protected reply(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
|
|
414
395
|
/** Show a "thinking" placeholder, then fill it later with {@link edit}. */
|
|
@@ -860,7 +841,7 @@ interface PageView<Item> {
|
|
|
860
841
|
*/
|
|
861
842
|
declare function paginate<Item>(items: readonly Item[], page: number, perPage: number): PageView<Item>;
|
|
862
843
|
//#endregion
|
|
863
|
-
//#region src/pagination/
|
|
844
|
+
//#region src/pagination/Controls.d.ts
|
|
864
845
|
/** The five built-in nav controls. */
|
|
865
846
|
type ControlKey = 'first' | 'prev' | 'indicator' | 'next' | 'last';
|
|
866
847
|
type CustomIdStyle = ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger;
|
|
@@ -982,5 +963,5 @@ declare abstract class PaginatorBase<Item, Prefix extends string, Ctx> {
|
|
|
982
963
|
/** Package version */
|
|
983
964
|
declare const version: string;
|
|
984
965
|
//#endregion
|
|
985
|
-
export { ArraySourceBase, type AttemptedWrite, type AutocompleteOptions, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, type BuilderType, Bus, ButtonRoute, ChannelMenuRoute, type CommandInfo, Commands, type ContextMenuInfo, ContextMenus, type ControlCosmetics, type ControlKey, Cooldown, type CooldownOptions, type CoreBase, CursorSourceBase, CustomId, DispatchContext, type DispatchOutcome, type
|
|
966
|
+
export { type AnyCustomId, ArraySourceBase, type AttemptedWrite, type AutocompleteOptions, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, type BuilderType, Bus, ButtonRoute, ChannelMenuRoute, type CommandInfo, Commands, type ContextMenuInfo, ContextMenus, type ControlCosmetics, type ControlKey, Cooldown, type CooldownOptions, type CoreBase, CursorSourceBase, CustomId, type CustomIdField, type CustomIdShape, type DecodedParams, type DecodedRoute, DispatchContext, type DispatchOutcome, type DispatchResult, DmOnly, type EffectGate, type EventDispatchResult, Fault, type FaultSource, type FieldOptions, type Gate, type GateContextBase, type GateNoticeOptions, GuildOnly, type GuildPermissionsContext, type HandlerOutcome, type HandlerResult, type InjectedCommandMap, type InjectedContextMenuMap, InteractionKind, type InteractionMiddlewareOptions, type ItemRender, MentionableMenuRoute, type MessageContextMenuRegistry, MessageContextMenuRoute, type MiddlewareKind, type ModalLike, ModalRoute, Notice, OwnerOnly, type PageRender, type PageSourceBase, type PageView, PaginatorBase, type PaginatorConfig, type PaginatorControls, type PermissionAssertion, type PermissionNoticeOverrides, type PermissionScope, RegisterCommand, RegisterInteractionMiddleware, RepliableHandler, RequireBotPermissions, RequirePermissions, type RequirePermissionsOptions, RequireRole, type RequireRoleOptions, type RequiredOf, ResolvedEmoji, type ResponseAttempt, type ResponseFailed, type ResponseOutcome, type ResponseSent, RoleMenuRoute, RowComponent, type RowType, ShutdownPhase, Silence, type SlashRegistry, SlashRoute, StartupPhase, StringMenuRoute, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type UserContextMenuRegistry, UserContextMenuRoute, UserMenuRoute, type WebhookFile, WebhookLog, type WebhookReport, WebhookUrl, and, assertPermissions, decodeFor, defineEffectGate, defineGate, mergeRoles, or, paginate, prefixOf, setCustomIdErrors, version };
|
|
986
967
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as translateSerializationError, B as
|
|
2
|
-
import { A as
|
|
3
|
-
import { n as Commands, r as ContextMenus } from "./subscribers-
|
|
1
|
+
import { A as translateSerializationError, B as contextMenuRouteOf, C as NotInDm, D as defineEffectGate, E as OnCooldown, F as checkAckLegality, H as storeComponentRoute, I as sendTarget, K as NoticeCard, L as RegisterInteractionMiddleware, M as publishResponse, O as defineGate, P as AckTrace, S as NotAllowed, T as NotOwner, U as storeInteractionRoute, a as RequirePermissions, c as hasAll, d as pickNotice, h as runCheck, i as RequireBotPermissions, j as attemptWrite, k as serializeReply, l as missingNames, m as rollbackCommits, n as pageCursor, o as RequireRole, p as markCommits, q as Notice, r as Silence, t as PAGE_MAX, u as presentNames, v as HasDangerousPermissions, w as NotInGuild, x as NeedsAny, y as MissingPermissions } from "./cursor-CFNKLVlk.mjs";
|
|
2
|
+
import { A as BuilderComponent, b as InteractionKind, d as WebhookLog, f as Subscriber, g as CommandMetadataKey, j as RowComponent, l as WebhookUrl, t as Bus, u as Subscribe } from "./Bus-Djm6688b.mjs";
|
|
3
|
+
import { n as Commands, r as ContextMenus } from "./subscribers-Bf4cBTvK.mjs";
|
|
4
4
|
import { n as StartupPhase, t as ShutdownPhase } from "./phases-BauKJOTT.mjs";
|
|
5
5
|
import "reflect-metadata";
|
|
6
|
-
import { CustomId, setCustomIdErrors, setCustomIdErrors as setCustomIdErrors$1 } from "@seedcord/custom-id";
|
|
6
|
+
import { CustomId, decodeFor, prefixOf, setCustomIdErrors, setCustomIdErrors as setCustomIdErrors$1 } from "@seedcord/custom-id";
|
|
7
7
|
import { ActionRowBuilder, ButtonBuilder, TextDisplayBuilder } from "@discordjs/builders";
|
|
8
8
|
import { ApplicationCommandType, ButtonStyle } from "discord-api-types/v10";
|
|
9
9
|
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
@@ -320,7 +320,8 @@ function MentionableMenuRoute(...defs) {
|
|
|
320
320
|
*/
|
|
321
321
|
var DispatchContext = class {
|
|
322
322
|
routeId;
|
|
323
|
-
state =
|
|
323
|
+
state = Object.create(null);
|
|
324
|
+
id = crypto.randomUUID();
|
|
324
325
|
constructor(routeId) {
|
|
325
326
|
this.routeId = routeId;
|
|
326
327
|
}
|
|
@@ -330,6 +331,16 @@ var DispatchContext = class {
|
|
|
330
331
|
get(key) {
|
|
331
332
|
return this.state[key];
|
|
332
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Read a key that must be present, with `undefined` stripped from the result.
|
|
336
|
+
*
|
|
337
|
+
* @throws A **SeedcordError** If nothing set the key on this dispatch.
|
|
338
|
+
*/
|
|
339
|
+
require(key) {
|
|
340
|
+
const value = this.state[key];
|
|
341
|
+
if (value === void 0) throw new SeedcordError(SeedcordErrorCode.DispatchStateMissing, [String(key)]);
|
|
342
|
+
return value;
|
|
343
|
+
}
|
|
333
344
|
};
|
|
334
345
|
|
|
335
346
|
//#endregion
|
|
@@ -345,6 +356,7 @@ var BaseHandler = class {
|
|
|
345
356
|
core;
|
|
346
357
|
event;
|
|
347
358
|
logger;
|
|
359
|
+
/** The bag for this dispatch. Each interaction gets its own. Every handler for one event shares a single bag. */
|
|
348
360
|
dispatch;
|
|
349
361
|
constructor(event, core, dispatch, channel) {
|
|
350
362
|
this.core = core;
|
|
@@ -357,8 +369,8 @@ var BaseHandler = class {
|
|
|
357
369
|
//#endregion
|
|
358
370
|
//#region src/handlers/RepliableHandler.ts
|
|
359
371
|
/**
|
|
360
|
-
* Shared base the repliable handlers on both transports extend. Defines the reply members over
|
|
361
|
-
*
|
|
372
|
+
* Shared base the repliable handlers on both transports extend. Defines the reply members over one sender.
|
|
373
|
+
* A handler builds its own through `buildSender`. A middleware takes the handler's.
|
|
362
374
|
*
|
|
363
375
|
* @typeParam Event - The repliable interaction type this handler processes
|
|
364
376
|
* @typeParam TCore - The transport's Core
|
|
@@ -370,10 +382,10 @@ var RepliableHandler = class extends BaseHandler {
|
|
|
370
382
|
/** The reply surface for this interaction. Pass the handler to reply from outside its class. */
|
|
371
383
|
sender;
|
|
372
384
|
routeId;
|
|
373
|
-
constructor(event, core, dispatch) {
|
|
385
|
+
constructor(event, core, dispatch, sender) {
|
|
374
386
|
super(event, core, dispatch, "interactions");
|
|
375
|
-
this.routeId = dispatch
|
|
376
|
-
this.sender = this.buildSender(event, core,
|
|
387
|
+
this.routeId = dispatch.routeId;
|
|
388
|
+
this.sender = sender ?? this.buildSender(event, core, dispatch);
|
|
377
389
|
}
|
|
378
390
|
/** Send the initial response, exactly once. */
|
|
379
391
|
reply(response, opts) {
|
|
@@ -410,19 +422,19 @@ var RepliableHandler = class extends BaseHandler {
|
|
|
410
422
|
* supplies the writers.
|
|
411
423
|
*/
|
|
412
424
|
var BaseReplySender = class {
|
|
413
|
-
routeId;
|
|
414
425
|
telemetry;
|
|
415
426
|
state;
|
|
416
427
|
sent = /* @__PURE__ */ new Set();
|
|
417
428
|
ackedBy;
|
|
418
|
-
constructor(
|
|
419
|
-
this.routeId = routeId;
|
|
429
|
+
constructor(telemetry, initialState = "unacked") {
|
|
420
430
|
this.telemetry = telemetry;
|
|
421
431
|
this.state = initialState;
|
|
422
432
|
}
|
|
433
|
+
get routeId() {
|
|
434
|
+
return this.telemetry.dispatch.routeId;
|
|
435
|
+
}
|
|
423
436
|
report(method, startedAt, messageId) {
|
|
424
437
|
publishResponse(this.telemetry, {
|
|
425
|
-
routeId: this.routeId,
|
|
426
438
|
method,
|
|
427
439
|
startedAt,
|
|
428
440
|
outcome: "sent",
|
|
@@ -430,7 +442,7 @@ var BaseReplySender = class {
|
|
|
430
442
|
});
|
|
431
443
|
}
|
|
432
444
|
async attempt(method, startedAt, write) {
|
|
433
|
-
return await attemptWrite(this.telemetry,
|
|
445
|
+
return await attemptWrite(this.telemetry, method, startedAt, write);
|
|
434
446
|
}
|
|
435
447
|
async reply(response, opts) {
|
|
436
448
|
this.checkLegality("reply");
|
|
@@ -806,7 +818,7 @@ function Cooldown(duration, options) {
|
|
|
806
818
|
limit: options.limit
|
|
807
819
|
};
|
|
808
820
|
const anonId = anonSeq++;
|
|
809
|
-
const keyOf = (ctx) => `cooldown:${ctx.
|
|
821
|
+
const keyOf = (ctx) => `cooldown:${ctx.declaredRoute ?? `anon${anonId}`}:${per}:w${windowMs}:l${options?.limit ?? 1}:${scopeValue(ctx, per)}`;
|
|
810
822
|
return defineEffectGate("Cooldown", async (ctx) => {
|
|
811
823
|
const result = await ctx.core.rateLimiter.peek(keyOf(ctx), window);
|
|
812
824
|
if (!result.limited) return;
|
|
@@ -972,7 +984,7 @@ function paginate(items, page, perPage) {
|
|
|
972
984
|
}
|
|
973
985
|
|
|
974
986
|
//#endregion
|
|
975
|
-
//#region src/pagination/
|
|
987
|
+
//#region src/pagination/Controls.ts
|
|
976
988
|
const DEFAULT_LABEL = {
|
|
977
989
|
first: "First",
|
|
978
990
|
prev: "Prev",
|
|
@@ -1177,8 +1189,8 @@ var CursorSourceBase = class {
|
|
|
1177
1189
|
//#endregion
|
|
1178
1190
|
//#region src/index.ts
|
|
1179
1191
|
/** Package version */
|
|
1180
|
-
const version = "0.
|
|
1192
|
+
const version = "0.7.0";
|
|
1181
1193
|
|
|
1182
1194
|
//#endregion
|
|
1183
|
-
export { ArraySourceBase, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, Bus, ButtonRoute, ChannelMenuRoute, Commands, ContextMenus, Cooldown, CursorSourceBase, CustomId, DispatchContext, DmOnly, Fault, GuildOnly, InteractionKind, MentionableMenuRoute, MessageContextMenuRoute, ModalRoute, Notice, OwnerOnly, PaginatorBase, RegisterCommand, RepliableHandler, RequireBotPermissions, RequirePermissions, RequireRole, ResolvedEmoji, RoleMenuRoute, RowComponent, ShutdownPhase, Silence, SlashRoute, StartupPhase, StringMenuRoute, Subscribe, Subscriber, UserContextMenuRoute, UserMenuRoute, WebhookLog, WebhookUrl, and, assertPermissions, defineEffectGate, defineGate, mergeRoles, or, paginate, setCustomIdErrors, version };
|
|
1195
|
+
export { ArraySourceBase, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, Bus, ButtonRoute, ChannelMenuRoute, Commands, ContextMenus, Cooldown, CursorSourceBase, CustomId, DispatchContext, DmOnly, Fault, GuildOnly, InteractionKind, MentionableMenuRoute, MessageContextMenuRoute, ModalRoute, Notice, OwnerOnly, PaginatorBase, RegisterCommand, RegisterInteractionMiddleware, RepliableHandler, RequireBotPermissions, RequirePermissions, RequireRole, ResolvedEmoji, RoleMenuRoute, RowComponent, ShutdownPhase, Silence, SlashRoute, StartupPhase, StringMenuRoute, Subscribe, Subscriber, UserContextMenuRoute, UserMenuRoute, WebhookLog, WebhookUrl, and, assertPermissions, decodeFor, defineEffectGate, defineGate, mergeRoles, or, paginate, prefixOf, setCustomIdErrors, version };
|
|
1184
1196
|
//# sourceMappingURL=index.mjs.map
|