@seedcord/core 0.6.0 → 0.8.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.
Files changed (33) hide show
  1. package/dist/{Bus-dGy6xq3F.mjs → Bus-Djm6688b.mjs} +6 -5
  2. package/dist/Bus-Djm6688b.mjs.map +1 -0
  3. package/dist/{Pluggable-B7_EftHj.mjs → Pluggable-BShEwGw9.mjs} +40 -7
  4. package/dist/Pluggable-BShEwGw9.mjs.map +1 -0
  5. package/dist/{Pluggable-C5uxmDb-.d.mts → Pluggable-CAteNmfy.d.mts} +11 -5
  6. package/dist/Plugin-BJfRk0s_.mjs.map +1 -1
  7. package/dist/{Plugin-Bnz61fs_.d.mts → Plugin-D3wIj0xX.d.mts} +8 -5
  8. package/dist/{cursor-8Y2zpF-Y.d.mts → cursor-BPaPFTic.d.mts} +186 -14
  9. package/dist/{cursor-BkI9lxy2.mjs → cursor-CFNKLVlk.mjs} +49 -11
  10. package/dist/cursor-CFNKLVlk.mjs.map +1 -0
  11. package/dist/{index-CD8l15aZ.d.mts → index-BS1hH9Sh.d.mts} +2 -2
  12. package/dist/index.d.mts +16 -35
  13. package/dist/index.mjs +29 -37
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/internal.index.d.mts +79 -8
  16. package/dist/internal.index.mjs +121 -16
  17. package/dist/internal.index.mjs.map +1 -1
  18. package/dist/node-internal.index.d.mts +6 -4
  19. package/dist/node-internal.index.mjs +38 -14
  20. package/dist/node-internal.index.mjs.map +1 -1
  21. package/dist/node.index.d.mts +1 -1
  22. package/dist/node.index.mjs +1 -1
  23. package/dist/{phases-D0a8BV9Z.d.mts → phases-DJf12l5T.d.mts} +48 -9
  24. package/dist/plugin.index.d.mts +1 -1
  25. package/dist/{slashRouteLeaves-C1msUE9Q.mjs → slashRouteLeaves-DTFHzCKN.mjs} +2 -2
  26. package/dist/{slashRouteLeaves-C1msUE9Q.mjs.map → slashRouteLeaves-DTFHzCKN.mjs.map} +1 -1
  27. package/dist/{subscribers-A8lNU5yM.mjs → subscribers-kAQQt_YP.mjs} +32 -4
  28. package/dist/subscribers-kAQQt_YP.mjs.map +1 -0
  29. package/package.json +8 -8
  30. package/dist/Bus-dGy6xq3F.mjs.map +0 -1
  31. package/dist/Pluggable-B7_EftHj.mjs.map +0 -1
  32. package/dist/cursor-BkI9lxy2.mjs.map +0 -1
  33. package/dist/subscribers-A8lNU5yM.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as Notice, I 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-D0a8BV9Z.mjs";
