@seedcord/core 0.9.4 → 0.11.0-next.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/README.md +28 -10
- package/dist/CoordinatedShutdown-H5YjZn8A.d.mts +78 -0
- package/dist/CoordinatedStartup-CGnJrqcl.mjs +168 -0
- package/dist/CoordinatedStartup-CGnJrqcl.mjs.map +1 -0
- package/dist/{HmrModuleHandler-DOAtah3j.mjs → HmrModuleHandler-8ZC-UuZh.mjs} +9 -22
- package/dist/HmrModuleHandler-8ZC-UuZh.mjs.map +1 -0
- package/dist/PluginHost-B8kxLOeb.mjs +245 -0
- package/dist/PluginHost-B8kxLOeb.mjs.map +1 -0
- package/dist/{Plugin-Dhx_ivqj.d.mts → PluginHost-DB4j8unu.d.mts} +110 -17
- package/dist/PluginLifecycle-AhQ46NIr.mjs +158 -0
- package/dist/PluginLifecycle-AhQ46NIr.mjs.map +1 -0
- package/dist/ServerHost-CvGQr7oN.mjs +191 -0
- package/dist/ServerHost-CvGQr7oN.mjs.map +1 -0
- package/dist/ServerHost-DYeh0KTk.d.mts +40 -0
- package/dist/hmr.index.d.mts +0 -1
- package/dist/hmr.index.mjs +1 -1
- package/dist/{cursor-BTU5bGoo.d.mts → index-Du71Xx69.d.mts} +253 -6
- package/dist/index.d.mts +19 -84
- package/dist/index.mjs +17 -37
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.d.mts +185 -22
- package/dist/internal.index.mjs +713 -19
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.d.mts +25 -70
- package/dist/node-internal.index.mjs +84 -298
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/node.index.d.mts +3 -2
- package/dist/node.index.mjs +53 -200
- package/dist/node.index.mjs.map +1 -1
- package/dist/{phases-D_zQBXga.d.mts → phases-FTM69J3a.d.mts} +4 -4
- package/dist/plugin.index.d.mts +2 -2
- package/dist/plugin.index.mjs +2 -2
- package/dist/publishDefault-D3dAyzZ9.mjs +7 -0
- package/dist/publishDefault-D3dAyzZ9.mjs.map +1 -0
- package/dist/subscribers-Ce3SWy23.mjs +1913 -0
- package/dist/subscribers-Ce3SWy23.mjs.map +1 -0
- package/package.json +17 -16
- package/dist/Bus-BxPa-Uvp.mjs +0 -866
- package/dist/Bus-BxPa-Uvp.mjs.map +0 -1
- package/dist/HmrModuleHandler-DOAtah3j.mjs.map +0 -1
- package/dist/Pluggable-CXyUZIvT.mjs +0 -310
- package/dist/Pluggable-CXyUZIvT.mjs.map +0 -1
- package/dist/Pluggable-CwKbLui3.d.mts +0 -162
- package/dist/Plugin-CmNW5n6a.mjs +0 -122
- package/dist/Plugin-CmNW5n6a.mjs.map +0 -1
- package/dist/contextMenuLeaves-COzDYa6c.d.mts +0 -17
- package/dist/cursor-CgNBnJfu.mjs +0 -802
- package/dist/cursor-CgNBnJfu.mjs.map +0 -1
- package/dist/devChannel-CQU7hq7Q.mjs +0 -14
- package/dist/devChannel-CQU7hq7Q.mjs.map +0 -1
- package/dist/index-B_-EjyvS.d.mts +0 -135
- package/dist/publishDefault-BuSZPbjT.mjs +0 -14
- package/dist/publishDefault-BuSZPbjT.mjs.map +0 -1
- package/dist/slashRouteLeaves-k1hJnXDO.mjs +0 -31
- package/dist/slashRouteLeaves-k1hJnXDO.mjs.map +0 -1
- package/dist/subscribers-xGy7a7xR.mjs +0 -167
- package/dist/subscribers-xGy7a7xR.mjs.map +0 -1
- package/dist/types-BG0BimVr.d.mts +0 -13
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { K as Notice, P as DispatchContext, U as MiddlewareKind, r as CoreBase } from "./phases-
|
|
1
|
+
import { K as Notice, P as DispatchContext, U as MiddlewareKind, l as Subscriber, r as CoreBase, y as SubscriptionKey } from "./phases-FTM69J3a.mjs";
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { CustomId, CustomIdField } from "@seedcord/custom-id";
|
|
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
|
-
import { APIMessageTopLevelComponent, ApplicationCommandType, ChannelType } from "discord-api-types/v10";
|
|
6
|
-
import { ReplyResponse } from "@seedcord/types";
|
|
5
|
+
import { APIApplicationCommand, APIMessageComponentEmoji, APIMessageTopLevelComponent, ApplicationCommandType, ChannelType, RESTPostAPIApplicationCommandsJSONBody, Snowflake } from "discord-api-types/v10";
|
|
6
|
+
import { EventFrequency, ILogger, ReplyFile, ReplyResponse } from "@seedcord/types";
|
|
7
7
|
import { Constructor, IsNever, LiteralUnion, NonEmptyTuple } from "type-fest";
|
|
8
8
|
//#region src/registries/ContextMenuRegistry.d.ts
|
|
9
9
|
/** The two context-menu command kinds Discord defines. */
|
|
@@ -260,6 +260,112 @@ declare function RegisterCommand(scope: 'global'): (ctor: CommandCtor) => void;
|
|
|
260
260
|
*/
|
|
261
261
|
declare function RegisterCommand(scope: 'guild', guilds: GuildTarget[]): (ctor: CommandCtor) => void;
|
|
262
262
|
//#endregion
|
|
263
|
+
//#region src/commands/deployTarget.d.ts
|
|
264
|
+
type DeployTarget = Exclude<CommandMeta, {
|
|
265
|
+
scope: 'config';
|
|
266
|
+
}>;
|
|
267
|
+
declare function resolveDeployTarget(meta: CommandMeta, configured: readonly string[], commandName: string): DeployTarget;
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/commands/scopes.d.ts
|
|
270
|
+
declare const GLOBAL_ID = "global";
|
|
271
|
+
type ScopeId = LiteralUnion<typeof GLOBAL_ID, Snowflake>;
|
|
272
|
+
declare function commandsRoute(applicationId: Snowflake, scope: ScopeId): `/${string}`;
|
|
273
|
+
declare function globalFirst<ValueT>(scopes: Iterable<readonly [ScopeId, ValueT]>): (readonly [ScopeId, ValueT])[];
|
|
274
|
+
declare function scopeIdsOf(target: DeployTarget): readonly ScopeId[];
|
|
275
|
+
declare function skippedNote(skipped: readonly ScopeId[], guildLabel: (guildId: string) => string): string;
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/commands/types.d.ts
|
|
278
|
+
/** @internal */
|
|
279
|
+
type CommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder;
|
|
280
|
+
/** discord returns these from each scope's deploy, keyed by command id. @internal */
|
|
281
|
+
type DeployResult = Map<ScopeId, Map<string, APIApplicationCommand>>;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/commands/linkCommands.d.ts
|
|
284
|
+
interface CommandRef {
|
|
285
|
+
readonly name: string;
|
|
286
|
+
readonly type: ApplicationCommandType;
|
|
287
|
+
}
|
|
288
|
+
interface LinkedContextMenus {
|
|
289
|
+
readonly user: Record<string, ContextMenuInfo>;
|
|
290
|
+
readonly message: Record<string, ContextMenuInfo>;
|
|
291
|
+
}
|
|
292
|
+
interface LinkedCommands {
|
|
293
|
+
readonly commands: Record<string, CommandInfo>;
|
|
294
|
+
readonly contextMenus: LinkedContextMenus;
|
|
295
|
+
readonly multiGuild: CommandRef[];
|
|
296
|
+
readonly notInCode: CommandRef[];
|
|
297
|
+
}
|
|
298
|
+
interface CommandLike {
|
|
299
|
+
name: string;
|
|
300
|
+
type?: ApplicationCommandType | undefined;
|
|
301
|
+
}
|
|
302
|
+
declare function commandRefOf({ name, type }: CommandLike): CommandRef;
|
|
303
|
+
declare function commandKey(command: CommandLike): string;
|
|
304
|
+
declare function indexById(commands: readonly APIApplicationCommand[]): Map<string, APIApplicationCommand>;
|
|
305
|
+
declare function linkCommands(deploy: DeployResult, all: readonly RESTPostAPIApplicationCommandsJSONBody[]): LinkedCommands;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/commands/CommandInjector.d.ts
|
|
308
|
+
/** What {@link Commands} resolves to for one slash route. */
|
|
309
|
+
interface CommandInfo {
|
|
310
|
+
/** The clickable `</config set:id>` mention. A route whose id did not resolve falls back to `/config set`. */
|
|
311
|
+
readonly mention: string;
|
|
312
|
+
/** The deployed command id. Absent when the command deployed to two or more guilds. */
|
|
313
|
+
readonly id?: string;
|
|
314
|
+
/** The full route, e.g. `config/set`. */
|
|
315
|
+
readonly route: string;
|
|
316
|
+
/** The route's own description, taken from the subcommand for a nested route. */
|
|
317
|
+
readonly description: string;
|
|
318
|
+
}
|
|
319
|
+
/** Each registered slash route mapped to its deployed command. */
|
|
320
|
+
type InjectedCommandMap = { [K in keyof SlashRegistry]: CommandInfo; };
|
|
321
|
+
/**
|
|
322
|
+
* The bot's deployed slash commands, keyed by {@link SlashRegistry}. A server bot fills these after
|
|
323
|
+
* each deploy. An edge bot fills them on its first request, from the ids `seedcord build` wrote into
|
|
324
|
+
* the worker.
|
|
325
|
+
*
|
|
326
|
+
* @throws A **SeedcordError** when you read a command before the bot fills it.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* import { Commands } from '@seedcord/gateway';
|
|
331
|
+
*
|
|
332
|
+
* await this.reply(`Try ${Commands['config/set'].mention}`);
|
|
333
|
+
*
|
|
334
|
+
* // a help listing
|
|
335
|
+
* const lines = Object.values(Commands).map((c) => `${c.mention} ${c.description}`);
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
declare const Commands: InjectedCommandMap;
|
|
339
|
+
/** What {@link ContextMenus} resolves to for one context-menu command. */
|
|
340
|
+
interface ContextMenuInfo {
|
|
341
|
+
/** The deployed command id. Absent when the command deployed to two or more guilds. */
|
|
342
|
+
readonly id?: string;
|
|
343
|
+
/** The name shown in Discord's right-click menu. */
|
|
344
|
+
readonly name: string;
|
|
345
|
+
readonly kind: ContextMenuKind;
|
|
346
|
+
}
|
|
347
|
+
/** Deployed context-menu commands, split by kind because Discord scopes name uniqueness per command type. */
|
|
348
|
+
interface InjectedContextMenuMap {
|
|
349
|
+
readonly user: { [K in keyof UserContextMenuRegistry]: ContextMenuInfo; };
|
|
350
|
+
readonly message: { [K in keyof MessageContextMenuRegistry]: ContextMenuInfo; };
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* The bot's deployed context-menu commands. A server bot fills these after each deploy. An edge bot
|
|
354
|
+
* fills them on its first request, from the ids `seedcord build` wrote into the worker.
|
|
355
|
+
*
|
|
356
|
+
* @throws A **SeedcordError** when you read a command before the bot fills it.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* import { ContextMenus } from '@seedcord/gateway';
|
|
361
|
+
*
|
|
362
|
+
* const id = ContextMenus.user['View Profile'].id;
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare const ContextMenus: InjectedContextMenuMap;
|
|
366
|
+
declare function installLinks({ commands, contextMenus }: Pick<LinkedCommands, 'commands' | 'contextMenus'>): void;
|
|
367
|
+
declare function warnLinks(logger: ILogger, { multiGuild, notInCode }: Pick<LinkedCommands, 'multiGuild' | 'notInCode'>): void;
|
|
368
|
+
//#endregion
|
|
263
369
|
//#region src/decorators/brands.d.ts
|
|
264
370
|
declare const SlashRouteBrand: unique symbol;
|
|
265
371
|
declare const AutocompleteRouteBrand: unique symbol;
|
|
@@ -312,7 +418,7 @@ interface InteractionMiddlewareMetadata {
|
|
|
312
418
|
* }
|
|
313
419
|
* ```
|
|
314
420
|
*
|
|
315
|
-
* @throws A **SeedcordTypeError**
|
|
421
|
+
* @throws A **SeedcordTypeError** when `priority` is not a finite number.
|
|
316
422
|
*/
|
|
317
423
|
declare function RegisterInteractionMiddleware<const Kinds extends NonEmptyTuple<MiddlewareKind> = NonEmptyTuple<MiddlewareKind>>(options?: InteractionMiddlewareOptions<Kinds>): <TCtor extends AnyMiddlewareCtor>(ctor: AssertMiddlewareKinds<Kinds[number], TCtor>) => void;
|
|
318
424
|
/** @internal */
|
|
@@ -740,6 +846,19 @@ declare function RequireBotPermissions(scope: PermissionScope, options?: Require
|
|
|
740
846
|
*/
|
|
741
847
|
declare function RequireRole(roleId: string, options?: RequireRoleOptions): Gate<GateContextBase, 'RequireRole'>;
|
|
742
848
|
//#endregion
|
|
849
|
+
//#region src/miscellaneous/ResolvedEmoji.d.ts
|
|
850
|
+
/**
|
|
851
|
+
* A resolved custom emoji. Renders as `<:name:id>` in message content, or `<a:name:id>` when animated,
|
|
852
|
+
* and passes straight to a builder's `setEmoji`.
|
|
853
|
+
*/
|
|
854
|
+
declare class ResolvedEmoji implements APIMessageComponentEmoji {
|
|
855
|
+
readonly name: string;
|
|
856
|
+
readonly id: string;
|
|
857
|
+
readonly animated: boolean;
|
|
858
|
+
constructor(name: string, id: string, animated?: boolean);
|
|
859
|
+
toString(): string;
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
743
862
|
//#region src/inputs/AutocompleteOptions.d.ts
|
|
744
863
|
type Row<Route extends keyof SlashRegistry> = SlashRegistry[Route]['options'];
|
|
745
864
|
type EntryFor<Route extends keyof SlashRegistry, Name extends PropertyKey> = Route extends unknown ? Name extends keyof Row<Route> ? Row<Route>[Name] : never : never;
|
|
@@ -789,5 +908,133 @@ type PageCursor<Prefix extends string> = CustomId<Prefix, {
|
|
|
789
908
|
/** Build the page cursor for a paginator. */
|
|
790
909
|
declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
|
|
791
910
|
//#endregion
|
|
792
|
-
|
|
793
|
-
|
|
911
|
+
//#region src/subscribers/decorators/Subscribe.d.ts
|
|
912
|
+
/**
|
|
913
|
+
* Options accepted by the `@Subscribe` decorator.
|
|
914
|
+
*/
|
|
915
|
+
interface SubscribeOptions {
|
|
916
|
+
/**
|
|
917
|
+
* Frequency: `'once'` or `'on'`.
|
|
918
|
+
*
|
|
919
|
+
* @defaultValue `'on'`
|
|
920
|
+
*/
|
|
921
|
+
readonly frequency?: EventFrequency | undefined;
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Registers a subscriber handler class with a specific subscriber event.
|
|
925
|
+
*
|
|
926
|
+
* Associates the decorated class with a subscriber event type for automatic
|
|
927
|
+
* registration and execution when the subscriber is emitted.
|
|
928
|
+
*
|
|
929
|
+
* @typeParam TSubscriber - The subscriber event name to register for
|
|
930
|
+
* @param subscriber - The subscriber event name to register for
|
|
931
|
+
* @param options - Options to configure the subscriber handler registration.
|
|
932
|
+
* @decorator
|
|
933
|
+
* @example
|
|
934
|
+
* ```typescript
|
|
935
|
+
* \@Subscribe('userJoin')
|
|
936
|
+
* class WelcomeHandler extends Subscriber<'userJoin'> {
|
|
937
|
+
* async execute() {
|
|
938
|
+
* }
|
|
939
|
+
* }
|
|
940
|
+
* ```
|
|
941
|
+
* @example
|
|
942
|
+
* ```ts
|
|
943
|
+
* \@Subscribe('userJoin', { frequency: 'once' })
|
|
944
|
+
* // or
|
|
945
|
+
* \@Subscribe('userJoin')
|
|
946
|
+
* ```
|
|
947
|
+
*/
|
|
948
|
+
declare function Subscribe<TSubscriber extends SubscriptionKey>(subscriber: TSubscriber, options?: SubscribeOptions): <HandlerCtor extends Constructor<Subscriber<TSubscriber, CoreBase>>>(constructor: HandlerCtor) => void;
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/subscribers/bases/WebhookSender.d.ts
|
|
951
|
+
/** A file attached to a webhook report. */
|
|
952
|
+
interface WebhookFile extends ReplyFile {
|
|
953
|
+
readonly description: string;
|
|
954
|
+
}
|
|
955
|
+
interface WebhookSendOptions {
|
|
956
|
+
flags: number;
|
|
957
|
+
username: string;
|
|
958
|
+
avatarUrl?: string | undefined;
|
|
959
|
+
components: readonly {
|
|
960
|
+
toJSON(): APIMessageTopLevelComponent;
|
|
961
|
+
}[];
|
|
962
|
+
files?: readonly WebhookFile[] | undefined;
|
|
963
|
+
}
|
|
964
|
+
declare class WebhookSender {
|
|
965
|
+
private readonly rest;
|
|
966
|
+
private readonly route;
|
|
967
|
+
constructor(url: string);
|
|
968
|
+
verify(): Promise<'ok' | 'missing' | 'unreachable'>;
|
|
969
|
+
send(options: WebhookSendOptions): Promise<void>;
|
|
970
|
+
}
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/subscribers/bases/WebhookLog.d.ts
|
|
973
|
+
/**
|
|
974
|
+
* The content a reporter returns from {@link WebhookLog.report}.
|
|
975
|
+
*/
|
|
976
|
+
interface WebhookReport {
|
|
977
|
+
/** Shown as the webhook message author. Defaults to the reporter's class name. */
|
|
978
|
+
username?: string;
|
|
979
|
+
/** Shown as the webhook message avatar. Defaults to the webhook's own. */
|
|
980
|
+
avatarUrl?: string;
|
|
981
|
+
components: readonly {
|
|
982
|
+
toJSON(): APIMessageTopLevelComponent;
|
|
983
|
+
}[];
|
|
984
|
+
files?: readonly WebhookFile[] | undefined;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Base class for subscribers that deliver their event to a Discord webhook.
|
|
988
|
+
*
|
|
989
|
+
* Declare the url's environment variable with `@WebhookUrl` and implement {@link report}. The base
|
|
990
|
+
* resolves the url, validates it, reuses one sender per url, and sends. Registration skips a reporter
|
|
991
|
+
* whose variable is unset and warns at boot.
|
|
992
|
+
*
|
|
993
|
+
* @typeParam KeyOfSubscribers - The subscription key this reporter receives
|
|
994
|
+
* @typeParam TCore - The transport's Core
|
|
995
|
+
*/
|
|
996
|
+
declare abstract class WebhookLog<KeyOfSubscribers extends SubscriptionKey, TCore extends CoreBase> extends Subscriber<KeyOfSubscribers, TCore> {
|
|
997
|
+
private static readonly senders;
|
|
998
|
+
/**
|
|
999
|
+
* Builds the message for one published event.
|
|
1000
|
+
*
|
|
1001
|
+
* @param suppressed - How many events were dropped since the last card
|
|
1002
|
+
*/
|
|
1003
|
+
abstract report(suppressed: number): WebhookReport | Promise<WebhookReport>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Events sharing this key collapse into one card per minute. Return `null` to send every event.
|
|
1006
|
+
*/
|
|
1007
|
+
protected throttleKey(): string | null;
|
|
1008
|
+
execute(): Promise<void>;
|
|
1009
|
+
/** @internal */
|
|
1010
|
+
static senderFor(url: string): WebhookSender;
|
|
1011
|
+
/** @internal */
|
|
1012
|
+
static envKeyOf(ctor: NewableFunction): string;
|
|
1013
|
+
/** @internal Returns null when the env var is unset, throws when set but malformed. */
|
|
1014
|
+
static urlOf(envKey: string): string | null;
|
|
1015
|
+
}
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/subscribers/decorators/WebhookUrl.d.ts
|
|
1018
|
+
/**
|
|
1019
|
+
* Declares the environment variable a {@link WebhookLog} reporter reads its webhook url from.
|
|
1020
|
+
*
|
|
1021
|
+
* An unset variable disables the reporter with a boot warning. A set but malformed value throws
|
|
1022
|
+
* at boot.
|
|
1023
|
+
*
|
|
1024
|
+
* @param envKey - The environment variable name holding the webhook url
|
|
1025
|
+
* @decorator
|
|
1026
|
+
* @example
|
|
1027
|
+
* ```ts
|
|
1028
|
+
* \@Subscribe('memberBanned')
|
|
1029
|
+
* \@WebhookUrl('BAN_LOG_WEBHOOK_URL')
|
|
1030
|
+
* class BanLog extends WebhookLog<'memberBanned'> {
|
|
1031
|
+
* report() {
|
|
1032
|
+
* return { components: [new BanCard(this.data).component] };
|
|
1033
|
+
* }
|
|
1034
|
+
* }
|
|
1035
|
+
* ```
|
|
1036
|
+
*/
|
|
1037
|
+
declare function WebhookUrl(envKey: string): <HandlerCtor extends Constructor<WebhookLog<SubscriptionKey, CoreBase>>>(constructor: HandlerCtor) => void;
|
|
1038
|
+
//#endregion
|
|
1039
|
+
export { SlashRouteBrand as $, Gate as A, CacheFor as At, HandlerOutcome as B, UserContextMenuRegistry as Bt, GateNoticeOptions as C, CommandMeta as Ct, JoinNames as D, RowComponent as Dt, IntersectRequired as E, BuilderComponent as Et, defineGate as F, SlashRouteEntry as Ft, RegisterInteractionMiddleware as G, AnyMiddlewareCtor as H, SerializedReply as I, ContextMenuKind as It, ComponentDefsBrand as J, interactionMiddlewareMetaOf as K, serializeReply as L, MenuCacheFor as Lt, GuildPermissionsContext as M, RouteCache as Mt, RequiredOf as N, SlashOption as Nt, TwoOrMore as O, BuilderType as Ot, defineEffectGate as P, SlashRegistry as Pt, MiddlewareKindsBrand as Q, DispatchResult as R, MessageContextMenuRegistry as Rt, PermissionScope as S, resolveDeployTarget as St, GateFitsWith as T, RegisterCommand as Tt, InteractionMiddlewareMetadata as U, HandlerResult as V, InteractionMiddlewareOptions as W, ContextMenuKindBrand as X, ComponentKindBrand as Y, ContextMenuNamesBrand as Z, RequirePermissions as _, ScopeId as _t, Subscribe as a, InjectedContextMenuMap as at, RequireRoleOptions as b, scopeIdsOf as bt, PageCursor as c, CommandRef as ct, AutocompleteOptions as d, commandRefOf as dt, CommandInfo as et, ChoiceValueOf as f, indexById as ft, RequireBotPermissions as g, GLOBAL_ID as gt, ResolvedEmoji as h, DeployResult as ht, WebhookFile as i, InjectedCommandMap as it, GateContextBase as j, OptionKind as jt, EffectGate as k, RowType as kt, pageCursor as l, LinkedCommands as lt, FocusedField as m, CommandBuilder as mt, WebhookLog as n, ContextMenuInfo as nt, SubscribeOptions as o, installLinks as ot, EntryFor as p, linkCommands as pt, AutocompleteRouteBrand as q, WebhookReport as r, ContextMenus as rt, PAGE_MAX as s, warnLinks as st, WebhookUrl as t, Commands as tt, AutocompletableNames as u, commandKey as ut, RequirePermissionsOptions as v, commandsRoute as vt, pickNotice as w, GuildTarget as wt, PermissionNames as x, skippedNote as xt, RequireRole as y, globalFirst as yt, EventDispatchResult as z, NamesFor as zt };
|
|
1040
|
+
//# sourceMappingURL=index-Du71Xx69.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { C as AckState, K as Notice, P as DispatchContext, U as MiddlewareKind, _ as ResponseSent, b as Subscriptions, f as DispatchOutcome, g as ResponseOutcome, h as ResponseFailed, i as Bus, l as Subscriber, m as ResponseAttempt, n as StartupPhase, p as FaultSource, r as CoreBase, t as ShutdownPhase, u as AttemptedWrite, v as SubscriptionData, x as ReplyTelemetry, y as SubscriptionKey, z as InteractionKind } from "./phases-
|
|
2
|
-
import { $ as
|
|
3
|
-
import "./types-BG0BimVr.mjs";
|
|
4
|
-
import { a as Subscribe, i as WebhookFile, n as WebhookLog, o as SubscribeOptions, r as WebhookReport, t as WebhookUrl } from "./index-B_-EjyvS.mjs";
|
|
1
|
+
import { C as AckState, K as Notice, P as DispatchContext, U as MiddlewareKind, _ as ResponseSent, b as Subscriptions, f as DispatchOutcome, g as ResponseOutcome, h as ResponseFailed, i as Bus, l as Subscriber, m as ResponseAttempt, n as StartupPhase, p as FaultSource, r as CoreBase, t as ShutdownPhase, u as AttemptedWrite, v as SubscriptionData, x as ReplyTelemetry, y as SubscriptionKey, z as InteractionKind } from "./phases-FTM69J3a.mjs";
|
|
2
|
+
import { $ as SlashRouteBrand, A as Gate, B as HandlerOutcome, Bt as UserContextMenuRegistry, C as GateNoticeOptions, D as JoinNames, Dt as RowComponent, E as IntersectRequired, Et as BuilderComponent, F as defineGate, G as RegisterInteractionMiddleware, I as SerializedReply, It as ContextMenuKind, J as ComponentDefsBrand, M as GuildPermissionsContext, N as RequiredOf, O as TwoOrMore, Ot as BuilderType, P as defineEffectGate, Pt as SlashRegistry, R as DispatchResult, Rt as MessageContextMenuRegistry, S as PermissionScope, Tt as RegisterCommand, V as HandlerResult, W as InteractionMiddlewareOptions, X as ContextMenuKindBrand, Y as ComponentKindBrand, Z as ContextMenuNamesBrand, _ as RequirePermissions, a as Subscribe, at as InjectedContextMenuMap, b as RequireRoleOptions, c as PageCursor, d as AutocompleteOptions, et as CommandInfo, g as RequireBotPermissions, h as ResolvedEmoji, i as WebhookFile, it as InjectedCommandMap, j as GateContextBase, k as EffectGate, kt as RowType, n as WebhookLog, nt as ContextMenuInfo, o as SubscribeOptions, q as AutocompleteRouteBrand, r as WebhookReport, rt as ContextMenus, t as WebhookUrl, tt as Commands, v as RequirePermissionsOptions, wt as GuildTarget, y as RequireRole, z as EventDispatchResult, zt as NamesFor } from "./index-Du71Xx69.mjs";
|
|
5
3
|
import "reflect-metadata";
|
|
6
4
|
import { AnyCustomId, AnyCustomId as AnyCustomId$1, CustomId, CustomIdField, CustomIdShape, DecodedParams, DecodedRoute, FieldOptions, decodeFor, prefixOf, setCustomIdErrors } from "@seedcord/custom-id";
|
|
7
5
|
import { ActionRowBuilder, ButtonBuilder } from "@discordjs/builders";
|
|
@@ -10,61 +8,6 @@ import { Logger } from "@seedcord/logger";
|
|
|
10
8
|
import { ValidDuration } from "@seedcord/utils";
|
|
11
9
|
import { DeferOpts, EpochMs, LoggerChannelId, RenderContext, ReplyResponse, SendOpts, TypedExtract, V2Component } from "@seedcord/types";
|
|
12
10
|
import { Constructor, Promisable } from "type-fest";
|
|
13
|
-
//#region src/commands/CommandInjector.d.ts
|
|
14
|
-
/** What {@link Commands} resolves to for one slash route. */
|
|
15
|
-
interface CommandInfo {
|
|
16
|
-
/** The clickable `</config set:id>` mention. A route whose id did not resolve falls back to `/config set`. */
|
|
17
|
-
readonly mention: string;
|
|
18
|
-
/** The deployed command id. Absent when the command deployed to two or more guilds. */
|
|
19
|
-
readonly id?: string;
|
|
20
|
-
/** The full route, e.g. `config/set`. */
|
|
21
|
-
readonly route: string;
|
|
22
|
-
/** The route's own description, taken from the subcommand for a nested route. */
|
|
23
|
-
readonly description: string;
|
|
24
|
-
}
|
|
25
|
-
/** Each registered slash route mapped to its deployed command. */
|
|
26
|
-
type InjectedCommandMap = { [K in keyof SlashRegistry]: CommandInfo; };
|
|
27
|
-
/**
|
|
28
|
-
* The bot's deployed slash commands, keyed by {@link SlashRegistry}. Filled by
|
|
29
|
-
* {@link CommandInjector} after each deploy, and a read before that throws.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* import { Commands } from '@seedcord/gateway';
|
|
34
|
-
*
|
|
35
|
-
* await this.reply(`Try ${Commands['config/set'].mention}`);
|
|
36
|
-
*
|
|
37
|
-
* // a help listing
|
|
38
|
-
* const lines = Object.values(Commands).map((c) => `${c.mention} ${c.description}`);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare const Commands: InjectedCommandMap;
|
|
42
|
-
/** What {@link ContextMenus} resolves to for one context-menu command. */
|
|
43
|
-
interface ContextMenuInfo {
|
|
44
|
-
/** The deployed command id. Absent when the command deployed to two or more guilds. */
|
|
45
|
-
readonly id?: string;
|
|
46
|
-
/** The name shown in Discord's right-click menu. */
|
|
47
|
-
readonly name: string;
|
|
48
|
-
readonly kind: ContextMenuKind;
|
|
49
|
-
}
|
|
50
|
-
/** Deployed context-menu commands, split by kind because Discord scopes name uniqueness per command type. */
|
|
51
|
-
interface InjectedContextMenuMap {
|
|
52
|
-
readonly user: { [K in keyof UserContextMenuRegistry]: ContextMenuInfo; };
|
|
53
|
-
readonly message: { [K in keyof MessageContextMenuRegistry]: ContextMenuInfo; };
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The bot's deployed context-menu commands. Filled by {@link CommandInjector} after each deploy, and a read
|
|
57
|
-
* before that throws.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* import { ContextMenus } from '@seedcord/gateway';
|
|
62
|
-
*
|
|
63
|
-
* const id = ContextMenus.user['View Profile'].id;
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export declare const ContextMenus: InjectedContextMenuMap;
|
|
67
|
-
//#endregion
|
|
68
11
|
//#region src/decorators/routes.d.ts
|
|
69
12
|
type ComponentBrand = TypedExtract<InteractionKind, InteractionKind.Button | InteractionKind.Modal | InteractionKind.StringMenu | InteractionKind.UserMenu | InteractionKind.RoleMenu | InteractionKind.ChannelMenu | InteractionKind.MentionableMenu>;
|
|
70
13
|
type AnyHandlerCtor = new (...args: never[]) => unknown;
|
|
@@ -319,10 +262,11 @@ interface ModalLike {
|
|
|
319
262
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
320
263
|
}
|
|
321
264
|
/**
|
|
322
|
-
* Tracks acknowledgement state
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
265
|
+
* Tracks acknowledgement state. Every verb runs the legality check, calls the transport's wire writer,
|
|
266
|
+
* then updates the state and the ack trace. Each transport binds `TMessage` to its own created-message
|
|
267
|
+
* type and supplies the writers.
|
|
268
|
+
*
|
|
269
|
+
* @throws A **SeedcordError** when you call a verb the current ack state doesn't allow. It throws before any transport call.
|
|
326
270
|
*/
|
|
327
271
|
export declare abstract class BaseReplySender<TMessage extends {
|
|
328
272
|
id: string;
|
|
@@ -586,14 +530,16 @@ interface CooldownOptions {
|
|
|
586
530
|
}
|
|
587
531
|
/**
|
|
588
532
|
* Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, and a string is
|
|
589
|
-
* a duration like `30m` or `24h`.
|
|
590
|
-
*
|
|
533
|
+
* a duration like `30m` or `24h`. The slot is charged in commit, only after the whole gate set passes,
|
|
534
|
+
* so a later refusal never burns the cooldown.
|
|
591
535
|
* That split also means two requests racing the same key can both pass before either charges the slot.
|
|
592
536
|
* The key combines the handler's route with the window settings, keeping two different handlers on separate
|
|
593
537
|
* windows. Reword the refusal with {@link CooldownOptions.message} or replace it with {@link CooldownOptions.notice}.
|
|
594
538
|
*
|
|
595
|
-
* @param duration - A number is seconds, and a string is a duration like `30m` or `24h`.
|
|
539
|
+
* @param duration - A number is seconds, and a string is a duration like `30m` or `24h`.
|
|
596
540
|
* @param options - Sets the scope with `per`, the uses per window with `limit`, and the refusal text with `message` or `notice`.
|
|
541
|
+
* @throws A **SeedcordTypeError** when `duration` is a string that doesn't parse.
|
|
542
|
+
* @throws A **SeedcordRangeError** when `duration` is zero or negative.
|
|
597
543
|
*
|
|
598
544
|
* @see the `@Gated` decorator from your transport package
|
|
599
545
|
* @see {@link IRateLimiter}
|
|
@@ -654,7 +600,7 @@ interface PermissionAssertion extends PermissionNoticeOverrides {
|
|
|
654
600
|
* The caller computes `permissions`, gateway off a discord.js role, member, or channel, and HTTP off the
|
|
655
601
|
* bitfield the interaction payload carries.
|
|
656
602
|
*
|
|
657
|
-
* @throws A {@link Notice}
|
|
603
|
+
* @throws A {@link Notice} when the check refuses. It lists the missing or present permissions.
|
|
658
604
|
*
|
|
659
605
|
* @example
|
|
660
606
|
* ```ts
|
|
@@ -802,19 +748,6 @@ export declare class Silence extends Error {
|
|
|
802
748
|
constructor(reason?: string | undefined);
|
|
803
749
|
}
|
|
804
750
|
//#endregion
|
|
805
|
-
//#region src/miscellaneous/ResolvedEmoji.d.ts
|
|
806
|
-
/**
|
|
807
|
-
* A resolved custom emoji. Renders as `<:name:id>` in message content, or `<a:name:id>` when animated,
|
|
808
|
-
* and passes straight to a builder's `setEmoji`.
|
|
809
|
-
*/
|
|
810
|
-
export declare class ResolvedEmoji implements APIMessageComponentEmoji {
|
|
811
|
-
readonly name: string;
|
|
812
|
-
readonly id: string;
|
|
813
|
-
readonly animated: boolean;
|
|
814
|
-
constructor(name: string, id: string, animated?: boolean);
|
|
815
|
-
toString(): string;
|
|
816
|
-
}
|
|
817
|
-
//#endregion
|
|
818
751
|
//#region src/pagination/PageView.d.ts
|
|
819
752
|
/**
|
|
820
753
|
* One rendered page of a paginated list.
|
|
@@ -838,7 +771,7 @@ interface PageView<Item> {
|
|
|
838
771
|
* @param page - The requested zero-based page, clamped into `[0, totalPages - 1]`.
|
|
839
772
|
* @param perPage - The page size. Must be a positive integer.
|
|
840
773
|
* @returns The sliced {@link PageView}, with `totalPages` always known.
|
|
841
|
-
* @throws SeedcordRangeError when `perPage` is not a positive integer.
|
|
774
|
+
* @throws A **SeedcordRangeError** when `perPage` is not a positive integer.
|
|
842
775
|
*/
|
|
843
776
|
export declare function paginate<Item>(items: readonly Item[], page: number, perPage: number): PageView<Item>;
|
|
844
777
|
//#endregion
|
|
@@ -860,8 +793,10 @@ interface PaginatorControls {
|
|
|
860
793
|
*/
|
|
861
794
|
button(key: ControlKey, cosmetics?: ControlCosmetics): ButtonBuilder;
|
|
862
795
|
/**
|
|
863
|
-
* Assemble an action row of the chosen controls, in order.
|
|
864
|
-
*
|
|
796
|
+
* Assemble an action row of the chosen controls, in order.
|
|
797
|
+
*
|
|
798
|
+
* @throws A **SeedcordRangeError** when `keys` is empty or holds more than five controls.
|
|
799
|
+
* @throws A **SeedcordTypeError** when `keys` holds the same control twice.
|
|
865
800
|
*/
|
|
866
801
|
row(...keys: ControlKey[]): ActionRowBuilder<ButtonBuilder>;
|
|
867
802
|
}
|
|
@@ -964,5 +899,5 @@ export declare abstract class PaginatorBase<Item, Prefix extends string, Ctx> {
|
|
|
964
899
|
/** Package version */
|
|
965
900
|
export declare const version: string;
|
|
966
901
|
//#endregion
|
|
967
|
-
export { type AnyCustomId, type AttemptedWrite, type AutocompleteOptions, BuilderComponent, type BuilderType, Bus, type CommandInfo, type ContextMenuInfo, type ControlCosmetics, type ControlKey, type CooldownOptions, type CoreBase, CustomId, type CustomIdField, type CustomIdShape, type DecodedParams, type DecodedRoute, DispatchContext, type DispatchOutcome, type DispatchResult, type EffectGate, type EventDispatchResult, type FaultSource, type FieldOptions, type Gate, type GateContextBase, type GateNoticeOptions, type GuildPermissionsContext, type GuildTarget, type HandlerOutcome, type HandlerResult, type InjectedCommandMap, type InjectedContextMenuMap, InteractionKind, type InteractionMiddlewareOptions, type ItemRender, type MessageContextMenuRegistry, type MiddlewareKind, type ModalLike, Notice, type PageRender, type PageSourceBase, type PageView, type PaginatorConfig, type PaginatorControls, type PermissionAssertion, type PermissionNoticeOverrides, type PermissionScope, RegisterCommand, RegisterInteractionMiddleware, RequireBotPermissions, RequirePermissions, type RequirePermissionsOptions, RequireRole, type RequireRoleOptions, type RequiredOf, type ResponseAttempt, type ResponseFailed, type ResponseOutcome, type ResponseSent, RowComponent, type RowType, ShutdownPhase, type SlashRegistry, StartupPhase, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type UserContextMenuRegistry, type WebhookFile, WebhookLog, type WebhookReport, WebhookUrl, decodeFor, defineEffectGate, defineGate, prefixOf, setCustomIdErrors };
|
|
902
|
+
export { type AnyCustomId, type AttemptedWrite, type AutocompleteOptions, BuilderComponent, type BuilderType, Bus, type CommandInfo, Commands, type ContextMenuInfo, ContextMenus, type ControlCosmetics, type ControlKey, type CooldownOptions, type CoreBase, CustomId, type CustomIdField, type CustomIdShape, type DecodedParams, type DecodedRoute, DispatchContext, type DispatchOutcome, type DispatchResult, type EffectGate, type EventDispatchResult, type FaultSource, type FieldOptions, type Gate, type GateContextBase, type GateNoticeOptions, type GuildPermissionsContext, type GuildTarget, type HandlerOutcome, type HandlerResult, type InjectedCommandMap, type InjectedContextMenuMap, InteractionKind, type InteractionMiddlewareOptions, type ItemRender, type MessageContextMenuRegistry, type MiddlewareKind, type ModalLike, Notice, type PageRender, type PageSourceBase, type PageView, type PaginatorConfig, type PaginatorControls, type PermissionAssertion, type PermissionNoticeOverrides, type PermissionScope, RegisterCommand, RegisterInteractionMiddleware, RequireBotPermissions, RequirePermissions, type RequirePermissionsOptions, RequireRole, type RequireRoleOptions, type RequiredOf, ResolvedEmoji, type ResponseAttempt, type ResponseFailed, type ResponseOutcome, type ResponseSent, RowComponent, type RowType, ShutdownPhase, type SlashRegistry, StartupPhase, Subscribe, type SubscribeOptions, Subscriber, type SubscriptionData, type SubscriptionKey, type Subscriptions, type UserContextMenuRegistry, type WebhookFile, WebhookLog, type WebhookReport, WebhookUrl, decodeFor, defineEffectGate, defineGate, prefixOf, setCustomIdErrors };
|
|
968
903
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-BxPa-Uvp.mjs";
|
|
3
|
-
import { a as ContextMenus, i as Commands, n as RegisterCommand } from "./subscribers-xGy7a7xR.mjs";
|
|
1
|
+
import { $ as RegisterInteractionMiddleware, A as rollbackCommits, B as NotInGuild, D as pickNotice, E as presentNames, F as MissingPermissions, G as serializeReply, H as OnCooldown, Ht as Notice, J as publishResponse, K as translateSerializationError, L as NeedsAny, Lt as NoticeCard, P as HasDangerousPermissions, Q as sendTarget, R as NotAllowed, Rt as BuilderComponent, S as RequireRole, T as missingNames, U as defineEffectGate, V as NotOwner, W as defineGate, X as AckTrace, Z as checkAckLegality, _ as pageCursor, b as RequireBotPermissions, bt as Commands, ct as RegisterCommand, d as WebhookLog, f as Subscriber, g as PAGE_MAX, it as storeInteractionRoute, j as runCheck, k as markCommits, l as WebhookUrl, pt as InteractionKind, q as attemptWrite, rt as storeComponentRoute, t as Bus, tt as contextMenuRouteOf, u as Subscribe, v as ResolvedEmoji, w as hasAll, x as RequirePermissions, xt as ContextMenus, y as Silence, z as NotInDm, zt as RowComponent } from "./subscribers-Ce3SWy23.mjs";
|
|
4
2
|
import { n as StartupPhase, t as ShutdownPhase } from "./phases-BauKJOTT.mjs";
|
|
5
3
|
import "reflect-metadata";
|
|
6
4
|
import { CustomId, decodeFor, prefixOf, setCustomIdErrors, setCustomIdErrors as setCustomIdErrors$1 } from "@seedcord/custom-id";
|
|
@@ -314,7 +312,7 @@ var DispatchContext = class {
|
|
|
314
312
|
/**
|
|
315
313
|
* Read a key that must be present, with `undefined` stripped from the result.
|
|
316
314
|
*
|
|
317
|
-
* @throws A **SeedcordError**
|
|
315
|
+
* @throws A **SeedcordError** when nothing set the key on this dispatch.
|
|
318
316
|
*/
|
|
319
317
|
require(key) {
|
|
320
318
|
const value = this.state[key];
|
|
@@ -396,10 +394,11 @@ var RepliableHandler = class extends BaseHandler {
|
|
|
396
394
|
//#endregion
|
|
397
395
|
//#region src/reply/BaseReplySender.ts
|
|
398
396
|
/**
|
|
399
|
-
* Tracks acknowledgement state
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
397
|
+
* Tracks acknowledgement state. Every verb runs the legality check, calls the transport's wire writer,
|
|
398
|
+
* then updates the state and the ack trace. Each transport binds `TMessage` to its own created-message
|
|
399
|
+
* type and supplies the writers.
|
|
400
|
+
*
|
|
401
|
+
* @throws A **SeedcordError** when you call a verb the current ack state doesn't allow. It throws before any transport call.
|
|
403
402
|
*/
|
|
404
403
|
var BaseReplySender = class {
|
|
405
404
|
telemetry;
|
|
@@ -741,14 +740,16 @@ function scopeValue(ctx, per) {
|
|
|
741
740
|
}
|
|
742
741
|
/**
|
|
743
742
|
* Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, and a string is
|
|
744
|
-
* a duration like `30m` or `24h`.
|
|
745
|
-
*
|
|
743
|
+
* a duration like `30m` or `24h`. The slot is charged in commit, only after the whole gate set passes,
|
|
744
|
+
* so a later refusal never burns the cooldown.
|
|
746
745
|
* That split also means two requests racing the same key can both pass before either charges the slot.
|
|
747
746
|
* The key combines the handler's route with the window settings, keeping two different handlers on separate
|
|
748
747
|
* windows. Reword the refusal with {@link CooldownOptions.message} or replace it with {@link CooldownOptions.notice}.
|
|
749
748
|
*
|
|
750
|
-
* @param duration - A number is seconds, and a string is a duration like `30m` or `24h`.
|
|
749
|
+
* @param duration - A number is seconds, and a string is a duration like `30m` or `24h`.
|
|
751
750
|
* @param options - Sets the scope with `per`, the uses per window with `limit`, and the refusal text with `message` or `notice`.
|
|
751
|
+
* @throws A **SeedcordTypeError** when `duration` is a string that doesn't parse.
|
|
752
|
+
* @throws A **SeedcordRangeError** when `duration` is zero or negative.
|
|
752
753
|
*
|
|
753
754
|
* @see the `@Gated` decorator from your transport package
|
|
754
755
|
* @see {@link IRateLimiter}
|
|
@@ -791,7 +792,7 @@ function Cooldown(duration, options) {
|
|
|
791
792
|
if (parsed === null) throw new SeedcordTypeError(SeedcordErrorCode.GateInvalidCooldownDuration, [duration]);
|
|
792
793
|
windowMs = parsed;
|
|
793
794
|
}
|
|
794
|
-
if (windowMs <= 0) throw new
|
|
795
|
+
if (windowMs <= 0) throw new SeedcordRangeError(SeedcordErrorCode.GateInvalidCooldownDuration, [String(duration)]);
|
|
795
796
|
const per = options?.per ?? "user";
|
|
796
797
|
const window = options?.limit === void 0 ? { windowMs } : {
|
|
797
798
|
windowMs,
|
|
@@ -818,7 +819,7 @@ function Cooldown(duration, options) {
|
|
|
818
819
|
* The caller computes `permissions`, gateway off a discord.js role, member, or channel, and HTTP off the
|
|
819
820
|
* bitfield the interaction payload carries.
|
|
820
821
|
*
|
|
821
|
-
* @throws A {@link Notice}
|
|
822
|
+
* @throws A {@link Notice} when the check refuses. It lists the missing or present permissions.
|
|
822
823
|
*
|
|
823
824
|
* @example
|
|
824
825
|
* ```ts
|
|
@@ -917,26 +918,6 @@ function mergeRoles(current, add, remove) {
|
|
|
917
918
|
return [...new Set(current).union(new Set(add)).difference(new Set(remove))];
|
|
918
919
|
}
|
|
919
920
|
|
|
920
|
-
//#endregion
|
|
921
|
-
//#region src/miscellaneous/ResolvedEmoji.ts
|
|
922
|
-
/**
|
|
923
|
-
* A resolved custom emoji. Renders as `<:name:id>` in message content, or `<a:name:id>` when animated,
|
|
924
|
-
* and passes straight to a builder's `setEmoji`.
|
|
925
|
-
*/
|
|
926
|
-
var ResolvedEmoji = class {
|
|
927
|
-
name;
|
|
928
|
-
id;
|
|
929
|
-
animated;
|
|
930
|
-
constructor(name, id, animated = false) {
|
|
931
|
-
this.name = name;
|
|
932
|
-
this.id = id;
|
|
933
|
-
this.animated = animated;
|
|
934
|
-
}
|
|
935
|
-
toString() {
|
|
936
|
-
return `<${this.animated ? "a" : ""}:${this.name}:${this.id}>`;
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
|
|
940
921
|
//#endregion
|
|
941
922
|
//#region src/pagination/paginate.ts
|
|
942
923
|
/**
|
|
@@ -946,7 +927,7 @@ var ResolvedEmoji = class {
|
|
|
946
927
|
* @param page - The requested zero-based page, clamped into `[0, totalPages - 1]`.
|
|
947
928
|
* @param perPage - The page size. Must be a positive integer.
|
|
948
929
|
* @returns The sliced {@link PageView}, with `totalPages` always known.
|
|
949
|
-
* @throws SeedcordRangeError when `perPage` is not a positive integer.
|
|
930
|
+
* @throws A **SeedcordRangeError** when `perPage` is not a positive integer.
|
|
950
931
|
*/
|
|
951
932
|
function paginate(items, page, perPage) {
|
|
952
933
|
if (!Number.isSafeInteger(perPage) || perPage <= 0) throw new SeedcordRangeError(SeedcordErrorCode.PaginationInvalidPerPage, [perPage]);
|
|
@@ -1020,8 +1001,7 @@ var Controls = class {
|
|
|
1020
1001
|
};
|
|
1021
1002
|
}
|
|
1022
1003
|
row(...keys) {
|
|
1023
|
-
if (keys.length === 0) throw new SeedcordRangeError(SeedcordErrorCode.
|
|
1024
|
-
if (keys.length > MAX_BUTTONS_PER_ROW) throw new SeedcordRangeError(SeedcordErrorCode.PaginationTooManyControls, [keys.length]);
|
|
1004
|
+
if (keys.length === 0 || keys.length > MAX_BUTTONS_PER_ROW) throw new SeedcordRangeError(SeedcordErrorCode.PaginationControlCount, [keys.length, MAX_BUTTONS_PER_ROW]);
|
|
1025
1005
|
const seen = /* @__PURE__ */ new Set();
|
|
1026
1006
|
for (const key of keys) {
|
|
1027
1007
|
if (seen.has(key)) throw new SeedcordTypeError(SeedcordErrorCode.PaginationDuplicateControls, [key]);
|
|
@@ -1169,7 +1149,7 @@ var CursorSourceBase = class {
|
|
|
1169
1149
|
//#endregion
|
|
1170
1150
|
//#region src/index.ts
|
|
1171
1151
|
/** Package version */
|
|
1172
|
-
const version = "0.
|
|
1152
|
+
const version = "0.11.0-next.0";
|
|
1173
1153
|
|
|
1174
1154
|
//#endregion
|
|
1175
1155
|
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 };
|