@seedcord/core 0.1.1-next.0 → 0.1.2
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/HmrModuleHandler-CxGOo1LT.cjs.map +1 -1
- package/dist/HmrModuleHandler-KxRP8lqJ.mjs.map +1 -1
- package/dist/Plugin-CDAV7P9l.mjs.map +1 -1
- package/dist/Plugin-DVNh1kvX.cjs.map +1 -1
- package/dist/{Plugin-BPz0obbN.d.mts → Plugin-qRc7Ch4g.d.mts} +22 -43
- package/dist/{basic-CeSFvbaz.d.mts → basic-Dng__Ena.d.mts} +2 -2
- package/dist/{contextMenuLeaves-CC3-qObq.d.mts → contextMenuLeaves-COzDYa6c.d.mts} +4 -5
- package/dist/{cursor-Bk-W5MTq.d.mts → cursor-C77xH5QT.d.mts} +30 -52
- package/dist/{cursor-Y6ct-N_8.mjs → cursor-D207VrRo.mjs} +20 -44
- package/dist/cursor-D207VrRo.mjs.map +1 -0
- package/dist/{cursor-D2iP-CCS.cjs → cursor-DFgJ70_B.cjs} +20 -44
- package/dist/cursor-DFgJ70_B.cjs.map +1 -0
- package/dist/{index-Dm0WKN37.d.mts → index-C0k7lRDi.d.mts} +3 -14
- package/dist/index.cjs +17 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +21 -24
- package/dist/index.mjs +17 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.cjs +10 -48
- package/dist/internal.index.cjs.map +1 -1
- package/dist/internal.index.d.mts +15 -62
- package/dist/internal.index.mjs +10 -48
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.cjs +3 -76
- package/dist/node-internal.index.cjs.map +1 -1
- package/dist/node-internal.index.d.mts +4 -76
- package/dist/node-internal.index.mjs +3 -76
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/plugin.index.d.mts +1 -1
- package/dist/{publishDefault-CldnxcT2.mjs → publishDefault-BCrMG9T8.mjs} +5 -19
- package/dist/publishDefault-BCrMG9T8.mjs.map +1 -0
- package/dist/{publishDefault-CVlwYUS5.cjs → publishDefault-D52iT8mF.cjs} +5 -19
- package/dist/publishDefault-D52iT8mF.cjs.map +1 -0
- package/dist/{slashRouteLeaves-BANDtPFm.mjs → slashRouteLeaves-De1SxqnX.mjs} +4 -4
- package/dist/slashRouteLeaves-De1SxqnX.mjs.map +1 -0
- package/dist/{slashRouteLeaves-nfxOAM7Q.cjs → slashRouteLeaves-HVl6Ymr0.cjs} +4 -4
- package/dist/slashRouteLeaves-HVl6Ymr0.cjs.map +1 -0
- package/dist/{subscribers-CDbep0RH.cjs → subscribers-6x4xw39Z.cjs} +8 -26
- package/dist/subscribers-6x4xw39Z.cjs.map +1 -0
- package/dist/{subscribers-xO6DZ-70.mjs → subscribers-nEpbJj3Z.mjs} +8 -26
- package/dist/subscribers-nEpbJj3Z.mjs.map +1 -0
- package/package.json +9 -9
- package/dist/cursor-D2iP-CCS.cjs.map +0 -1
- package/dist/cursor-Y6ct-N_8.mjs.map +0 -1
- package/dist/publishDefault-CVlwYUS5.cjs.map +0 -1
- package/dist/publishDefault-CldnxcT2.mjs.map +0 -1
- package/dist/slashRouteLeaves-BANDtPFm.mjs.map +0 -1
- package/dist/slashRouteLeaves-nfxOAM7Q.cjs.map +0 -1
- package/dist/subscribers-CDbep0RH.cjs.map +0 -1
- package/dist/subscribers-xO6DZ-70.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as CommandBuilder, r as DeployResult, t as Constructor } from "./basic-
|
|
2
|
-
import { A as AckState, D as Notice, O as ReplyTelemetry, V as InteractionRoutes, g as CoreBase } from "./Plugin-
|
|
1
|
+
import { n as CommandBuilder, r as DeployResult, t as Constructor } from "./basic-Dng__Ena.mjs";
|
|
2
|
+
import { A as AckState, D as Notice, O as ReplyTelemetry, V as InteractionRoutes, g as CoreBase } from "./Plugin-qRc7Ch4g.mjs";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
import { ActionRowBuilder, ButtonBuilder, ChannelSelectMenuBuilder, CheckboxBuilder, CheckboxGroupBuilder, CheckboxGroupOptionBuilder, ContainerBuilder, ContextMenuCommandBuilder, EmbedBuilder, FileBuilder, FileUploadBuilder, LabelBuilder, MediaGalleryBuilder, MentionableSelectMenuBuilder, ModalBuilder, RadioGroupBuilder, RadioGroupOptionBuilder, RoleSelectMenuBuilder, SectionBuilder, SeparatorBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextDisplayBuilder, TextInputBuilder, UserSelectMenuBuilder } from "@discordjs/builders";
|
|
5
5
|
import { APIMessageTopLevelComponent, APIModalInteractionResponseCallbackData, ApplicationCommandType, ChannelType, Snowflake } from "discord-api-types/v10";
|
|
@@ -119,11 +119,7 @@ interface InjectedContextMenuMap {
|
|
|
119
119
|
* ```
|
|
120
120
|
*/
|
|
121
121
|
declare const ContextMenus: InjectedContextMenuMap;
|
|
122
|
-
/**
|
|
123
|
-
* Records each deployed command on {@link Commands} and {@link ContextMenus}.
|
|
124
|
-
*
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
122
|
+
/** @internal */
|
|
127
123
|
declare class CommandInjector {
|
|
128
124
|
private readonly logger;
|
|
129
125
|
inject(deploy: DeployResult, all: readonly CommandBuilder[]): void;
|
|
@@ -202,21 +198,14 @@ type RowType = keyof typeof RowTypes;
|
|
|
202
198
|
type InstantiatedActionRow<RowKey extends RowType> = InstanceType<(typeof RowTypes)[RowKey]>;
|
|
203
199
|
//#endregion
|
|
204
200
|
//#region src/components/Component.d.ts
|
|
205
|
-
/**
|
|
206
|
-
* Base class for Discord component wrappers.
|
|
207
|
-
*
|
|
208
|
-
* @typeParam TComponent - The Discord.js component type being wrapped
|
|
209
|
-
*
|
|
210
|
-
* @internal
|
|
211
|
-
*/
|
|
201
|
+
/** @internal */
|
|
212
202
|
declare abstract class BaseComponent<TComponent> {
|
|
213
203
|
private readonly _component;
|
|
214
204
|
protected constructor(ComponentClass: new () => TComponent);
|
|
215
205
|
/**
|
|
216
206
|
* Returns the live builder, ready to send in a Discord message or nest in another component.
|
|
217
207
|
*
|
|
218
|
-
*
|
|
219
|
-
* {@link BuilderComponent}), so it has a side effect.
|
|
208
|
+
* Reading this can apply the bot color (see {@link BuilderComponent}), so it has a side effect.
|
|
220
209
|
* @example new SomeComponent().component
|
|
221
210
|
*/
|
|
222
211
|
abstract get component(): InstantiatedBuilder<BuilderType> | InstantiatedActionRow<RowType>;
|
|
@@ -375,7 +364,6 @@ type CommandMeta = GlobalMeta | GuildMeta;
|
|
|
375
364
|
/**
|
|
376
365
|
* Attaches deployment metadata so the framework registers this command globally or in specific guilds.
|
|
377
366
|
*
|
|
378
|
-
* @param scope - Must be 'global' for global registration
|
|
379
367
|
* @decorator
|
|
380
368
|
* @example
|
|
381
369
|
* ```typescript
|
|
@@ -387,7 +375,6 @@ declare function RegisterCommand(scope: 'global'): (ctor: CommandCtor) => void;
|
|
|
387
375
|
/**
|
|
388
376
|
* Registers a command for specific guild deployment.
|
|
389
377
|
*
|
|
390
|
-
* @param scope - Must be 'guild' for guild-specific registration
|
|
391
378
|
* @param guilds - Array of guild IDs where the command should be registered
|
|
392
379
|
* @decorator
|
|
393
380
|
* @example
|
|
@@ -434,7 +421,8 @@ type DecodedParams<Shape extends CustomIdShape> = { [Name in keyof Shape]: Shape
|
|
|
434
421
|
declare function prefixOf(wire: string): string;
|
|
435
422
|
/**
|
|
436
423
|
* A typed customId. The single source of truth shared by the component that mints it and the handler
|
|
437
|
-
* that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
|
|
424
|
+
* that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
|
|
425
|
+
* into a compact wire string, which fits more of them inside Discord's 100-char limit.
|
|
438
426
|
*
|
|
439
427
|
* @typeParam Prefix - The stable route prefix, e.g. 'approve'.
|
|
440
428
|
* @typeParam Shape - The accumulated fields, filled in by the chain.
|
|
@@ -448,7 +436,7 @@ declare function prefixOf(wire: string): string;
|
|
|
448
436
|
* // Set the custom id on a button when creating it.
|
|
449
437
|
* new ButtonBuilder().setCustomId(ApproveId.encode({ userId: '123', action: 'approve' }));
|
|
450
438
|
*
|
|
451
|
-
* //
|
|
439
|
+
* // in the handler, userId comes back a string
|
|
452
440
|
* const { userId, action } = this.params; // userId: string, action: 'approve' | 'deny'
|
|
453
441
|
* await this.event.guild?.members.fetch(userId);
|
|
454
442
|
* ```
|
|
@@ -456,7 +444,7 @@ declare function prefixOf(wire: string): string;
|
|
|
456
444
|
declare class CustomId<Prefix extends string, Shape extends CustomIdShape = {}> {
|
|
457
445
|
/** The stable route prefix, e.g. 'approve'. */
|
|
458
446
|
readonly prefix: Prefix;
|
|
459
|
-
/**
|
|
447
|
+
/** The field definitions accumulated by the chain, keyed by name. */
|
|
460
448
|
readonly shape: Shape;
|
|
461
449
|
/** The prefix plus a short hash of the shape, the part of the wire before the colon. */
|
|
462
450
|
readonly routeKey: string;
|
|
@@ -517,7 +505,8 @@ declare class CustomId<Prefix extends string, Shape extends CustomIdShape = {}>
|
|
|
517
505
|
*/
|
|
518
506
|
oneOf<Name extends string, const Choices extends NonEmptyTuple<string>>(name: Name, choices: Choices): CustomId<Prefix, Shape & Record<Name, CustomIdField<Choices[number]>>>;
|
|
519
507
|
/**
|
|
520
|
-
* Add a free short text field. Avoid it where possible
|
|
508
|
+
* Add a free short text field. Avoid it where possible. It cannot be packed, which makes it the most
|
|
509
|
+
* expensive field on the wire.
|
|
521
510
|
*
|
|
522
511
|
* @example
|
|
523
512
|
* ```ts
|
|
@@ -545,11 +534,7 @@ declare class CustomId<Prefix extends string, Shape extends CustomIdShape = {}>
|
|
|
545
534
|
/** True if this wire was minted from this customId's prefix, ignoring the shape hash. */
|
|
546
535
|
owns(wire: string): boolean;
|
|
547
536
|
}
|
|
548
|
-
/**
|
|
549
|
-
* Any customId, for places where the exact prefix and shape do not matter.
|
|
550
|
-
*
|
|
551
|
-
* @internal
|
|
552
|
-
*/
|
|
537
|
+
/** @internal */
|
|
553
538
|
type AnyCustomId = CustomId<string, CustomIdShape>;
|
|
554
539
|
/**
|
|
555
540
|
* The outcome of decoding a wire against several customIds, the matched prefix paired with its values.
|
|
@@ -560,11 +545,7 @@ type DecodedRoute<Defs extends readonly AnyCustomId[]> = { [Index in keyof Defs]
|
|
|
560
545
|
readonly prefix: Defs[Index]['prefix'];
|
|
561
546
|
readonly params: DecodedParams<Defs[Index]['shape']>;
|
|
562
547
|
} : never; }[number];
|
|
563
|
-
/**
|
|
564
|
-
* Find the customId whose prefix owns this wire, decode against it, and report which one matched.
|
|
565
|
-
*
|
|
566
|
-
* @internal
|
|
567
|
-
*/
|
|
548
|
+
/** @internal */
|
|
568
549
|
declare function decodeFor<Defs extends readonly AnyCustomId[]>(defs: Defs, wire: string): DecodedRoute<Defs>;
|
|
569
550
|
//#endregion
|
|
570
551
|
//#region src/decorators/interactionRoutes.d.ts
|
|
@@ -579,7 +560,7 @@ declare enum SelectMenuKind {
|
|
|
579
560
|
type RoutableConstructor = new (...args: never[]) => unknown;
|
|
580
561
|
declare function areRoutes(routes: unknown): routes is string[];
|
|
581
562
|
/**
|
|
582
|
-
*
|
|
563
|
+
* every stored route kind and its route strings on a decorated constructor. the build's manifest
|
|
583
564
|
* emitter reads the same pairs.
|
|
584
565
|
*/
|
|
585
566
|
declare function interactionRoutesOf(constructor: RoutableConstructor): [InteractionRoutes, string[]][];
|
|
@@ -589,13 +570,11 @@ declare function selectMenuRouteOf(kind: SelectMenuKind): InteractionRoutes;
|
|
|
589
570
|
declare function contextMenuRouteOf(kind: ContextMenuKind): InteractionRoutes;
|
|
590
571
|
//#endregion
|
|
591
572
|
//#region src/reply/serializeReply.d.ts
|
|
592
|
-
/** Serialized message data the transport wire writers consume. */
|
|
593
573
|
interface SerializedReply<TNative = never> {
|
|
594
574
|
readonly components: APIMessageTopLevelComponent[];
|
|
595
575
|
readonly allowedMentions?: ReplyResponse['allowedMentions'];
|
|
596
576
|
readonly files?: ReplyResponse<TNative>['files'];
|
|
597
577
|
}
|
|
598
|
-
/** Wraps a string in a TextDisplay component. */
|
|
599
578
|
declare function serializeReply<TNative>(response: ReplyResponse<TNative> | string, routeId: string): SerializedReply<TNative>;
|
|
600
579
|
//#endregion
|
|
601
580
|
//#region src/reply/BaseReplySender.d.ts
|
|
@@ -605,9 +584,9 @@ interface ModalLike {
|
|
|
605
584
|
}
|
|
606
585
|
/**
|
|
607
586
|
* Tracks acknowledgement state and throws a translated `SeedcordError` on an illegal verb before any
|
|
608
|
-
* transport call.
|
|
609
|
-
* state and ack trace. Each transport binds `TMessage` to its created-message
|
|
610
|
-
* writers.
|
|
587
|
+
* transport call. Every verb runs the legality check, calls the transport's wire writer, then updates
|
|
588
|
+
* the state and the ack trace. Each transport binds `TMessage` to its own created-message type and
|
|
589
|
+
* supplies the writers.
|
|
611
590
|
*/
|
|
612
591
|
declare abstract class BaseReplySender<TMessage extends {
|
|
613
592
|
id: string;
|
|
@@ -624,7 +603,7 @@ declare abstract class BaseReplySender<TMessage extends {
|
|
|
624
603
|
defer(opts?: DeferOpts): Promise<void>;
|
|
625
604
|
deferUpdate(): Promise<void>;
|
|
626
605
|
/**
|
|
627
|
-
* After a deferUpdate the state stays deferred-update
|
|
606
|
+
* After a deferUpdate the state stays deferred-update. Calling this again rewrites. The returned message
|
|
628
607
|
* is the source message, editable only through a bare `update` or `edit`. A targeted `edit` or `delete`
|
|
629
608
|
* of it throws the foreign-target error.
|
|
630
609
|
*/
|
|
@@ -688,7 +667,7 @@ interface GateContextBase {
|
|
|
688
667
|
readonly memberRoleIds: readonly string[];
|
|
689
668
|
/**
|
|
690
669
|
* The member's permission bits, or null outside a guild. On an interaction these are the
|
|
691
|
-
* channel-scoped permissions the payload contains, on a gateway event the member's guild-level ones.
|
|
670
|
+
* channel-scoped permissions the payload contains, and on a gateway event they're the member's guild-level ones.
|
|
692
671
|
*/
|
|
693
672
|
readonly memberPermissions: bigint | null;
|
|
694
673
|
/**
|
|
@@ -731,8 +710,8 @@ declare const GateBrand: unique symbol;
|
|
|
731
710
|
* a field absent on a handler's context is rejected at compile time. `Name` is captured as a literal so
|
|
732
711
|
* a mismatch error can name the gate. Build one with {@link defineGate} or {@link defineEffectGate}.
|
|
733
712
|
*
|
|
734
|
-
* @typeParam Ctx - The context the gate requires
|
|
735
|
-
* @typeParam Name - The gate's name
|
|
713
|
+
* @typeParam Ctx - The context the gate requires. A field missing from it is a compile error.
|
|
714
|
+
* @typeParam Name - The gate's literal name, named in a mismatch error.
|
|
736
715
|
*
|
|
737
716
|
* @example
|
|
738
717
|
* ```ts
|
|
@@ -756,12 +735,12 @@ interface Gate<Ctx extends GateContextBase = GateContextBase, Name extends strin
|
|
|
756
735
|
}
|
|
757
736
|
/**
|
|
758
737
|
* A gate that carries a side effect, split so the effect fires only once the gate is the one that
|
|
759
|
-
* let the request through. `check` peeks and refuses, `commit` applies the effect after the whole
|
|
738
|
+
* let the request through. `check` peeks and refuses, while `commit` applies the effect after the whole
|
|
760
739
|
* gate set passes. {@link Cooldown} is the catalog gate that returns one. Build one with
|
|
761
740
|
* {@link defineEffectGate}.
|
|
762
741
|
*
|
|
763
|
-
* @typeParam Ctx - The context
|
|
764
|
-
* @typeParam Name - The gate's name
|
|
742
|
+
* @typeParam Ctx - The context both `check` and `commit` require. A field missing from it fails to compile.
|
|
743
|
+
* @typeParam Name - The gate's literal name, shown when a mismatch error names the gate.
|
|
765
744
|
*
|
|
766
745
|
* @example
|
|
767
746
|
* ```ts
|
|
@@ -791,7 +770,7 @@ interface EffectGate<Ctx extends GateContextBase = GateContextBase, Name extends
|
|
|
791
770
|
* the check reads. No annotation defaults to {@link GateContextBase}, an agnostic gate that fits every
|
|
792
771
|
* handler.
|
|
793
772
|
*
|
|
794
|
-
* @typeParam Name - The gate's name captured as a literal
|
|
773
|
+
* @typeParam Name - The gate's name, captured as a literal for mismatch errors.
|
|
795
774
|
* @typeParam Ctx - The context the check reads, inferred from the `ctx` annotation.
|
|
796
775
|
*
|
|
797
776
|
* @param name - The gate's name, used in mismatch errors.
|
|
@@ -825,7 +804,7 @@ declare function defineGate<const Name extends string, Ctx extends GateContextBa
|
|
|
825
804
|
* commits. In an `or`, a refusing arm's queued commit is rolled back. This is how {@link Cooldown} peeks
|
|
826
805
|
* in `check` and charges the slot in `commit`.
|
|
827
806
|
*
|
|
828
|
-
* @typeParam Name - The gate's name
|
|
807
|
+
* @typeParam Name - The gate's literal name, used to name a mismatch error.
|
|
829
808
|
* @typeParam Ctx - The context both `check` and `commit` read, inferred from the `ctx` annotation.
|
|
830
809
|
*
|
|
831
810
|
* @param name - The gate's name, used in mismatch errors.
|
|
@@ -843,7 +822,7 @@ declare function defineGate<const Name extends string, Ctx extends GateContextBa
|
|
|
843
822
|
* return defineEffectGate(
|
|
844
823
|
* 'UsesPerDay',
|
|
845
824
|
* (ctx) => {
|
|
846
|
-
* // peek and refuse by throwing
|
|
825
|
+
* // peek and refuse by throwing. do not mutate yet
|
|
847
826
|
* if (usedToday(ctx.userId) >= max) throw new OutOfUsesNotice(max);
|
|
848
827
|
* },
|
|
849
828
|
* (ctx) => {
|
|
@@ -907,7 +886,6 @@ declare function pickNotice(options: GateNoticeOptions | undefined, makeDefault:
|
|
|
907
886
|
* `discord-api-types/v10` (or `discord.js`).
|
|
908
887
|
*/
|
|
909
888
|
type PermissionScope = readonly bigint[];
|
|
910
|
-
/** Permission bit to its prettified human-readable name. */
|
|
911
889
|
declare const PermissionNames: Map<bigint, string>;
|
|
912
890
|
//#endregion
|
|
913
891
|
//#region src/gates/catalog/permissions.d.ts
|
|
@@ -981,7 +959,7 @@ declare function RequirePermissions(scope: PermissionScope, options?: RequirePer
|
|
|
981
959
|
*
|
|
982
960
|
* The default `'channel'` scope reads the bot's effective channel set (wire `app_permissions`), what
|
|
983
961
|
* Discord enforces in the invoked channel. The `'guild'` scope reads the bot's base set from roles and
|
|
984
|
-
* requires a {@link GuildPermissionsContext},
|
|
962
|
+
* requires a {@link GuildPermissionsContext}, fitting a gateway handler only. `app_permissions` is
|
|
985
963
|
* absent on gateway events, the channel scope refuses there as unresolved, use `in: 'guild'` on an
|
|
986
964
|
* event handler.
|
|
987
965
|
*
|
|
@@ -1042,7 +1020,7 @@ type ChoiceValueOf<Entry> = Entry extends {
|
|
|
1042
1020
|
} ? string : Entry extends {
|
|
1043
1021
|
kind: 'integer' | 'number';
|
|
1044
1022
|
} ? number : never;
|
|
1045
|
-
/**
|
|
1023
|
+
/** the focused option. `value` is the raw partial discord delivers mid-type, always a string regardless of kind. */
|
|
1046
1024
|
interface FocusedField<Route extends keyof SlashOptionRegistry> {
|
|
1047
1025
|
name: AutocompletableNames<Route>;
|
|
1048
1026
|
value: string;
|
|
@@ -1081,4 +1059,4 @@ type PageCursor<Prefix extends string> = CustomId<Prefix, {
|
|
|
1081
1059
|
declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
|
|
1082
1060
|
//#endregion
|
|
1083
1061
|
export { RowType as $, ModalLike as A, storeInteractionRoute as B, Gate as C, defineEffectGate as D, RequiredOf as E, areRoutes as F, DecodedParams as G, CustomId as H, contextMenuRouteOf as I, Promisable as J, CommandMeta as K, interactionRoutesOf as L, serializeReply as M, RoutableConstructor as N, defineGate as O, SelectMenuKind as P, BuilderType as Q, selectMenuRouteOf as R, EffectGate as S, GuildPermissionsContext as T, decodeFor as U, AnyCustomId as V, prefixOf as W, BuilderComponent as X, IsNever as Y, RowComponent as Z, pickNotice as _, AutocompleteOptions as a, InjectedCommandMap as at, JoinNames as b, FocusedField as c, SlashOption as ct, RequirePermissionsOptions as d, MessageContextMenuRegistry as dt, CommandInfo as et, RequireRole as f, UserContextMenuRegistry as ft, GateNoticeOptions as g, PermissionScope as h, AutocompletableNames as i, ContextMenus as it, SerializedReply as j, BaseReplySender as k, RequireBotPermissions as l, SlashOptionRegistry as lt, PermissionNames as m, PageCursor as n, Commands as nt, ChoiceValueOf as o, InjectedContextMenuMap as ot, RequireRoleOptions as p, RegisterCommand as q, pageCursor as r, ContextMenuInfo as rt, EntryFor as s, OptionKind as st, PAGE_MAX as t, CommandInjector as tt, RequirePermissions as u, ContextMenuKind as ut, GateFitsWith as v, GateContextBase as w, TwoOrMore as x, IntersectRequired as y, storeComponentRoute as z };
|
|
1084
|
-
//# sourceMappingURL=cursor-
|
|
1062
|
+
//# sourceMappingURL=cursor-C77xH5QT.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as InteractionRouteKeys, f as InteractionRoutes, g as contextMenuLeaves, i as BuilderComponent, u as InteractionMetadataKey } from "./publishDefault-
|
|
1
|
+
import { d as InteractionRouteKeys, f as InteractionRoutes, g as contextMenuLeaves, i as BuilderComponent, u as InteractionMetadataKey } from "./publishDefault-BCrMG9T8.mjs";
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { SlashCommandBuilder, TextDisplayBuilder } from "@discordjs/builders";
|
|
4
4
|
import { Logger, paint } from "@seedcord/logger";
|
|
@@ -9,25 +9,12 @@ import { SeedcordError, SeedcordRangeError } from "@seedcord/errors/internal";
|
|
|
9
9
|
import { prettify, toEpochSeconds } from "@seedcord/utils";
|
|
10
10
|
|
|
11
11
|
//#region src/miscellaneous/guarded.ts
|
|
12
|
-
/**
|
|
13
|
-
* A backing record for a generated accessor. Null-prototype, on a plain object a key named `__proto__` sets
|
|
14
|
-
* the store's prototype and adds no entry.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
12
|
function accessorStore() {
|
|
19
13
|
return Object.create(null);
|
|
20
14
|
}
|
|
21
|
-
/** Empties a store in place, keeping the reference the accessor's Proxy wraps. @internal */
|
|
22
15
|
function clearStore(store) {
|
|
23
16
|
for (const key of Object.keys(store)) Reflect.deleteProperty(store, key);
|
|
24
17
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Wraps a generated accessor's backing record so a read of an absent key throws. Handler modules import before
|
|
27
|
-
* startup fills the record, and an unguarded read there returns `undefined` and renders as an empty string.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
18
|
function guardedAccessor(accessor, storage) {
|
|
32
19
|
return new Proxy(storage, { get(target, key, receiver) {
|
|
33
20
|
if (typeof key !== "string" || Object.hasOwn(target, key)) return Reflect.get(target, key, receiver);
|
|
@@ -78,11 +65,7 @@ function slashBuildersOf(all) {
|
|
|
78
65
|
const slash = all.filter((command) => command instanceof SlashCommandBuilder);
|
|
79
66
|
return [...new Set(slash)];
|
|
80
67
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Records each deployed command on {@link Commands} and {@link ContextMenus}.
|
|
83
|
-
*
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
68
|
+
/** @internal */
|
|
86
69
|
var CommandInjector = class {
|
|
87
70
|
logger = new Logger("Commands", { channel: "bot" });
|
|
88
71
|
inject(deploy, all) {
|
|
@@ -217,7 +200,7 @@ var Notice = class extends Error {
|
|
|
217
200
|
*/
|
|
218
201
|
report = false;
|
|
219
202
|
/**
|
|
220
|
-
* Whether the reply is ephemeral,
|
|
203
|
+
* Whether the reply is ephemeral, seen only by the invoking user. Set it false for a refusal the
|
|
221
204
|
* whole channel should see.
|
|
222
205
|
*
|
|
223
206
|
* @defaultValue `true`
|
|
@@ -225,7 +208,7 @@ var Notice = class extends Error {
|
|
|
225
208
|
ephemeral = true;
|
|
226
209
|
/**
|
|
227
210
|
* A short one-line reason. When every arm of an `or` gate refuses and each refusal sets this, `or`
|
|
228
|
-
* lists them
|
|
211
|
+
* lists them as the reply.
|
|
229
212
|
*/
|
|
230
213
|
summary;
|
|
231
214
|
constructor(message, options) {
|
|
@@ -237,10 +220,6 @@ var Notice = class extends Error {
|
|
|
237
220
|
|
|
238
221
|
//#endregion
|
|
239
222
|
//#region src/stops/NoticeCard.ts
|
|
240
|
-
/**
|
|
241
|
-
* Built fresh inside a {@link Notice}'s `render` to back its ComponentsV2 reply. The title renders as
|
|
242
|
-
* an h3 line with the description on the next line.
|
|
243
|
-
*/
|
|
244
223
|
var NoticeCard = class extends BuilderComponent {
|
|
245
224
|
constructor(description, title = "Cannot Proceed") {
|
|
246
225
|
super("container");
|
|
@@ -253,7 +232,7 @@ var NoticeCard = class extends BuilderComponent {
|
|
|
253
232
|
/**
|
|
254
233
|
* Thrown when a customId was minted by an older version of its shape.
|
|
255
234
|
*
|
|
256
|
-
* This is normal after the shape changes.
|
|
235
|
+
* This is normal after the shape changes.
|
|
257
236
|
*/
|
|
258
237
|
var StaleCustomId = class extends Notice {
|
|
259
238
|
constructor(prefix) {
|
|
@@ -266,7 +245,7 @@ var StaleCustomId = class extends Notice {
|
|
|
266
245
|
/**
|
|
267
246
|
* Thrown when a customId wire is corrupt or tampered with and cannot be trusted.
|
|
268
247
|
*
|
|
269
|
-
*
|
|
248
|
+
* It reports because this is an odd case that should not happen.
|
|
270
249
|
*/
|
|
271
250
|
var InvalidCustomId = class extends Notice {
|
|
272
251
|
constructor(detail) {
|
|
@@ -503,7 +482,8 @@ function prefixOf(wire) {
|
|
|
503
482
|
}
|
|
504
483
|
/**
|
|
505
484
|
* A typed customId. The single source of truth shared by the component that mints it and the handler
|
|
506
|
-
* that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
|
|
485
|
+
* that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
|
|
486
|
+
* into a compact wire string, which fits more of them inside Discord's 100-char limit.
|
|
507
487
|
*
|
|
508
488
|
* @typeParam Prefix - The stable route prefix, e.g. 'approve'.
|
|
509
489
|
* @typeParam Shape - The accumulated fields, filled in by the chain.
|
|
@@ -517,7 +497,7 @@ function prefixOf(wire) {
|
|
|
517
497
|
* // Set the custom id on a button when creating it.
|
|
518
498
|
* new ButtonBuilder().setCustomId(ApproveId.encode({ userId: '123', action: 'approve' }));
|
|
519
499
|
*
|
|
520
|
-
* //
|
|
500
|
+
* // in the handler, userId comes back a string
|
|
521
501
|
* const { userId, action } = this.params; // userId: string, action: 'approve' | 'deny'
|
|
522
502
|
* await this.event.guild?.members.fetch(userId);
|
|
523
503
|
* ```
|
|
@@ -525,7 +505,7 @@ function prefixOf(wire) {
|
|
|
525
505
|
var CustomId = class CustomId {
|
|
526
506
|
/** The stable route prefix, e.g. 'approve'. */
|
|
527
507
|
prefix;
|
|
528
|
-
/**
|
|
508
|
+
/** The field definitions accumulated by the chain, keyed by name. */
|
|
529
509
|
shape;
|
|
530
510
|
/** The prefix plus a short hash of the shape, the part of the wire before the colon. */
|
|
531
511
|
routeKey;
|
|
@@ -606,7 +586,8 @@ var CustomId = class CustomId {
|
|
|
606
586
|
});
|
|
607
587
|
}
|
|
608
588
|
/**
|
|
609
|
-
* Add a free short text field. Avoid it where possible
|
|
589
|
+
* Add a free short text field. Avoid it where possible. It cannot be packed, which makes it the most
|
|
590
|
+
* expensive field on the wire.
|
|
610
591
|
*
|
|
611
592
|
* @example
|
|
612
593
|
* ```ts
|
|
@@ -649,11 +630,7 @@ var CustomId = class CustomId {
|
|
|
649
630
|
return prefixOf(wire) === this.prefix;
|
|
650
631
|
}
|
|
651
632
|
};
|
|
652
|
-
/**
|
|
653
|
-
* Find the customId whose prefix owns this wire, decode against it, and report which one matched.
|
|
654
|
-
*
|
|
655
|
-
* @internal
|
|
656
|
-
*/
|
|
633
|
+
/** @internal */
|
|
657
634
|
function decodeFor(defs, wire) {
|
|
658
635
|
const match = defs.find((def) => def.owns(wire));
|
|
659
636
|
if (!match) throw new InvalidCustomId(`no customId owns ${JSON.stringify(routeKeyOf(wire))}`);
|
|
@@ -666,14 +643,14 @@ function decodeFor(defs, wire) {
|
|
|
666
643
|
//#endregion
|
|
667
644
|
//#region src/customId/routing.ts
|
|
668
645
|
/**
|
|
669
|
-
*
|
|
646
|
+
* route decorators store a handler's customId defs here, so the component base can decode
|
|
670
647
|
* against them at runtime.
|
|
671
648
|
*
|
|
672
649
|
* @internal
|
|
673
650
|
*/
|
|
674
651
|
const ComponentDefsKey = Symbol("seedcord:customId:componentDefs");
|
|
675
652
|
/**
|
|
676
|
-
*
|
|
653
|
+
* throws `CustomIdHandlerRouteMissing` when the class has no stored defs. a drifted or corrupt wire
|
|
677
654
|
* throws `StaleCustomId` or `InvalidCustomId`.
|
|
678
655
|
*
|
|
679
656
|
* @internal
|
|
@@ -699,7 +676,7 @@ function areRoutes(routes) {
|
|
|
699
676
|
return Array.isArray(routes) && routes.every((route) => typeof route === "string");
|
|
700
677
|
}
|
|
701
678
|
/**
|
|
702
|
-
*
|
|
679
|
+
* every stored route kind and its route strings on a decorated constructor. the build's manifest
|
|
703
680
|
* emitter reads the same pairs.
|
|
704
681
|
*/
|
|
705
682
|
function interactionRoutesOf(constructor) {
|
|
@@ -744,7 +721,7 @@ function contextMenuRouteOf(kind) {
|
|
|
744
721
|
* the check reads. No annotation defaults to {@link GateContextBase}, an agnostic gate that fits every
|
|
745
722
|
* handler.
|
|
746
723
|
*
|
|
747
|
-
* @typeParam Name - The gate's name captured as a literal
|
|
724
|
+
* @typeParam Name - The gate's name, captured as a literal for mismatch errors.
|
|
748
725
|
* @typeParam Ctx - The context the check reads, inferred from the `ctx` annotation.
|
|
749
726
|
*
|
|
750
727
|
* @param name - The gate's name, used in mismatch errors.
|
|
@@ -783,7 +760,7 @@ function defineGate(name, fn) {
|
|
|
783
760
|
* commits. In an `or`, a refusing arm's queued commit is rolled back. This is how {@link Cooldown} peeks
|
|
784
761
|
* in `check` and charges the slot in `commit`.
|
|
785
762
|
*
|
|
786
|
-
* @typeParam Name - The gate's name
|
|
763
|
+
* @typeParam Name - The gate's literal name, used to name a mismatch error.
|
|
787
764
|
* @typeParam Ctx - The context both `check` and `commit` read, inferred from the `ctx` annotation.
|
|
788
765
|
*
|
|
789
766
|
* @param name - The gate's name, used in mismatch errors.
|
|
@@ -801,7 +778,7 @@ function defineGate(name, fn) {
|
|
|
801
778
|
* return defineEffectGate(
|
|
802
779
|
* 'UsesPerDay',
|
|
803
780
|
* (ctx) => {
|
|
804
|
-
* // peek and refuse by throwing
|
|
781
|
+
* // peek and refuse by throwing. do not mutate yet
|
|
805
782
|
* if (usedToday(ctx.userId) >= max) throw new OutOfUsesNotice(max);
|
|
806
783
|
* },
|
|
807
784
|
* (ctx) => {
|
|
@@ -946,7 +923,6 @@ function pickNotice(options, makeDefault) {
|
|
|
946
923
|
|
|
947
924
|
//#endregion
|
|
948
925
|
//#region src/permissions/bits.ts
|
|
949
|
-
/** Permission bit to its prettified human-readable name. */
|
|
950
926
|
const PermissionNames = new Map(Object.entries(PermissionFlagsBits).map(([key, bit]) => [bit, prettify(key)]));
|
|
951
927
|
const ADMINISTRATOR = PermissionFlagsBits.Administrator;
|
|
952
928
|
function nameOf(bit) {
|
|
@@ -1073,4 +1049,4 @@ function pageCursor(prefix) {
|
|
|
1073
1049
|
|
|
1074
1050
|
//#endregion
|
|
1075
1051
|
export { areRoutes as A, prefixOf as B, NotInDm as C, defineEffectGate as D, OnCooldown as E, storeInteractionRoute as F, ContextMenus as G, Notice as H, ComponentDefsKey as I, guardedAccessor as J, accessorStore as K, decodeComponentRoute as L, interactionRoutesOf as M, selectMenuRouteOf as N, defineGate as O, storeComponentRoute as P, CustomId as R, NotAllowed as S, NotOwner as T, CommandInjector as U, NoticeCard as V, Commands as W, GateNotice as _, RequirePermissions as a, MissingRole as b, hasAll as c, pickNotice as d, discardCommits as f, runCommits as g, runCheck as h, RequireBotPermissions as i, contextMenuRouteOf as j, SelectMenuKind as k, missingNames as l, rollbackCommits as m, pageCursor as n, RequireRole as o, markCommits as p, clearStore as q, Silence as r, PermissionNames as s, PAGE_MAX as t, presentNames as u, HasDangerousPermissions as v, NotInGuild as w, NeedsAny as x, MissingPermissions as y, decodeFor as z };
|
|
1076
|
-
//# sourceMappingURL=cursor-
|
|
1052
|
+
//# sourceMappingURL=cursor-D207VrRo.mjs.map
|