2
- import { $ as MessageContextMenuRegistry, C as Gate, D as defineEffectGate, E as RequiredOf, F as ContextMenuNamesBrand, H as RowComponent, I as SlashRouteBrand, M as ComponentDefsBrand, N as ComponentKindBrand, O as defineGate, P as ContextMenuKindBrand, R as RegisterCommand, S as EffectGate, T as GuildPermissionsContext, U as BuilderType, V as BuilderComponent, W as RowType, Y as SlashRegistry, Z as ContextMenuKind, a as AutocompleteOptions, b as JoinNames, d as RequirePermissionsOptions, et as NamesFor, f as RequireRole, g as GateNoticeOptions, h as PermissionScope, j as AutocompleteRouteBrand, k as SerializedReply, l as RequireBotPermissions, n as PageCursor, p as RequireRoleOptions, tt as UserContextMenuRegistry, u as RequirePermissions, w as GateContextBase, x as TwoOrMore, y as IntersectRequired, z as Promisable } from "./cursor-8Y2zpF-Y.mjs";
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 RowComponent, B as AutocompleteRouteBrand, C as Gate, D as defineEffectGate, E as RequiredOf, H as ComponentKindBrand, J as GuildTarget, K as SlashRouteBrand, L as InteractionMiddlewareOptions, M as EventDispatchResult, N as HandlerOutcome, O as defineGate, P as HandlerResult, Q as BuilderComponent, R as RegisterInteractionMiddleware, S as EffectGate, T as GuildPermissionsContext, U as ContextMenuKindBrand, V as ComponentDefsBrand, W as ContextMenuNamesBrand, X as Promisable, Y as RegisterCommand, a as AutocompleteOptions, b as JoinNames, ct as ContextMenuKind, d as RequirePermissionsOptions, dt as NamesFor, et as BuilderType, f as RequireRole, ft as UserContextMenuRegistry, g as GateNoticeOptions, h as PermissionScope, j as DispatchResult, k as SerializedReply, l as RequireBotPermissions, n as PageCursor, ot as SlashRegistry, p as RequireRoleOptions, tt as RowType, u as RequirePermissions, ut as MessageContextMenuRegistry, w as GateContextBase, x as TwoOrMore, y as IntersectRequired } from "./cursor-BPaPFTic.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-CD8l15aZ.mjs";
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
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";
@@ -85,9 +85,9 @@ type ComponentOf<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends {
85
85
  type DefsOf<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends {
86
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]>;
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
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`.
@@ -290,26 +290,6 @@ declare function ChannelMenuRoute<const Defs extends readonly AnyCustomId$1[]>(.
290
290
  */
291
291
  declare function MentionableMenuRoute<const Defs extends readonly AnyCustomId$1[]>(...defs: Defs): <TCtor extends AnyHandlerCtor>(constructor: AssertComponentRoute<InteractionKind.MentionableMenu, Defs, TCtor>) => void;
292
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
- }
312
- //#endregion
313
293
  //#region src/handlers/BaseHandler.d.ts
314
294
  /**
315
295
  * Base class every transport handler extends. Don't register handlers directly. Use the more specific
@@ -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
- protected readonly dispatch?: DispatchContext | undefined;
326
- protected constructor(event: Event, core: TCore, dispatch?: DispatchContext, channel?: LoggerChannelId);
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(routeId: string, telemetry: ReplyTelemetry, initialState?: AckState);
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 the sender
396
- * the transport builds.
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?: DispatchContext);
411
- protected abstract buildSender(event: Event, core: TCore, routeId: string): TSender;
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}. */
@@ -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 { 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 DispatchState, DmOnly, type EffectGate, Fault, type FaultSource, type FieldOptions, type Gate, type GateContextBase, type GateNoticeOptions, GuildOnly, type GuildPermissionsContext, type InjectedCommandMap, type InjectedContextMenuMap, InteractionKind, type ItemRender, MentionableMenuRoute, type MessageContextMenuRegistry, MessageContextMenuRoute, type ModalLike, ModalRoute, Notice, OwnerOnly, type PageRender, type PageSourceBase, type PageView, PaginatorBase, type PaginatorConfig, type PaginatorControls, type PermissionAssertion, type PermissionNoticeOverrides, type PermissionScope, RegisterCommand, 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 };
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 GuildTarget, 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,6 +1,6 @@
1
- import { A as translateSerializationError, B as storeComponentRoute, C as NotInDm, D as defineEffectGate, E as OnCooldown, F as checkAckLegality, G as Notice, I as sendTarget, M as publishResponse, O as defineGate, P as AckTrace, R as contextMenuRouteOf, S as NotAllowed, T as NotOwner, V as storeInteractionRoute, W as NoticeCard, 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, r as Silence, t as PAGE_MAX, u as presentNames, v as HasDangerousPermissions, w as NotInGuild, x as NeedsAny, y as MissingPermissions } from "./cursor-BkI9lxy2.mjs";
2
- import { A as RowComponent, d as WebhookLog, f as Subscriber, g as CommandMetadataKey, k as BuilderComponent, l as WebhookUrl, t as Bus, u as Subscribe, y as InteractionKind } from "./Bus-dGy6xq3F.mjs";
3
- import { n as Commands, r as ContextMenus } from "./subscribers-A8lNU5yM.mjs";
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, j as RowComponent, l as WebhookUrl, t as Bus, u as Subscribe } from "./Bus-Djm6688b.mjs";
3
+ import { a as ContextMenus, i as Commands, n as RegisterCommand } from "./subscribers-kAQQt_YP.mjs";
4
4
  import { n as StartupPhase, t as ShutdownPhase } from "./phases-BauKJOTT.mjs";
5
5
  import "reflect-metadata";
6
6
  import { CustomId, decodeFor, prefixOf, setCustomIdErrors, setCustomIdErrors as setCustomIdErrors$1 } from "@seedcord/custom-id";
@@ -44,26 +44,6 @@ setCustomIdErrors$1({
44
44
  invalid: (detail) => new InvalidCustomId(detail)
45
45
  });
46
46
 
47
- //#endregion
48
- //#region src/decorators/Command.ts
49
- function RegisterCommand(scope, guilds = []) {
50
- return (ctor) => {
51
- const existingMeta = Reflect.getOwnMetadata(CommandMetadataKey, ctor);
52
- if (existingMeta) throw new SeedcordError(SeedcordErrorCode.DecoratorCommandAlreadyRegistered, [
53
- ctor.name,
54
- existingMeta.scope,
55
- scope
56
- ]);
57
- if (scope === "global" && guilds.length > 0) throw new SeedcordTypeError(SeedcordErrorCode.DecoratorCommandGlobalWithGuilds);
58
- if (scope === "guild" && (!Array.isArray(guilds) || guilds.length === 0)) throw new SeedcordTypeError(SeedcordErrorCode.DecoratorCommandGuildWithoutGuilds);
59
- const meta = scope === "global" ? { scope } : {
60
- scope,
61
- guilds
62
- };
63
- Reflect.defineMetadata(CommandMetadataKey, meta, ctor);
64
- };
65
- }
66
-
67
47
  //#endregion
68
48
  //#region src/decorators/routes.ts
69
49
  /**
@@ -320,7 +300,8 @@ function MentionableMenuRoute(...defs) {
320
300
  */
321
301
  var DispatchContext = class {
322
302
  routeId;
323
- state = {};
303
+ state = Object.create(null);
304
+ id = crypto.randomUUID();
324
305
  constructor(routeId) {
325
306
  this.routeId = routeId;
326
307
  }
@@ -330,6 +311,16 @@ var DispatchContext = class {
330
311
  get(key) {
331
312
  return this.state[key];
332
313
  }
314
+ /**
315
+ * Read a key that must be present, with `undefined` stripped from the result.
316
+ *
317
+ * @throws A **SeedcordError** If nothing set the key on this dispatch.
318
+ */
319
+ require(key) {
320
+ const value = this.state[key];
321
+ if (value === void 0) throw new SeedcordError(SeedcordErrorCode.DispatchStateMissing, [String(key)]);
322
+ return value;
323
+ }
333
324
  };
334
325
 
335
326
  //#endregion
@@ -345,6 +336,7 @@ var BaseHandler = class {
345
336
  core;
346
337
  event;
347
338
  logger;
339
+ /** The bag for this dispatch. Each interaction gets its own. Every handler for one event shares a single bag. */
348
340
  dispatch;
349
341
  constructor(event, core, dispatch, channel) {
350
342
  this.core = core;
@@ -357,8 +349,8 @@ var BaseHandler = class {
357
349
  //#endregion
358
350
  //#region src/handlers/RepliableHandler.ts
359
351
  /**
360
- * Shared base the repliable handlers on both transports extend. Defines the reply members over the sender
361
- * the transport builds.
352
+ * Shared base the repliable handlers on both transports extend. Defines the reply members over one sender.
353
+ * A handler builds its own through `buildSender`. A middleware takes the handler's.
362
354
  *
363
355
  * @typeParam Event - The repliable interaction type this handler processes
364
356
  * @typeParam TCore - The transport's Core
@@ -370,10 +362,10 @@ var RepliableHandler = class extends BaseHandler {
370
362
  /** The reply surface for this interaction. Pass the handler to reply from outside its class. */
371
363
  sender;
372
364
  routeId;
373
- constructor(event, core, dispatch) {
365
+ constructor(event, core, dispatch, sender) {
374
366
  super(event, core, dispatch, "interactions");
375
- this.routeId = dispatch?.routeId ?? this.constructor.name;
376
- this.sender = this.buildSender(event, core, this.routeId);
367
+ this.routeId = dispatch.routeId;
368
+ this.sender = sender ?? this.buildSender(event, core, dispatch);
377
369
  }
378
370
  /** Send the initial response, exactly once. */
379
371
  reply(response, opts) {
@@ -410,19 +402,19 @@ var RepliableHandler = class extends BaseHandler {
410
402
  * supplies the writers.
411
403
  */
412
404
  var BaseReplySender = class {
413
- routeId;
414
405
  telemetry;
415
406
  state;
416
407
  sent = /* @__PURE__ */ new Set();
417
408
  ackedBy;
418
- constructor(routeId, telemetry, initialState = "unacked") {
419
- this.routeId = routeId;
409
+ constructor(telemetry, initialState = "unacked") {
420
410
  this.telemetry = telemetry;
421
411
  this.state = initialState;
422
412
  }
413
+ get routeId() {
414
+ return this.telemetry.dispatch.routeId;
415
+ }
423
416
  report(method, startedAt, messageId) {
424
417
  publishResponse(this.telemetry, {
425
- routeId: this.routeId,
426
418
  method,
427
419
  startedAt,
428
420
  outcome: "sent",
@@ -430,7 +422,7 @@ var BaseReplySender = class {
430
422
  });
431
423
  }
432
424
  async attempt(method, startedAt, write) {
433
- return await attemptWrite(this.telemetry, this.routeId, method, startedAt, write);
425
+ return await attemptWrite(this.telemetry, method, startedAt, write);
434
426
  }
435
427
  async reply(response, opts) {
436
428
  this.checkLegality("reply");
@@ -806,7 +798,7 @@ function Cooldown(duration, options) {
806
798
  limit: options.limit
807
799
  };
808
800
  const anonId = anonSeq++;
809
- const keyOf = (ctx) => `cooldown:${ctx.routeId ?? `anon${anonId}`}:${per}:w${windowMs}:l${options?.limit ?? 1}:${scopeValue(ctx, per)}`;
801
+ const keyOf = (ctx) => `cooldown:${ctx.declaredRoute ?? `anon${anonId}`}:${per}:w${windowMs}:l${options?.limit ?? 1}:${scopeValue(ctx, per)}`;
810
802
  return defineEffectGate("Cooldown", async (ctx) => {
811
803
  const result = await ctx.core.rateLimiter.peek(keyOf(ctx), window);
812
804
  if (!result.limited) return;
@@ -1177,8 +1169,8 @@ var CursorSourceBase = class {
1177
1169
  //#endregion
1178
1170
  //#region src/index.ts
1179
1171
  /** Package version */
1180
- const version = "0.6.0";
1172
+ const version = "0.8.0";
1181
1173
 
1182
1174
  //#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, decodeFor, defineEffectGate, defineGate, mergeRoles, or, paginate, prefixOf, setCustomIdErrors, version };
1175
+ 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
1176
  //# sourceMappingURL=index.mjs.map