@seedcord/core 0.4.1 → 0.6.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 (37) hide show
  1. package/dist/{Bus-yJGE6Fs2.mjs → Bus-dGy6xq3F.mjs} +43 -40
  2. package/dist/Bus-dGy6xq3F.mjs.map +1 -0
  3. package/dist/{Pluggable-BI_LQuPm.mjs → Pluggable-B7_EftHj.mjs} +33 -10
  4. package/dist/Pluggable-B7_EftHj.mjs.map +1 -0
  5. package/dist/{Pluggable-bFCmT4oB.d.mts → Pluggable-C5uxmDb-.d.mts} +11 -4
  6. package/dist/{Plugin-B0SRHzMX.mjs → Plugin-BJfRk0s_.mjs} +3 -3
  7. package/dist/{Plugin-B0SRHzMX.mjs.map → Plugin-BJfRk0s_.mjs.map} +1 -1
  8. package/dist/{Plugin-BW2JH2_h.d.mts → Plugin-Bnz61fs_.d.mts} +9 -3
  9. package/dist/{cursor-CO_MTgdZ.d.mts → cursor-8Y2zpF-Y.d.mts} +4 -25
  10. package/dist/{cursor-CaT051ii.mjs → cursor-BkI9lxy2.mjs} +6 -29
  11. package/dist/cursor-BkI9lxy2.mjs.map +1 -0
  12. package/dist/{index-CvneCObW.d.mts → index-CD8l15aZ.d.mts} +2 -2
  13. package/dist/index.d.mts +101 -20
  14. package/dist/index.mjs +113 -16
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal.index.d.mts +13 -6
  17. package/dist/internal.index.mjs +11 -11
  18. package/dist/internal.index.mjs.map +1 -1
  19. package/dist/node-internal.index.d.mts +10 -5
  20. package/dist/node-internal.index.mjs +19 -10
  21. package/dist/node-internal.index.mjs.map +1 -1
  22. package/dist/node.index.d.mts +1 -1
  23. package/dist/node.index.mjs +31 -10
  24. package/dist/node.index.mjs.map +1 -1
  25. package/dist/{phases-C5Steaa2.d.mts → phases-D0a8BV9Z.d.mts} +10 -7
  26. package/dist/plugin.index.d.mts +1 -1
  27. package/dist/plugin.index.mjs +1 -1
  28. package/dist/{publishDefault-D826XXDQ.mjs → publishDefault-BuSZPbjT.mjs} +2 -2
  29. package/dist/{publishDefault-D826XXDQ.mjs.map → publishDefault-BuSZPbjT.mjs.map} +1 -1
  30. package/dist/{slashRouteLeaves-BQmbFm-S.mjs → slashRouteLeaves-C1msUE9Q.mjs} +2 -2
  31. package/dist/{slashRouteLeaves-BQmbFm-S.mjs.map → slashRouteLeaves-C1msUE9Q.mjs.map} +1 -1
  32. package/dist/{subscribers-DVa-Pr45.mjs → subscribers-A8lNU5yM.mjs} +2 -2
  33. package/dist/{subscribers-DVa-Pr45.mjs.map → subscribers-A8lNU5yM.mjs.map} +1 -1
  34. package/package.json +14 -14
  35. package/dist/Bus-yJGE6Fs2.mjs.map +0 -1
  36. package/dist/Pluggable-BI_LQuPm.mjs.map +0 -1
  37. package/dist/cursor-CaT051ii.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { A as translateSerializationError, C as NotInDm, D as defineEffectGate, E as OnCooldown, F as checkAckLegality, H as storeComponentRoute, I as sendTarget, K as NoticeCard, L as SelectMenuKind, M as publishResponse, O as defineGate, P as AckTrace, S as NotAllowed, T as NotOwner, U as storeInteractionRoute, V as selectMenuRouteOf, 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, z as contextMenuRouteOf } from "./cursor-CaT051ii.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, x as InteractionRoutes } from "./Bus-yJGE6Fs2.mjs";
3
- import { n as Commands, r as ContextMenus } from "./subscribers-DVa-Pr45.mjs";
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";
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";
@@ -193,24 +193,121 @@ function ModalRoute(...defs) {
193
193
  };
194
194
  }
