@seedcord/http 0.5.1 → 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/{RouteManifest-DTxI4fS0.d.mts → RouteManifest-D7qXj8Ts.d.mts} +3 -3
- package/dist/{edge.index-B4x6VSJl.mjs → edge.index-CWUU_d_X.mjs} +172 -85
- package/dist/edge.index-CWUU_d_X.mjs.map +1 -0
- package/dist/{edge.index-LQtTs595.d.mts → edge.index-LAWTa6NI.d.mts} +153 -53
- package/dist/edge.index.d.mts +3 -3
- package/dist/edge.index.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +30 -84
- package/dist/index.mjs.map +1 -1
- package/dist/manifest.index.d.mts +1 -1
- package/package.json +16 -15
- package/dist/edge.index-B4x6VSJl.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InteractionKind, SubscriptionKey } from "@seedcord/core";
|
|
2
2
|
import { ApplicationCommandType } from "discord-api-types/v10";
|
|
3
3
|
import { EventFrequency } from "@seedcord/types";
|
|
4
4
|
//#region src/manifest/RouteManifest.d.ts
|
|
@@ -27,7 +27,7 @@ interface CommandRoute extends RouteModule {
|
|
|
27
27
|
* the receiver routes by (the routeKey minus its layout hash).
|
|
28
28
|
*/
|
|
29
29
|
interface ComponentRoute extends RouteModule {
|
|
30
|
-
readonly kind:
|
|
30
|
+
readonly kind: InteractionKind.Button | InteractionKind.Modal | InteractionKind.StringMenu | InteractionKind.UserMenu | InteractionKind.RoleMenu | InteractionKind.ChannelMenu | InteractionKind.MentionableMenu;
|
|
31
31
|
readonly prefix: string;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -61,4 +61,4 @@ interface RouteManifest {
|
|
|
61
61
|
}
|
|
62
62
|
//#endregion
|
|
63
63
|
export { RouteManifest as t };
|
|
64
|
-
//# sourceMappingURL=RouteManifest-
|
|
64
|
+
//# sourceMappingURL=RouteManifest-D7qXj8Ts.d.mts.map
|
|
@@ -4,13 +4,14 @@ import { SeedcordError, SeedcordTypeError, applicationIdFromToken, validateDisco
|
|
|
4
4
|
import { Logger } from "@seedcord/logger";
|
|
5
5
|
import { Converters, Envapter } from "envapt";
|
|
6
6
|
import { DiscordAPIError, REST } from "@discordjs/rest";
|
|
7
|
-
import { ArraySourceBase, BaseHandler, BaseReplySender, Bus, CursorSourceBase, DispatchContext, Fault, Notice, PaginatorBase, RepliableHandler, ResolvedEmoji, Silence, Subscriber, WebhookLog } from "@seedcord/core";
|
|
7
|
+
import { ArraySourceBase, BaseHandler, BaseReplySender, Bus, CursorSourceBase, DispatchContext, Fault, InteractionKind, Notice, PaginatorBase, RepliableHandler, ResolvedEmoji, Silence, Subscriber, WebhookLog } from "@seedcord/core";
|
|
8
8
|
import { SeedcordErrorCode, paint } from "@seedcord/errors";
|
|
9
9
|
import { MemoryRateLimiter } from "@seedcord/rate-limiter";
|
|
10
10
|
import { ApplicationCommandOptionType, ApplicationCommandType, ChannelType, ComponentType, InteractionResponseType, InteractionType, MessageFlags, RESTJSONErrorCodes, Routes } from "discord-api-types/v10";
|
|
11
11
|
import { API } from "@discordjs/core/http-only";
|
|
12
12
|
import { buildSlashRoute } from "@seedcord/utils/internal";
|
|
13
13
|
import { prefixOf } from "@seedcord/custom-id";
|
|
14
|
+
import { Collection } from "@discordjs/collection";
|
|
14
15
|
|
|
15
16
|
//#region src/reply/ReplySender.ts
|
|
16
17
|
function wireAllowedMentions(mentions) {
|
|
@@ -139,8 +140,8 @@ function apiFor(rest) {
|
|
|
139
140
|
* Shared base the repliable HTTP interaction handlers extend.
|
|
140
141
|
*
|
|
141
142
|
* Not a public entry point. Extend {@link SlashHandler}, {@link ButtonHandler}, {@link ModalHandler},
|
|
142
|
-
* {@link
|
|
143
|
-
* to the http sender.
|
|
143
|
+
* {@link ContextMenuHandler}, or one of the select menu bases instead. This class binds the core
|
|
144
|
+
* reply base to the http sender.
|
|
144
145
|
*
|
|
145
146
|
* @typeParam Event - The repliable interaction type this handler processes
|
|
146
147
|
*/
|
|
@@ -348,8 +349,8 @@ async function handleRawFault(error, uuid, scope) {
|
|
|
348
349
|
await sendGuarded(scope.routeId, () => respondEmptyChoices(scope));
|
|
349
350
|
return;
|
|
350
351
|
}
|
|
351
|
-
const
|
|
352
|
-
const response = (
|
|
352
|
+
const Override = core.config.errors?.defaultError;
|
|
353
|
+
const response = (Override ? new Override(uuid) : new Fault()).render(renderContext(core, uuid));
|
|
353
354
|
await sendGuarded(scope.routeId, () => sender.send(response, { ephemeral: true }));
|
|
354
355
|
}
|
|
355
356
|
async function handleFault(caught, scope) {
|
|
@@ -429,14 +430,14 @@ async function loadHandlerCtor(match, payload, core, report) {
|
|
|
429
430
|
async function dispatchInteraction(args) {
|
|
430
431
|
const { match, payload, core } = args;
|
|
431
432
|
const report = dispatchReporter(match, payload, core);
|
|
432
|
-
const
|
|
433
|
-
if (!
|
|
433
|
+
const Handler = await loadHandlerCtor(match, payload, core, report);
|
|
434
|
+
if (!Handler) return null;
|
|
434
435
|
const routeId = unhandledRouteId(match);
|
|
435
|
-
logger().debug(`Processing ${paint.sky.bold(routeId)} with ${paint.mute(
|
|
436
|
+
logger().debug(`Processing ${paint.sky.bold(routeId)} with ${paint.mute(Handler.name)}`);
|
|
436
437
|
const dispatch = new DispatchContext(routeId);
|
|
437
438
|
let handler;
|
|
438
439
|
try {
|
|
439
|
-
handler = new
|
|
440
|
+
handler = new Handler(payload, core, dispatch);
|
|
440
441
|
} catch (caught) {
|
|
441
442
|
await answer(caught, freshScope(match, payload, core), report);
|
|
442
443
|
return null;
|
|
@@ -447,7 +448,7 @@ async function dispatchInteraction(args) {
|
|
|
447
448
|
routeId,
|
|
448
449
|
sender: handler instanceof RepliableHandler$1 ? handler.sender : null
|
|
449
450
|
};
|
|
450
|
-
const refusal = await gateRefusal(
|
|
451
|
+
const refusal = await gateRefusal(Handler, match, payload, core);
|
|
451
452
|
if (refusal) {
|
|
452
453
|
await answer(refusal.caught, scope, report);
|
|
453
454
|
return null;
|
|
@@ -673,8 +674,8 @@ var UnhandledAutocomplete = class extends AutocompleteHandler {
|
|
|
673
674
|
* Shared base the repliable interaction handlers extend.
|
|
674
675
|
*
|
|
675
676
|
* Not a public entry point. Extend {@link SlashHandler}, {@link ContextMenuHandler}, {@link ButtonHandler},
|
|
676
|
-
* {@link
|
|
677
|
-
* reply members.
|
|
677
|
+
* {@link ModalHandler}, or one of the select menu bases instead. This class adds `showModal` on top
|
|
678
|
+
* of the reply members.
|
|
678
679
|
*
|
|
679
680
|
* @typeParam Event - The repliable interaction type this handler processes
|
|
680
681
|
*/
|
|
@@ -701,31 +702,22 @@ var UnhandledRepliable = class extends InteractionHandler {
|
|
|
701
702
|
|
|
702
703
|
//#endregion
|
|
703
704
|
//#region src/dispatch/resolve.ts
|
|
704
|
-
const COMPONENT_KIND = {
|
|
705
|
-
button: "button",
|
|
706
|
-
stringSelect: "stringMenu",
|
|
707
|
-
userSelect: "userMenu",
|
|
708
|
-
roleSelect: "roleMenu",
|
|
709
|
-
channelSelect: "channelMenu",
|
|
710
|
-
mentionableSelect: "mentionableMenu",
|
|
711
|
-
modal: "modal"
|
|
712
|
-
};
|
|
713
705
|
function commandKind(type) {
|
|
714
706
|
switch (type) {
|
|
715
|
-
case ApplicationCommandType.ChatInput: return
|
|
716
|
-
case ApplicationCommandType.User: return
|
|
717
|
-
case ApplicationCommandType.Message: return
|
|
707
|
+
case ApplicationCommandType.ChatInput: return InteractionKind.Slash;
|
|
708
|
+
case ApplicationCommandType.User: return InteractionKind.UserContextMenu;
|
|
709
|
+
case ApplicationCommandType.Message: return InteractionKind.MessageContextMenu;
|
|
718
710
|
default: return null;
|
|
719
711
|
}
|
|
720
712
|
}
|
|
721
713
|
function componentMapKey(type) {
|
|
722
714
|
switch (type) {
|
|
723
|
-
case ComponentType.Button: return
|
|
724
|
-
case ComponentType.StringSelect: return
|
|
725
|
-
case ComponentType.UserSelect: return
|
|
726
|
-
case ComponentType.RoleSelect: return
|
|
727
|
-
case ComponentType.ChannelSelect: return
|
|
728
|
-
case ComponentType.MentionableSelect: return
|
|
715
|
+
case ComponentType.Button: return InteractionKind.Button;
|
|
716
|
+
case ComponentType.StringSelect: return InteractionKind.StringMenu;
|
|
717
|
+
case ComponentType.UserSelect: return InteractionKind.UserMenu;
|
|
718
|
+
case ComponentType.RoleSelect: return InteractionKind.RoleMenu;
|
|
719
|
+
case ComponentType.ChannelSelect: return InteractionKind.ChannelMenu;
|
|
720
|
+
case ComponentType.MentionableSelect: return InteractionKind.MentionableMenu;
|
|
729
721
|
default: return null;
|
|
730
722
|
}
|
|
731
723
|
}
|
|
@@ -755,22 +747,20 @@ function describeRow(row) {
|
|
|
755
747
|
*/
|
|
756
748
|
function buildRouteMaps(manifest) {
|
|
757
749
|
const maps = {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
modal: /* @__PURE__ */ new Map()
|
|
770
|
-
}
|
|
750
|
+
[InteractionKind.Slash]: /* @__PURE__ */ new Map(),
|
|
751
|
+
[InteractionKind.UserContextMenu]: /* @__PURE__ */ new Map(),
|
|
752
|
+
[InteractionKind.MessageContextMenu]: /* @__PURE__ */ new Map(),
|
|
753
|
+
[InteractionKind.Autocomplete]: /* @__PURE__ */ new Map(),
|
|
754
|
+
[InteractionKind.Button]: /* @__PURE__ */ new Map(),
|
|
755
|
+
[InteractionKind.StringMenu]: /* @__PURE__ */ new Map(),
|
|
756
|
+
[InteractionKind.UserMenu]: /* @__PURE__ */ new Map(),
|
|
757
|
+
[InteractionKind.RoleMenu]: /* @__PURE__ */ new Map(),
|
|
758
|
+
[InteractionKind.ChannelMenu]: /* @__PURE__ */ new Map(),
|
|
759
|
+
[InteractionKind.MentionableMenu]: /* @__PURE__ */ new Map(),
|
|
760
|
+
[InteractionKind.Modal]: /* @__PURE__ */ new Map()
|
|
771
761
|
};
|
|
772
762
|
const owners = /* @__PURE__ */ new Map();
|
|
773
|
-
function set(
|
|
763
|
+
function set(kind, key, row) {
|
|
774
764
|
const routeId = `${kind}:${key}`;
|
|
775
765
|
const owner = owners.get(routeId);
|
|
776
766
|
if (owner) throw new SeedcordError(SeedcordErrorCode.InteractionDuplicateRoute, [
|
|
@@ -779,7 +769,7 @@ function buildRouteMaps(manifest) {
|
|
|
779
769
|
describeRow(row)
|
|
780
770
|
]);
|
|
781
771
|
owners.set(routeId, row);
|
|
782
|
-
|
|
772
|
+
maps[kind].set(key, {
|
|
783
773
|
kind,
|
|
784
774
|
routeId,
|
|
785
775
|
load: namedExport(routeId, row)
|
|
@@ -787,10 +777,10 @@ function buildRouteMaps(manifest) {
|
|
|
787
777
|
}
|
|
788
778
|
for (const row of manifest.commandRoutes) {
|
|
789
779
|
const kind = commandKind(row.type);
|
|
790
|
-
if (kind) set(
|
|
780
|
+
if (kind) set(kind, row.name, row);
|
|
791
781
|
}
|
|
792
|
-
for (const row of manifest.autocompleteRoutes) set(
|
|
793
|
-
for (const row of manifest.componentRoutes) set(
|
|
782
|
+
for (const row of manifest.autocompleteRoutes) set(InteractionKind.Autocomplete, row.name, row);
|
|
783
|
+
for (const row of manifest.componentRoutes) set(row.kind, row.prefix, row);
|
|
794
784
|
return maps;
|
|
795
785
|
}
|
|
796
786
|
function unhandled(kind, attemptedKey) {
|
|
@@ -798,7 +788,7 @@ function unhandled(kind, attemptedKey) {
|
|
|
798
788
|
kind,
|
|
799
789
|
routeId: null,
|
|
800
790
|
attemptedKey,
|
|
801
|
-
load: () => Promise.resolve(kind ===
|
|
791
|
+
load: () => Promise.resolve(kind === InteractionKind.Autocomplete ? UnhandledAutocomplete : UnhandledRepliable)
|
|
802
792
|
};
|
|
803
793
|
}
|
|
804
794
|
/**
|
|
@@ -813,24 +803,24 @@ function resolve(maps, interaction) {
|
|
|
813
803
|
case InteractionType.ApplicationCommand: {
|
|
814
804
|
if (interaction.data.type === ApplicationCommandType.ChatInput) {
|
|
815
805
|
const route = slashRouteOf(interaction.data);
|
|
816
|
-
return maps.
|
|
806
|
+
return maps[InteractionKind.Slash].get(route) ?? unhandled(InteractionKind.Slash, route);
|
|
817
807
|
}
|
|
818
808
|
const kind = commandKind(interaction.data.type);
|
|
819
809
|
return kind ? maps[kind].get(interaction.data.name) ?? unhandled(kind, interaction.data.name) : null;
|
|
820
810
|
}
|
|
821
811
|
case InteractionType.ApplicationCommandAutocomplete: {
|
|
822
812
|
const route = slashRouteOf(interaction.data);
|
|
823
|
-
return maps.
|
|
813
|
+
return maps[InteractionKind.Autocomplete].get(route) ?? unhandled(InteractionKind.Autocomplete, route);
|
|
824
814
|
}
|
|
825
815
|
case InteractionType.MessageComponent: {
|
|
826
816
|
const key = componentMapKey(interaction.data.component_type);
|
|
827
817
|
if (!key) return null;
|
|
828
818
|
const prefix = prefixOf(interaction.data.custom_id);
|
|
829
|
-
return maps
|
|
819
|
+
return maps[key].get(prefix) ?? unhandled(key, prefix);
|
|
830
820
|
}
|
|
831
821
|
case InteractionType.ModalSubmit: {
|
|
832
822
|
const prefix = prefixOf(interaction.data.custom_id);
|
|
833
|
-
return maps.
|
|
823
|
+
return maps[InteractionKind.Modal].get(prefix) ?? unhandled(InteractionKind.Modal, prefix);
|
|
834
824
|
}
|
|
835
825
|
default: return null;
|
|
836
826
|
}
|
|
@@ -1006,7 +996,7 @@ function createSeedcord(config, manifest) {
|
|
|
1006
996
|
//#endregion
|
|
1007
997
|
//#region src/inputs/pick.ts
|
|
1008
998
|
function pick(ids, bucket) {
|
|
1009
|
-
const found =
|
|
999
|
+
const found = new Collection();
|
|
1010
1000
|
if (!ids || !bucket) return found;
|
|
1011
1001
|
for (const id of ids) if (Object.hasOwn(bucket, id)) found.set(id, bucket[id]);
|
|
1012
1002
|
return found;
|
|
@@ -1072,7 +1062,7 @@ function isKind(entry, kinds) {
|
|
|
1072
1062
|
* kind that getter does not read. The message names the getter that does.
|
|
1073
1063
|
*
|
|
1074
1064
|
* A select getter resolves the ids its field picked against the interaction's `resolved` data and returns a
|
|
1075
|
-
* `
|
|
1065
|
+
* `Collection` keyed by id. A field that picked nothing returns null. Pass `required` to throw there instead.
|
|
1076
1066
|
*/
|
|
1077
1067
|
var ModalFields = class {
|
|
1078
1068
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -1402,9 +1392,9 @@ var MessageContextMenuHandler = class extends InteractionHandler {
|
|
|
1402
1392
|
/**
|
|
1403
1393
|
* Shared base the customId-routed component handlers extend on the HTTP transport.
|
|
1404
1394
|
*
|
|
1405
|
-
* Not a public entry point. Extend {@link ButtonHandler}, {@link
|
|
1406
|
-
* instead. This class defines the customId decode, the route matching, and the source-message
|
|
1407
|
-
* `update` and `deferUpdate`.
|
|
1395
|
+
* Not a public entry point. Extend {@link ButtonHandler}, {@link ModalHandler}, or one of the select menu
|
|
1396
|
+
* bases instead. This class defines the customId decode, the route matching, and the source-message
|
|
1397
|
+
* verbs `update` and `deferUpdate`.
|
|
1408
1398
|
*
|
|
1409
1399
|
* @typeParam Event - The component or modal interaction type this handler processes
|
|
1410
1400
|
* @typeParam Defs - The customId route definitions registered on the concrete handler
|
|
@@ -1530,23 +1520,58 @@ var ModalHandler = class extends ComponentHandler {
|
|
|
1530
1520
|
|
|
1531
1521
|
//#endregion
|
|
1532
1522
|
//#region src/handlers/interaction/components/SelectMenuHandler.ts
|
|
1523
|
+
function resolvedOf(data) {
|
|
1524
|
+
return data.resolved ?? {};
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Shared base the select menu handlers extend on the HTTP transport.
|
|
1528
|
+
*
|
|
1529
|
+
* Not a public entry point. Extend {@link StringMenuHandler}, {@link UserMenuHandler},
|
|
1530
|
+
* {@link RoleMenuHandler}, {@link ChannelMenuHandler}, or {@link MentionableMenuHandler} instead. This
|
|
1531
|
+
* class defines the `values` getter those bases share.
|
|
1532
|
+
*
|
|
1533
|
+
* @typeParam Event - The select menu interaction type this handler processes
|
|
1534
|
+
* @typeParam Defs - The customId route definitions registered on the concrete handler
|
|
1535
|
+
*/
|
|
1536
|
+
var SelectMenuHandler = class extends ComponentHandler {
|
|
1537
|
+
/** The values this select picked. On every kind but the string menu they are snowflake ids. */
|
|
1538
|
+
get values() {
|
|
1539
|
+
return this.event.data.values ?? [];
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1533
1542
|
/**
|
|
1534
|
-
* Base class for a select menu handler on the HTTP transport.
|
|
1543
|
+
* Base class for a string select menu handler on the HTTP transport.
|
|
1544
|
+
*
|
|
1545
|
+
* Register the customId definitions with `@StringMenuRoute`, list the same ones in the generic, then read
|
|
1546
|
+
* the chosen option values from `this.values`. Read `this.params` for a single route or `this.match` for
|
|
1547
|
+
* several. Reply through the handler members, or rewrite the source message with `this.update`.
|
|
1548
|
+
*
|
|
1549
|
+
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof TopicsId]`.
|
|
1535
1550
|
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1551
|
+
* @example
|
|
1552
|
+
* ```ts
|
|
1553
|
+
* \@StringMenuRoute(TopicsId)
|
|
1554
|
+
* class Topics extends StringMenuHandler<[typeof TopicsId]> {
|
|
1555
|
+
* async execute() {
|
|
1556
|
+
* const { userId } = this.params;
|
|
1557
|
+
* await this.update(`<@${userId}> now follows ${this.values.join(', ')}`);
|
|
1558
|
+
* }
|
|
1559
|
+
* }
|
|
1560
|
+
* ```
|
|
1561
|
+
*/
|
|
1562
|
+
var StringMenuHandler = class extends SelectMenuHandler {};
|
|
1563
|
+
/**
|
|
1564
|
+
* Base class for a user select menu handler on the HTTP transport.
|
|
1539
1565
|
*
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1566
|
+
* Beside `this.values` this handler declares `this.users` and `this.members`. Register the customId
|
|
1567
|
+
* definitions with `@UserMenuRoute` and list the same ones in the generic.
|
|
1542
1568
|
*
|
|
1543
|
-
* @typeParam Kind - The select kind from {@link SelectMenuKind}, e.g. `SelectMenuKind.User`.
|
|
1544
1569
|
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof AssignId]`.
|
|
1545
1570
|
*
|
|
1546
1571
|
* @example
|
|
1547
1572
|
* ```ts
|
|
1548
|
-
* \@
|
|
1549
|
-
* class
|
|
1573
|
+
* \@UserMenuRoute(AssignId)
|
|
1574
|
+
* class Assign extends UserMenuHandler<[typeof AssignId]> {
|
|
1550
1575
|
* async execute() {
|
|
1551
1576
|
* const { roleId } = this.params;
|
|
1552
1577
|
* await this.reply(`assigning ${this.users.size} member(s) to <@&${roleId}>`);
|
|
@@ -1554,32 +1579,94 @@ var ModalHandler = class extends ComponentHandler {
|
|
|
1554
1579
|
* }
|
|
1555
1580
|
* ```
|
|
1556
1581
|
*/
|
|
1557
|
-
var
|
|
1558
|
-
get selection() {
|
|
1559
|
-
return this.event.data;
|
|
1560
|
-
}
|
|
1561
|
-
resolvedMap(bucket) {
|
|
1562
|
-
return pick(this.selection.values, bucket);
|
|
1563
|
-
}
|
|
1564
|
-
/** The ids this select picked. */
|
|
1565
|
-
get values() {
|
|
1566
|
-
return this.selection.values ?? [];
|
|
1567
|
-
}
|
|
1582
|
+
var UserMenuHandler = class extends SelectMenuHandler {
|
|
1568
1583
|
/** The users this select picked. */
|
|
1569
1584
|
get users() {
|
|
1570
|
-
return this.
|
|
1585
|
+
return pick(this.values, resolvedOf(this.event.data).users);
|
|
1571
1586
|
}
|
|
1572
1587
|
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
1573
1588
|
get members() {
|
|
1574
|
-
return this.
|
|
1589
|
+
return pick(this.values, resolvedOf(this.event.data).members);
|
|
1575
1590
|
}
|
|
1591
|
+
};
|
|
1592
|
+
/**
|
|
1593
|
+
* Base class for a role select menu handler on the HTTP transport.
|
|
1594
|
+
*
|
|
1595
|
+
* Beside `this.values` this handler declares `this.roles`. Register the customId definitions with
|
|
1596
|
+
* `@RoleMenuRoute` and list the same ones in the generic.
|
|
1597
|
+
*
|
|
1598
|
+
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof GrantId]`.
|
|
1599
|
+
*
|
|
1600
|
+
* @example
|
|
1601
|
+
* ```ts
|
|
1602
|
+
* \@RoleMenuRoute(GrantId)
|
|
1603
|
+
* class Grant extends RoleMenuHandler<[typeof GrantId]> {
|
|
1604
|
+
* async execute() {
|
|
1605
|
+
* await this.update(`granting ${this.roles.size} role(s)`);
|
|
1606
|
+
* }
|
|
1607
|
+
* }
|
|
1608
|
+
* ```
|
|
1609
|
+
*/
|
|
1610
|
+
var RoleMenuHandler = class extends SelectMenuHandler {
|
|
1576
1611
|
/** The roles this select picked. */
|
|
1577
1612
|
get roles() {
|
|
1578
|
-
return this.
|
|
1613
|
+
return pick(this.values, resolvedOf(this.event.data).roles);
|
|
1579
1614
|
}
|
|
1615
|
+
};
|
|
1616
|
+
/**
|
|
1617
|
+
* Base class for a channel select menu handler on the HTTP transport.
|
|
1618
|
+
*
|
|
1619
|
+
* Beside `this.values` this handler declares `this.channels`. Register the customId definitions with
|
|
1620
|
+
* `@ChannelMenuRoute` and list the same ones in the generic.
|
|
1621
|
+
*
|
|
1622
|
+
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof LogTargetId]`.
|
|
1623
|
+
*
|
|
1624
|
+
* @example
|
|
1625
|
+
* ```ts
|
|
1626
|
+
* \@ChannelMenuRoute(LogTargetId)
|
|
1627
|
+
* class LogTarget extends ChannelMenuHandler<[typeof LogTargetId]> {
|
|
1628
|
+
* async execute() {
|
|
1629
|
+
* await this.update(`logging to ${this.channels.size} channel(s)`);
|
|
1630
|
+
* }
|
|
1631
|
+
* }
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
var ChannelMenuHandler = class extends SelectMenuHandler {
|
|
1580
1635
|
/** The channels this select picked. */
|
|
1581
1636
|
get channels() {
|
|
1582
|
-
return this.
|
|
1637
|
+
return pick(this.values, resolvedOf(this.event.data).channels);
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
/**
|
|
1641
|
+
* Base class for a mentionable select menu handler on the HTTP transport.
|
|
1642
|
+
*
|
|
1643
|
+
* A mentionable menu accepts users and roles together. `this.users`, `this.members`, and `this.roles`
|
|
1644
|
+
* can each come back empty.
|
|
1645
|
+
*
|
|
1646
|
+
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof InviteId]`.
|
|
1647
|
+
*
|
|
1648
|
+
* @example
|
|
1649
|
+
* ```ts
|
|
1650
|
+
* \@MentionableMenuRoute(InviteId)
|
|
1651
|
+
* class Invite extends MentionableMenuHandler<[typeof InviteId]> {
|
|
1652
|
+
* async execute() {
|
|
1653
|
+
* await this.update(`inviting ${this.users.size} user(s) and ${this.roles.size} role(s)`);
|
|
1654
|
+
* }
|
|
1655
|
+
* }
|
|
1656
|
+
* ```
|
|
1657
|
+
*/
|
|
1658
|
+
var MentionableMenuHandler = class extends SelectMenuHandler {
|
|
1659
|
+
/** The users this select picked. */
|
|
1660
|
+
get users() {
|
|
1661
|
+
return pick(this.values, resolvedOf(this.event.data).users);
|
|
1662
|
+
}
|
|
1663
|
+
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
1664
|
+
get members() {
|
|
1665
|
+
return pick(this.values, resolvedOf(this.event.data).members);
|
|
1666
|
+
}
|
|
1667
|
+
/** The roles this select picked. */
|
|
1668
|
+
get roles() {
|
|
1669
|
+
return pick(this.values, resolvedOf(this.event.data).roles);
|
|
1583
1670
|
}
|
|
1584
1671
|
};
|
|
1585
1672
|
|
|
@@ -1726,8 +1813,8 @@ function Gated(...gates) {
|
|
|
1726
1813
|
|
|
1727
1814
|
//#endregion
|
|
1728
1815
|
//#region src/version.ts
|
|
1729
|
-
const version = "0.
|
|
1816
|
+
const version = "0.7.0";
|
|
1730
1817
|
|
|
1731
1818
|
//#endregion
|
|
1732
|
-
export { RepliableHandler$1 as
|
|
1733
|
-
//# sourceMappingURL=edge.index-
|
|
1819
|
+
export { createSeedcord as C, AutocompleteHandler as D, InteractionHandler as E, RepliableHandler$1 as O, ModalFields as S, buildRouteMaps as T, MessageContextMenuHandler as _, Paginator as a, EmojiInjector as b, ChannelMenuHandler as c, SelectMenuHandler as d, StringMenuHandler as f, ComponentHandler as g, ButtonHandler as h, CursorSource as i, ReplySender as k, MentionableMenuHandler as l, ModalHandler as m, Gated as n, Subscriber$1 as o, UserMenuHandler as p, ArraySource as r, WebhookLog$1 as s, version as t, RoleMenuHandler as u, UserContextMenuHandler as v, buildEngine as w, Emojis as x, SlashHandler as y };
|
|
1820
|
+
//# sourceMappingURL=edge.index-CWUU_d_X.mjs.map
|