195
195
  /**
196
- * Routes select menu interactions to handler classes.
196
+ * Routes string select menu interactions to a `StringMenuHandler`.
197
197
  *
198
- * Pass the select kind and the {@link CustomId} definition(s) this handler decodes. The handler's
199
- * generic must list the same kind and definitions, or it is a compile error.
198
+ * Pass the {@link CustomId} definition(s) this handler decodes and list the same ones in the handler's
199
+ * generic. The handler reads the chosen option values from `this.values`.
200
+ *
201
+ * @param defs - The customId definition(s) this handler decodes, one per route.
202
+ * @decorator
203
+ * @example
204
+ * ```ts
205
+ * \@StringMenuRoute(TopicsId)
206
+ * class Topics extends StringMenuHandler<[typeof TopicsId]> {
207
+ * async execute() {
208
+ * await this.update(`following ${this.values.join(', ')}`);
209
+ * }
210
+ * }
211
+ * ```
212
+ */
213
+ function StringMenuRoute(...defs) {
214
+ return function(constructor) {
215
+ storeComponentRoute("stringMenu", defs, constructor);
216
+ };
217
+ }
218
+ /**
219
+ * Routes user select menu interactions to a `UserMenuHandler`.
220
+ *
221
+ * Pass the {@link CustomId} definition(s) this handler decodes and list the same ones in the handler's
222
+ * generic. Beside `this.values` the handler declares `this.users` and `this.members`. Discord resolves
223
+ * the members only inside a guild.
224
+ *
225
+ * @param defs - The customId definition(s) this handler decodes, one per route.
226
+ * @decorator
227
+ * @example
228
+ * ```ts
229
+ * \@UserMenuRoute(AssignId)
230
+ * class Assign extends UserMenuHandler<[typeof AssignId]> {
231
+ * async execute() {
232
+ * const { roleId } = this.params;
233
+ * await this.reply(`assigning ${this.users.size} member(s) to <@&${roleId}>`);
234
+ * }
235
+ * }
236
+ * ```
237
+ */
238
+ function UserMenuRoute(...defs) {
239
+ return function(constructor) {
240
+ storeComponentRoute("userMenu", defs, constructor);
241
+ };
242
+ }
243
+ /**
244
+ * Routes role select menu interactions to a `RoleMenuHandler`.
245
+ *
246
+ * Pass the {@link CustomId} definition(s) this handler decodes and list the same ones in the handler's
247
+ * generic. Beside `this.values` the handler declares `this.roles`.
248
+ *
249
+ * @param defs - The customId definition(s) this handler decodes, one per route.
250
+ * @decorator
251
+ * @example
252
+ * ```ts
253
+ * \@RoleMenuRoute(GrantId)
254
+ * class Grant extends RoleMenuHandler<[typeof GrantId]> {
255
+ * async execute() {
256
+ * await this.update(`granting ${this.roles.size} role(s)`);
257
+ * }
258
+ * }
259
+ * ```
260
+ */
261
+ function RoleMenuRoute(...defs) {
262
+ return function(constructor) {
263
+ storeComponentRoute("roleMenu", defs, constructor);
264
+ };
265
+ }
266
+ /**
267
+ * Routes channel select menu interactions to a `ChannelMenuHandler`.
268
+ *
269
+ * Pass the {@link CustomId} definition(s) this handler decodes and list the same ones in the handler's
270
+ * generic. Beside `this.values` the handler declares `this.channels`.
200
271
  *
201
- * @param type - Select menu kind from {@link SelectMenuKind}.
202
272
  * @param defs - The customId definition(s) this handler decodes, one per route.
203
273
  * @decorator
274
+ * @example
275
+ * ```ts
276
+ * \@ChannelMenuRoute(LogTargetId)
277
+ * class LogTarget extends ChannelMenuHandler<[typeof LogTargetId]> {
278
+ * async execute() {
279
+ * await this.update(`logging to ${this.channels.size} channel(s)`);
280
+ * }
281
+ * }
282
+ * ```
283
+ */
284
+ function ChannelMenuRoute(...defs) {
285
+ return function(constructor) {
286
+ storeComponentRoute("channelMenu", defs, constructor);
287
+ };
288
+ }
289
+ /**
290
+ * Routes mentionable select menu interactions to a `MentionableMenuHandler`.
204
291
  *
292
+ * Pass the {@link CustomId} definition(s) this handler decodes and list the same ones in the handler's
293
+ * generic. A mentionable menu accepts users and roles together. `this.users`, `this.members`, and
294
+ * `this.roles` can each come back empty.
295
+ *
296
+ * @param defs - The customId definition(s) this handler decodes, one per route.
297
+ * @decorator
205
298
  * @example
206
- * ```typescript
207
- * \@SelectMenuRoute(SelectMenuKind.User, AssignId)
208
- * class AssignSelect extends SelectMenuHandler<SelectMenuKind.User, [typeof AssignId]> {}
299
+ * ```ts
300
+ * \@MentionableMenuRoute(InviteId)
301
+ * class Invite extends MentionableMenuHandler<[typeof InviteId]> {
302
+ * async execute() {
303
+ * await this.update(`inviting ${this.users.size} user(s) and ${this.roles.size} role(s)`);
304
+ * }
305
+ * }
209
306
  * ```
210
307
  */
211
- function SelectMenuRoute(type, ...defs) {
308
+ function MentionableMenuRoute(...defs) {
212
309
  return function(constructor) {
213
- storeComponentRoute(selectMenuRouteOf(type), defs, constructor);
310
+ storeComponentRoute("mentionableMenu", defs, constructor);
214
311
  };
215
312
  }
216
313
 
@@ -875,7 +972,7 @@ function paginate(items, page, perPage) {
875
972
  }
876
973
 
877
974
  //#endregion
878
- //#region src/pagination/controls.ts
975
+ //#region src/pagination/Controls.ts
879
976
  const DEFAULT_LABEL = {
880
977
  first: "First",
881
978
  prev: "Prev",
@@ -1080,8 +1177,8 @@ var CursorSourceBase = class {
1080
1177
  //#endregion
1081
1178
  //#region src/index.ts
1082
1179
  /** Package version */
1083
- const version = "0.4.1";
1180
+ const version = "0.6.0";
1084
1181
 
1085
1182
  //#endregion
1086
- export { ArraySourceBase, AutocompleteRoute, BaseHandler, BaseReplySender, BuilderComponent, Bus, ButtonRoute, Commands, ContextMenus, Cooldown, CursorSourceBase, CustomId, DispatchContext, DmOnly, Fault, GuildOnly, MessageContextMenuRoute, ModalRoute, Notice, OwnerOnly, PaginatorBase, RegisterCommand, RepliableHandler, RequireBotPermissions, RequirePermissions, RequireRole, ResolvedEmoji, RowComponent, SelectMenuKind, SelectMenuRoute, ShutdownPhase, Silence, SlashRoute, StartupPhase, Subscribe, Subscriber, UserContextMenuRoute, WebhookLog, WebhookUrl, and, assertPermissions, defineEffectGate, defineGate, mergeRoles, or, paginate, setCustomIdErrors, version };
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 };
1087
1184
  //# sourceMappingURL=index.mjs.map