@sapphire/plugin-subcommands 7.0.2-next.83d2d44 → 7.0.2-next.84dd7bb
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +28 -28
- package/dist/cjs/lib/types/Events.cjs.map +1 -1
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs +2 -2
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs.map +1 -1
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/cjs/register.d.cts +1 -1
- package/dist/esm/index.d.mts +28 -28
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/types/Events.mjs.map +1 -1
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs +2 -2
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs.map +1 -1
- package/dist/esm/register.d.mts +1 -1
- package/dist/esm/register.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var subcommandCooldown_cjs__namespace = /*#__PURE__*/_interopNamespace(subcomman
|
|
|
33
33
|
var SubcommandPreconditions = {
|
|
34
34
|
PluginSubcommandCooldown: PluginSubcommandCooldown_cjs.PluginPrecondition
|
|
35
35
|
};
|
|
36
|
-
var version = "7.0.2-next.
|
|
36
|
+
var version = "7.0.2-next.84dd7bb";
|
|
37
37
|
|
|
38
38
|
Object.defineProperty(exports, "PluginSubcommandCooldownPrecondition", {
|
|
39
39
|
enumerable: true,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["PluginSubcommandCooldown"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,IAAM,uBAAA,GAA0B;AAAA,4BACtCA;AACD;AAoBO,IAAM,OAAA,GAAkB","file":"index.cjs","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.2-next.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":["PluginSubcommandCooldown"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,IAAM,uBAAA,GAA0B;AAAA,4BACtCA;AACD;AAoBO,IAAM,OAAA,GAAkB","file":"index.cjs","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.2-next.84dd7bb';\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _sapphire_framework from '@sapphire/framework';
|
|
2
|
-
import { Command, Args, PreconditionContainerArray, MessageCommand, ChatInputCommand,
|
|
2
|
+
import { Command, Args, PreconditionContainerArray, MessageCommand, ChatInputCommand, BucketScope, UserError, ChatInputCommandContext, MessageCommandDeniedPayload, CooldownOptions, AllFlowsPrecondition, CorePreconditions } from '@sapphire/framework';
|
|
3
3
|
import { Message, CacheType, ChatInputCommandInteraction, ContextMenuCommandInteraction } from 'discord.js';
|
|
4
4
|
import { RateLimitManager } from '@sapphire/ratelimits';
|
|
5
5
|
|
|
@@ -169,33 +169,6 @@ declare namespace Subcommand {
|
|
|
169
169
|
type Registry = Command.Registry;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
/**
|
|
173
|
-
* The context for the subcommand cooldown precondition
|
|
174
|
-
* @since 5.1.0
|
|
175
|
-
*/
|
|
176
|
-
interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {
|
|
177
|
-
/** The name of the subcommand */
|
|
178
|
-
subcommandMethodName: string;
|
|
179
|
-
/** The name of the subcommand group, if any */
|
|
180
|
-
subcommandGroupName?: string;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate
|
|
184
|
-
* bucket as well as resolving the id differently to ensure it is specific to a subcommand.
|
|
185
|
-
* @since 5.1.0
|
|
186
|
-
*/
|
|
187
|
-
declare class PluginPrecondition extends AllFlowsPrecondition {
|
|
188
|
-
subcommandBuckets: WeakMap<Subcommand<_sapphire_framework.Args, SubcommandOptions>, RateLimitManager<string>>;
|
|
189
|
-
messageRun(message: Message, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
190
|
-
chatInputRun(interaction: ChatInputCommandInteraction, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
191
|
-
contextMenuRun(interaction: ContextMenuCommandInteraction, subcommand: Command, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
192
|
-
private sharedRun;
|
|
193
|
-
private getIdFromMessage;
|
|
194
|
-
private getIdFromInteraction;
|
|
195
|
-
private getSubcommandMappingName;
|
|
196
|
-
private getManager;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
172
|
/** The options for adding this subcommand cooldown precondition */
|
|
200
173
|
interface ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> {
|
|
201
174
|
/** The command to parse cooldowns for. */
|
|
@@ -356,6 +329,33 @@ declare function loadListeners(): void;
|
|
|
356
329
|
|
|
357
330
|
declare function loadPreconditions(): void;
|
|
358
331
|
|
|
332
|
+
/**
|
|
333
|
+
* The context for the subcommand cooldown precondition
|
|
334
|
+
* @since 5.1.0
|
|
335
|
+
*/
|
|
336
|
+
interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {
|
|
337
|
+
/** The name of the subcommand */
|
|
338
|
+
subcommandMethodName: string;
|
|
339
|
+
/** The name of the subcommand group, if any */
|
|
340
|
+
subcommandGroupName?: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate
|
|
344
|
+
* bucket as well as resolving the id differently to ensure it is specific to a subcommand.
|
|
345
|
+
* @since 5.1.0
|
|
346
|
+
*/
|
|
347
|
+
declare class PluginPrecondition extends AllFlowsPrecondition {
|
|
348
|
+
subcommandBuckets: WeakMap<Subcommand<_sapphire_framework.Args, SubcommandOptions>, RateLimitManager<string>>;
|
|
349
|
+
messageRun(message: Message, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
350
|
+
chatInputRun(interaction: ChatInputCommandInteraction, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
351
|
+
contextMenuRun(interaction: ContextMenuCommandInteraction, subcommand: Command, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
352
|
+
private sharedRun;
|
|
353
|
+
private getIdFromMessage;
|
|
354
|
+
private getIdFromInteraction;
|
|
355
|
+
private getSubcommandMappingName;
|
|
356
|
+
private getManager;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
359
|
declare module 'discord.js' {
|
|
360
360
|
interface ClientOptions {
|
|
361
361
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,sBAAA,GAAyB;AAAA,EACrC,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,0BAAA,EAA4B,4BAAA;AAAA,EAE5B,uBAAA,EAAyB,yBAAA;AAAA,EACzB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,wBAAA,EAA0B,0BAAA;AAAA,EAE1B,+CAAA,EAAiD,iDAAA;AAAA,EACjD,iDAAA,EAAmD;AACpD;AAEO,IAAK,2BAAA,qBAAAA,4BAAAA,KAAL;AACN,EAAAA,6BAAA,0BAAA,CAAA,GAA2B,0BAAA;AAC3B,EAAAA,6BAAA,4BAAA,CAAA,GAA6B,4BAAA;AAC7B,EAAAA,6BAAA,oBAAA,CAAA,GAAqB,oBAAA;AAHV,EAAA,OAAAA,4BAAAA;AAAA,CAAA,EAAA,2BAAA,IAAA,EAAA","file":"Events.cjs","sourcesContent":["import type { Args, ChatInputCommand, ChatInputCommandContext, MessageCommand, MessageCommandDeniedPayload, UserError } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport type { Subcommand } from '../Subcommand';\nimport type { ChatInputCommandSubcommandMappingMethod, MessageSubcommandMappingMethod, SubcommandMappingMethod } from './SubcommandMappings';\n\nexport const SubcommandPluginEvents = {\n\tChatInputSubcommandDenied: 'chatInputSubcommandDenied' as const,\n\tChatInputSubcommandRun: 'chatInputSubcommandRun' as const,\n\tChatInputSubcommandSuccess: 'chatInputSubcommandSuccess' as const,\n\tChatInputSubcommandError: 'chatInputSubcommandError' as const,\n\tChatInputSubcommandNoMatch: 'chatInputSubcommandNoMatch' as const,\n\n\tMessageSubcommandDenied: 'messageSubcommandDenied' as const,\n\tMessageSubcommandRun: 'messageSubcommandRun' as const,\n\tMessageSubcommandSuccess: 'messageSubcommandSuccess' as const,\n\tMessageSubcommandError: 'messageSubcommandError' as const,\n\tMessageSubcommandNoMatch: 'messageSubcommandNoMatch' as const,\n\n\tSubcommandMappingIsMissingMessageCommandHandler: 'subcommandMappingIsMissingMessageCommandHandler' as const,\n\tSubcommandMappingIsMissingChatInputCommandHandler: 'subcommandMappingIsMissingChatInputCommandHandler' as const\n};\n\nexport enum SubcommandPluginIdentifiers {\n\tMessageSubcommandNoMatch = 'messageSubcommandNoMatch',\n\tChatInputSubcommandNoMatch = 'chatInputSubcommandNoMatch',\n\tSubcommandNotFound = 'subcommandNotFound'\n}\n\nexport interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch;\n\tmessage: string;\n\tpossibleSubcommandName: string | null;\n\tpossibleSubcommandGroupOrName: string | null;\n}\n\nexport interface ChatInputSubcommandNoMatchContext extends ChatInputCommandContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch;\n\tmessage: string;\n}\n\nexport interface IMessageSubcommandPayload {\n\tmessage: Message;\n\tcommand: Subcommand;\n}\n\nexport interface MessageSubcommandDeniedPayload\n\textends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,sBAAA,GAAyB;AAAA,EACrC,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,0BAAA,EAA4B,4BAAA;AAAA,EAE5B,uBAAA,EAAyB,yBAAA;AAAA,EACzB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,wBAAA,EAA0B,0BAAA;AAAA,EAE1B,+CAAA,EAAiD,iDAAA;AAAA,EACjD,iDAAA,EAAmD;AACpD;AAEO,IAAK,2BAAA,qBAAAA,4BAAAA,KAAL;AACN,EAAAA,6BAAA,0BAAA,CAAA,GAA2B,0BAAA;AAC3B,EAAAA,6BAAA,4BAAA,CAAA,GAA6B,4BAAA;AAC7B,EAAAA,6BAAA,oBAAA,CAAA,GAAqB,oBAAA;AAHV,EAAA,OAAAA,4BAAAA;AAAA,CAAA,EAAA,2BAAA,IAAA,EAAA","file":"Events.cjs","sourcesContent":["import type { Args, ChatInputCommand, ChatInputCommandContext, MessageCommand, MessageCommandDeniedPayload, UserError } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport type { Subcommand } from '../Subcommand';\nimport type { ChatInputCommandSubcommandMappingMethod, MessageSubcommandMappingMethod, SubcommandMappingMethod } from './SubcommandMappings';\n\nexport const SubcommandPluginEvents = {\n\tChatInputSubcommandDenied: 'chatInputSubcommandDenied' as const,\n\tChatInputSubcommandRun: 'chatInputSubcommandRun' as const,\n\tChatInputSubcommandSuccess: 'chatInputSubcommandSuccess' as const,\n\tChatInputSubcommandError: 'chatInputSubcommandError' as const,\n\tChatInputSubcommandNoMatch: 'chatInputSubcommandNoMatch' as const,\n\n\tMessageSubcommandDenied: 'messageSubcommandDenied' as const,\n\tMessageSubcommandRun: 'messageSubcommandRun' as const,\n\tMessageSubcommandSuccess: 'messageSubcommandSuccess' as const,\n\tMessageSubcommandError: 'messageSubcommandError' as const,\n\tMessageSubcommandNoMatch: 'messageSubcommandNoMatch' as const,\n\n\tSubcommandMappingIsMissingMessageCommandHandler: 'subcommandMappingIsMissingMessageCommandHandler' as const,\n\tSubcommandMappingIsMissingChatInputCommandHandler: 'subcommandMappingIsMissingChatInputCommandHandler' as const\n};\n\nexport enum SubcommandPluginIdentifiers {\n\tMessageSubcommandNoMatch = 'messageSubcommandNoMatch',\n\tChatInputSubcommandNoMatch = 'chatInputSubcommandNoMatch',\n\tSubcommandNotFound = 'subcommandNotFound'\n}\n\nexport interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch;\n\tmessage: string;\n\tpossibleSubcommandName: string | null;\n\tpossibleSubcommandGroupOrName: string | null;\n}\n\nexport interface ChatInputSubcommandNoMatchContext extends ChatInputCommandContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch;\n\tmessage: string;\n}\n\nexport interface IMessageSubcommandPayload {\n\tmessage: Message;\n\tcommand: Subcommand;\n}\n\nexport interface MessageSubcommandDeniedPayload\n\textends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'>, MessageSubcommandAcceptedPayload {\n\tparameters?: string;\n}\n\nexport interface MessageSubcommandAcceptedPayload extends IMessageSubcommandPayload {\n\tcontext: MessageCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface MessageSubcommandRunPayload extends MessageSubcommandAcceptedPayload {}\n\nexport interface MessageSubcommandErrorPayload extends MessageSubcommandRunPayload {}\n\nexport interface MessageSubcommandSuccessPayload extends MessageSubcommandRunPayload {\n\tresult: unknown;\n}\n\nexport interface IChatInputSubcommandPayload {\n\tinteraction: ChatInputCommand.Interaction;\n\tcommand: Subcommand;\n}\n\nexport interface ChatInputSubcommandAcceptedPayload extends IChatInputSubcommandPayload {\n\tcontext: ChatInputCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface ChatInputSubcommandDeniedPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandRunPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandErrorPayload extends ChatInputSubcommandRunPayload {}\n\nexport interface ChatInputSubcommandSuccessPayload extends ChatInputSubcommandRunPayload {\n\tresult: unknown;\n}\n\ndeclare module 'discord.js' {\n\tinterface ClientEvents {\n\t\t[SubcommandPluginEvents.ChatInputSubcommandDenied]: [error: UserError, payload: ChatInputSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandRun]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandSuccess]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandError]: [error: unknown, payload: ChatInputSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandNoMatch]: [interaction: ChatInputCommand.Interaction, context: ChatInputSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.MessageSubcommandDenied]: [error: UserError, payload: MessageSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandRun]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandSuccess]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandError]: [error: unknown, payload: MessageSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandNoMatch]: [message: Message, args: Args, context: MessageSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandAcceptedPayload\n\t\t];\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler]: [\n\t\t\tmessage: ChatInputCommand.Interaction,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandAcceptedPayload\n\t\t];\n\t}\n}\n"]}
|
|
@@ -52,7 +52,7 @@ var _PluginPrecondition = class _PluginPrecondition extends framework.AllFlowsPr
|
|
|
52
52
|
case framework.BucketScope.Channel:
|
|
53
53
|
return `${message.channelId}.${subcommandIdentifier}`;
|
|
54
54
|
case framework.BucketScope.Guild:
|
|
55
|
-
return `${message.guildId}.${subcommandIdentifier}`
|
|
55
|
+
return message.guildId ? `${message.guildId}.${subcommandIdentifier}` : `${message.channelId}.${subcommandIdentifier}`;
|
|
56
56
|
default:
|
|
57
57
|
return `${message.author.id}.${subcommandIdentifier}`;
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ var _PluginPrecondition = class _PluginPrecondition extends framework.AllFlowsPr
|
|
|
65
65
|
case framework.BucketScope.Channel:
|
|
66
66
|
return `${interaction.channelId}.${subcommandIdentifier}`;
|
|
67
67
|
case framework.BucketScope.Guild:
|
|
68
|
-
return `${interaction.guildId}.${subcommandIdentifier}`
|
|
68
|
+
return interaction.guildId ? `${interaction.guildId}.${subcommandIdentifier}` : `${interaction.channelId}.${subcommandIdentifier}`;
|
|
69
69
|
default:
|
|
70
70
|
return `${interaction.user.id}.${subcommandIdentifier}`;
|
|
71
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/preconditions/PluginSubcommandCooldown.ts"],"names":["AllFlowsPrecondition","time","TimestampStyles","SubcommandIdentifiers","BucketSc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+
{"version":3,"sources":["../../../src/preconditions/PluginSubcommandCooldown.ts"],"names":["AllFlowsPrecondition","time","TimestampStyles","SubcommandIdentifiers","BucketScope","RateLimitManager"],"mappings":";;;;;;;;;;;;AA6BO,IAAM,mBAAA,GAAN,MAAM,mBAAA,SAA2BA,8BAAA,CAAqB;AAAA,EAAtD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACN,IAAA,aAAA,CAAA,IAAA,EAAO,mBAAA,sBAAwB,OAAA,EAA8C,CAAA;AAAA,EAAA;AAAA,EAE7D,UAAA,CACf,OAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,gBAAA,CAAiB,OAAA,EAAS,OAAO,CAAA;AAEzD,IAAA,OAAO,IAAA,CAAK,UAAU,OAAA,CAAQ,MAAA,CAAO,IAAI,UAAA,EAAY,OAAA,EAAS,YAAY,SAAS,CAAA;AAAA,EACpF;AAAA,EAEgB,YAAA,CACf,WAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,oBAAA,CAAqB,WAAA,EAAa,OAAO,CAAA;AAEjE,IAAA,OAAO,IAAA,CAAK,UAAU,WAAA,CAAY,IAAA,CAAK,IAAI,UAAA,EAAY,OAAA,EAAS,YAAY,YAAY,CAAA;AAAA,EACzF;AAAA,EAEgB,cAAA,CACf,WAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,oBAAA,CAAqB,WAAA,EAAa,OAAO,CAAA;AAEjE,IAAA,OAAO,IAAA,CAAK,UAAU,WAAA,CAAY,IAAA,CAAK,IAAI,UAAA,EAA0B,OAAA,EAAS,YAAY,cAAc,CAAA;AAAA,EACzG;AAAA,EAEQ,SAAA,CACP,QAAA,EACA,UAAA,EACA,OAAA,EACA,YACA,WAAA,EAC8B;AAE9B,IAAA,IAAI,OAAA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CAAW,YAAwB,OAAA,EAAsD;AAChG,IAAA,IAAI,OAAA,GAAU,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,UAAU,CAAA;AACnD,IAAA,IAAI,CAAC,OAAA,EAAS;AACb,MAAA,OAAA,GAAU,IAAIC,2BAAA,CAAiB,OAAA,CAAQ,KAAA,EAAO,QAAQ,KAAK,CAAA;AAC3D,MAAA,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,UAAA,EAAY,OAAO,CAAA;AAAA,IAC/C;AACA,IAAA,OAAO,OAAA;AAAA,EACR;AACD,CAAA;AA1G6D,MAAA,CAAA,mBAAA,EAAA,oBAAA,CAAA;AAAtD,IAAM,kBAAA,GAAN","file":"PluginSubcommandCooldown.cjs","sourcesContent":["import { AllFlowsPrecondition, BucketScope, Command, CorePreconditions } from '@sapphire/framework';\nimport { RateLimitManager } from '@sapphire/ratelimits';\nimport {\n\tTimestampStyles,\n\ttime,\n\ttype ChatInputCommandInteraction,\n\ttype CommandInteraction,\n\ttype ContextMenuCommandInteraction,\n\ttype Message\n} from 'discord.js';\nimport { Subcommand } from '../lib/Subcommand';\nimport { SubcommandIdentifiers } from '../lib/types/Enums';\n\n/**\n * The context for the subcommand cooldown precondition\n * @since 5.1.0\n */\nexport interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {\n\t/** The name of the subcommand */\n\tsubcommandMethodName: string;\n\t/** The name of the subcommand group, if any */\n\tsubcommandGroupName?: string;\n}\n\n/**\n * The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate\n * bucket as well as resolving the id differently to ensure it is specific to a subcommand.\n * @since 5.1.0\n */\nexport class PluginPrecondition extends AllFlowsPrecondition {\n\tpublic subcommandBuckets = new WeakMap<Subcommand, RateLimitManager<string>>();\n\n\tpublic override messageRun(\n\t\tmessage: Message,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromMessage(message, context);\n\n\t\treturn this.sharedRun(message.author.id, subcommand, context, cooldownId, 'message');\n\t}\n\n\tpublic override chatInputRun(\n\t\tinteraction: ChatInputCommandInteraction,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromInteraction(interaction, context);\n\n\t\treturn this.sharedRun(interaction.user.id, subcommand, context, cooldownId, 'chat input');\n\t}\n\n\tpublic override contextMenuRun(\n\t\tinteraction: ContextMenuCommandInteraction,\n\t\tsubcommand: Command,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromInteraction(interaction, context);\n\n\t\treturn this.sharedRun(interaction.user.id, subcommand as Subcommand, context, cooldownId, 'context menu');\n\t}\n\n\tprivate sharedRun(\n\t\tauthorId: string,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext,\n\t\tcooldownId: string,\n\t\tcommandType: string\n\t): AllFlowsPrecondition.Result {\n\t\t// If the subcommand it is testing for is not this one, return ok:\n\t\tif (context.external) return this.ok();\n\n\t\t// If there is no delay (undefined, null, 0), return ok:\n\t\tif (!context.delay) return this.ok();\n\n\t\t// If the user has provided any filtered users and the authorId is in that array, return ok:\n\t\tif (context.filteredUsers?.includes(authorId)) return this.ok();\n\n\t\tconst rateLimit = this.getManager(subcommand, context).acquire(cooldownId);\n\n\t\tif (rateLimit.limited) {\n\t\t\tconst remaining = rateLimit.remainingTime;\n\n\t\t\tconst nextAvailable = time(Math.floor(rateLimit.expires / 1000), TimestampStyles.RelativeTime);\n\t\t\treturn this.error({\n\t\t\t\tidentifier: SubcommandIdentifiers.SubcommandPreconditionCooldown,\n\t\t\t\tmessage: `There is a cooldown in effect for this ${commandType} subcommand. It'll be available ${nextAvailable}.`,\n\t\t\t\tcontext: { remaining }\n\t\t\t});\n\t\t}\n\n\t\trateLimit.consume();\n\t\treturn this.ok();\n\t}\n\n\tprivate getIdFromMessage(message: Message, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tconst subcommandIdentifier = this.getSubcommandMappingName(context);\n\t\tswitch (context.scope) {\n\t\t\tcase BucketScope.Global:\n\t\t\t\treturn `global.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Channel:\n\t\t\t\treturn `${message.channelId}.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Guild:\n\t\t\t\treturn message.guildId ? `${message.guildId}.${subcommandIdentifier}` : `${message.channelId}.${subcommandIdentifier}`;\n\t\t\tdefault:\n\t\t\t\treturn `${message.author.id}.${subcommandIdentifier}`;\n\t\t}\n\t}\n\n\tprivate getIdFromInteraction(interaction: CommandInteraction, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tconst subcommandIdentifier = this.getSubcommandMappingName(context);\n\t\tswitch (context.scope) {\n\t\t\tcase BucketScope.Global:\n\t\t\t\treturn `global.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Channel:\n\t\t\t\treturn `${interaction.channelId}.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Guild:\n\t\t\t\treturn interaction.guildId ? `${interaction.guildId}.${subcommandIdentifier}` : `${interaction.channelId}.${subcommandIdentifier}`;\n\t\t\tdefault:\n\t\t\t\treturn `${interaction.user.id}.${subcommandIdentifier}`;\n\t\t}\n\t}\n\n\tprivate getSubcommandMappingName(context: PluginSubcommandCooldownPreconditionContext) {\n\t\treturn context.subcommandGroupName ? `${context.subcommandGroupName}.${context.subcommandMethodName}` : context.subcommandMethodName;\n\t}\n\n\tprivate getManager(subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tlet manager = this.subcommandBuckets.get(subcommand);\n\t\tif (!manager) {\n\t\t\tmanager = new RateLimitManager(context.delay, context.limit);\n\t\t\tthis.subcommandBuckets.set(subcommand, manager);\n\t\t}\n\t\treturn manager;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":["Plugin","postInitialization","loadPreconditions","loadListeners","SapphireClient"],"mappings":";;;;;;;AASO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0BA,gBAAA,CAAO;AAAA;AAAA;AAAA;AAAA,EAI7C,
|
|
1
|
+
{"version":3,"sources":["../../src/register.ts"],"names":["Plugin","postInitialization","loadPreconditions","loadListeners","SapphireClient"],"mappings":";;;;;;;AASO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0BA,gBAAA,CAAO;AAAA;AAAA;AAAA;AAAA,EAI7C,QAAwBC,4BAAkB,CAAA,CAAwB,OAAA,EAA8B;AAC/F,IAAAC,2BAAA,EAAkB;AAElB,IAAA,IAAI,OAAA,CAAQ,iCAAiC,KAAA,EAAO;AACnD,MAAAC,uBAAA,EAAc;AAAA,IACf;AAAA,EACD;AACD,CAAA;AAX8C,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA;AAAvC,IAAM,iBAAA,GAAN;AAaPC,wBAAA,CAAe,OAAA,CAAQ,8BAAA,CAA+B,iBAAA,CAAkBH,4BAAkB,GAAG,+BAA+B,CAAA","file":"register.cjs","sourcesContent":["import './index';\n\nimport { Plugin, postInitialization, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { loadListeners, loadPreconditions } from './index';\n\n/**\n * @since 3.1.2\n */\nexport class SubcommandsPlugin extends Plugin {\n\t/**\n\t * @since 3.1.2\n\t */\n\tpublic static override [postInitialization](this: SapphireClient, options: ClientOptions): void {\n\t\tloadPreconditions();\n\n\t\tif (options.loadSubcommandErrorListeners !== false) {\n\t\t\tloadListeners();\n\t\t}\n\t}\n}\n\nSapphireClient.plugins.registerPostInitializationHook(SubcommandsPlugin[postInitialization], 'Subcommand-PostInitialization');\n"]}
|
package/dist/cjs/register.d.cts
CHANGED
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _sapphire_framework from '@sapphire/framework';
|
|
2
|
-
import { Command, Args, PreconditionContainerArray, MessageCommand, ChatInputCommand,
|
|
2
|
+
import { Command, Args, PreconditionContainerArray, MessageCommand, ChatInputCommand, BucketScope, UserError, ChatInputCommandContext, MessageCommandDeniedPayload, CooldownOptions, AllFlowsPrecondition, CorePreconditions } from '@sapphire/framework';
|
|
3
3
|
import { Message, CacheType, ChatInputCommandInteraction, ContextMenuCommandInteraction } from 'discord.js';
|
|
4
4
|
import { RateLimitManager } from '@sapphire/ratelimits';
|
|
5
5
|
|
|
@@ -169,33 +169,6 @@ declare namespace Subcommand {
|
|
|
169
169
|
type Registry = Command.Registry;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
/**
|
|
173
|
-
* The context for the subcommand cooldown precondition
|
|
174
|
-
* @since 5.1.0
|
|
175
|
-
*/
|
|
176
|
-
interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {
|
|
177
|
-
/** The name of the subcommand */
|
|
178
|
-
subcommandMethodName: string;
|
|
179
|
-
/** The name of the subcommand group, if any */
|
|
180
|
-
subcommandGroupName?: string;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate
|
|
184
|
-
* bucket as well as resolving the id differently to ensure it is specific to a subcommand.
|
|
185
|
-
* @since 5.1.0
|
|
186
|
-
*/
|
|
187
|
-
declare class PluginPrecondition extends AllFlowsPrecondition {
|
|
188
|
-
subcommandBuckets: WeakMap<Subcommand<_sapphire_framework.Args, SubcommandOptions>, RateLimitManager<string>>;
|
|
189
|
-
messageRun(message: Message, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
190
|
-
chatInputRun(interaction: ChatInputCommandInteraction, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
191
|
-
contextMenuRun(interaction: ContextMenuCommandInteraction, subcommand: Command, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
192
|
-
private sharedRun;
|
|
193
|
-
private getIdFromMessage;
|
|
194
|
-
private getIdFromInteraction;
|
|
195
|
-
private getSubcommandMappingName;
|
|
196
|
-
private getManager;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
172
|
/** The options for adding this subcommand cooldown precondition */
|
|
200
173
|
interface ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> {
|
|
201
174
|
/** The command to parse cooldowns for. */
|
|
@@ -356,6 +329,33 @@ declare function loadListeners(): void;
|
|
|
356
329
|
|
|
357
330
|
declare function loadPreconditions(): void;
|
|
358
331
|
|
|
332
|
+
/**
|
|
333
|
+
* The context for the subcommand cooldown precondition
|
|
334
|
+
* @since 5.1.0
|
|
335
|
+
*/
|
|
336
|
+
interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {
|
|
337
|
+
/** The name of the subcommand */
|
|
338
|
+
subcommandMethodName: string;
|
|
339
|
+
/** The name of the subcommand group, if any */
|
|
340
|
+
subcommandGroupName?: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate
|
|
344
|
+
* bucket as well as resolving the id differently to ensure it is specific to a subcommand.
|
|
345
|
+
* @since 5.1.0
|
|
346
|
+
*/
|
|
347
|
+
declare class PluginPrecondition extends AllFlowsPrecondition {
|
|
348
|
+
subcommandBuckets: WeakMap<Subcommand<_sapphire_framework.Args, SubcommandOptions>, RateLimitManager<string>>;
|
|
349
|
+
messageRun(message: Message, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
350
|
+
chatInputRun(interaction: ChatInputCommandInteraction, subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
351
|
+
contextMenuRun(interaction: ContextMenuCommandInteraction, subcommand: Command, context: PluginSubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
352
|
+
private sharedRun;
|
|
353
|
+
private getIdFromMessage;
|
|
354
|
+
private getIdFromInteraction;
|
|
355
|
+
private getSubcommandMappingName;
|
|
356
|
+
private getManager;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
359
|
declare module 'discord.js' {
|
|
360
360
|
interface ClientOptions {
|
|
361
361
|
/**
|
package/dist/esm/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export { loadPreconditions } from './preconditions/_load.mjs';
|
|
|
13
13
|
var SubcommandPreconditions = {
|
|
14
14
|
PluginSubcommandCooldown: PluginPrecondition
|
|
15
15
|
};
|
|
16
|
-
var version = "7.0.2-next.
|
|
16
|
+
var version = "7.0.2-next.84dd7bb";
|
|
17
17
|
|
|
18
18
|
export { SubcommandPreconditions, version };
|
|
19
19
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["PluginSubcommandCooldown"],"mappings":";;;;;;;;;;;;AAoDO,IAAM,uBAAA,GAA0B;AAAA,4BACtCA;AACD;AAoBO,IAAM,OAAA,GAAkB","file":"index.mjs","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.2-next.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":["PluginSubcommandCooldown"],"mappings":";;;;;;;;;;;;AAoDO,IAAM,uBAAA,GAA0B;AAAA,4BACtCA;AACD;AAoBO,IAAM,OAAA,GAAkB","file":"index.mjs","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '7.0.2-next.84dd7bb';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,sBAAA,GAAyB;AAAA,EACrC,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,0BAAA,EAA4B,4BAAA;AAAA,EAE5B,uBAAA,EAAyB,yBAAA;AAAA,EACzB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,wBAAA,EAA0B,0BAAA;AAAA,EAE1B,+CAAA,EAAiD,iDAAA;AAAA,EACjD,iDAAA,EAAmD;AACpD;AAEO,IAAK,2BAAA,qBAAAA,4BAAAA,KAAL;AACN,EAAAA,6BAAA,0BAAA,CAAA,GAA2B,0BAAA;AAC3B,EAAAA,6BAAA,4BAAA,CAAA,GAA6B,4BAAA;AAC7B,EAAAA,6BAAA,oBAAA,CAAA,GAAqB,oBAAA;AAHV,EAAA,OAAAA,4BAAAA;AAAA,CAAA,EAAA,2BAAA,IAAA,EAAA","file":"Events.mjs","sourcesContent":["import type { Args, ChatInputCommand, ChatInputCommandContext, MessageCommand, MessageCommandDeniedPayload, UserError } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport type { Subcommand } from '../Subcommand';\nimport type { ChatInputCommandSubcommandMappingMethod, MessageSubcommandMappingMethod, SubcommandMappingMethod } from './SubcommandMappings';\n\nexport const SubcommandPluginEvents = {\n\tChatInputSubcommandDenied: 'chatInputSubcommandDenied' as const,\n\tChatInputSubcommandRun: 'chatInputSubcommandRun' as const,\n\tChatInputSubcommandSuccess: 'chatInputSubcommandSuccess' as const,\n\tChatInputSubcommandError: 'chatInputSubcommandError' as const,\n\tChatInputSubcommandNoMatch: 'chatInputSubcommandNoMatch' as const,\n\n\tMessageSubcommandDenied: 'messageSubcommandDenied' as const,\n\tMessageSubcommandRun: 'messageSubcommandRun' as const,\n\tMessageSubcommandSuccess: 'messageSubcommandSuccess' as const,\n\tMessageSubcommandError: 'messageSubcommandError' as const,\n\tMessageSubcommandNoMatch: 'messageSubcommandNoMatch' as const,\n\n\tSubcommandMappingIsMissingMessageCommandHandler: 'subcommandMappingIsMissingMessageCommandHandler' as const,\n\tSubcommandMappingIsMissingChatInputCommandHandler: 'subcommandMappingIsMissingChatInputCommandHandler' as const\n};\n\nexport enum SubcommandPluginIdentifiers {\n\tMessageSubcommandNoMatch = 'messageSubcommandNoMatch',\n\tChatInputSubcommandNoMatch = 'chatInputSubcommandNoMatch',\n\tSubcommandNotFound = 'subcommandNotFound'\n}\n\nexport interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch;\n\tmessage: string;\n\tpossibleSubcommandName: string | null;\n\tpossibleSubcommandGroupOrName: string | null;\n}\n\nexport interface ChatInputSubcommandNoMatchContext extends ChatInputCommandContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch;\n\tmessage: string;\n}\n\nexport interface IMessageSubcommandPayload {\n\tmessage: Message;\n\tcommand: Subcommand;\n}\n\nexport interface MessageSubcommandDeniedPayload\n\textends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,sBAAA,GAAyB;AAAA,EACrC,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,0BAAA,EAA4B,4BAAA;AAAA,EAC5B,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,0BAAA,EAA4B,4BAAA;AAAA,EAE5B,uBAAA,EAAyB,yBAAA;AAAA,EACzB,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,sBAAA,EAAwB,wBAAA;AAAA,EACxB,wBAAA,EAA0B,0BAAA;AAAA,EAE1B,+CAAA,EAAiD,iDAAA;AAAA,EACjD,iDAAA,EAAmD;AACpD;AAEO,IAAK,2BAAA,qBAAAA,4BAAAA,KAAL;AACN,EAAAA,6BAAA,0BAAA,CAAA,GAA2B,0BAAA;AAC3B,EAAAA,6BAAA,4BAAA,CAAA,GAA6B,4BAAA;AAC7B,EAAAA,6BAAA,oBAAA,CAAA,GAAqB,oBAAA;AAHV,EAAA,OAAAA,4BAAAA;AAAA,CAAA,EAAA,2BAAA,IAAA,EAAA","file":"Events.mjs","sourcesContent":["import type { Args, ChatInputCommand, ChatInputCommandContext, MessageCommand, MessageCommandDeniedPayload, UserError } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport type { Subcommand } from '../Subcommand';\nimport type { ChatInputCommandSubcommandMappingMethod, MessageSubcommandMappingMethod, SubcommandMappingMethod } from './SubcommandMappings';\n\nexport const SubcommandPluginEvents = {\n\tChatInputSubcommandDenied: 'chatInputSubcommandDenied' as const,\n\tChatInputSubcommandRun: 'chatInputSubcommandRun' as const,\n\tChatInputSubcommandSuccess: 'chatInputSubcommandSuccess' as const,\n\tChatInputSubcommandError: 'chatInputSubcommandError' as const,\n\tChatInputSubcommandNoMatch: 'chatInputSubcommandNoMatch' as const,\n\n\tMessageSubcommandDenied: 'messageSubcommandDenied' as const,\n\tMessageSubcommandRun: 'messageSubcommandRun' as const,\n\tMessageSubcommandSuccess: 'messageSubcommandSuccess' as const,\n\tMessageSubcommandError: 'messageSubcommandError' as const,\n\tMessageSubcommandNoMatch: 'messageSubcommandNoMatch' as const,\n\n\tSubcommandMappingIsMissingMessageCommandHandler: 'subcommandMappingIsMissingMessageCommandHandler' as const,\n\tSubcommandMappingIsMissingChatInputCommandHandler: 'subcommandMappingIsMissingChatInputCommandHandler' as const\n};\n\nexport enum SubcommandPluginIdentifiers {\n\tMessageSubcommandNoMatch = 'messageSubcommandNoMatch',\n\tChatInputSubcommandNoMatch = 'chatInputSubcommandNoMatch',\n\tSubcommandNotFound = 'subcommandNotFound'\n}\n\nexport interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch;\n\tmessage: string;\n\tpossibleSubcommandName: string | null;\n\tpossibleSubcommandGroupOrName: string | null;\n}\n\nexport interface ChatInputSubcommandNoMatchContext extends ChatInputCommandContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch;\n\tmessage: string;\n}\n\nexport interface IMessageSubcommandPayload {\n\tmessage: Message;\n\tcommand: Subcommand;\n}\n\nexport interface MessageSubcommandDeniedPayload\n\textends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'>, MessageSubcommandAcceptedPayload {\n\tparameters?: string;\n}\n\nexport interface MessageSubcommandAcceptedPayload extends IMessageSubcommandPayload {\n\tcontext: MessageCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface MessageSubcommandRunPayload extends MessageSubcommandAcceptedPayload {}\n\nexport interface MessageSubcommandErrorPayload extends MessageSubcommandRunPayload {}\n\nexport interface MessageSubcommandSuccessPayload extends MessageSubcommandRunPayload {\n\tresult: unknown;\n}\n\nexport interface IChatInputSubcommandPayload {\n\tinteraction: ChatInputCommand.Interaction;\n\tcommand: Subcommand;\n}\n\nexport interface ChatInputSubcommandAcceptedPayload extends IChatInputSubcommandPayload {\n\tcontext: ChatInputCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface ChatInputSubcommandDeniedPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandRunPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandErrorPayload extends ChatInputSubcommandRunPayload {}\n\nexport interface ChatInputSubcommandSuccessPayload extends ChatInputSubcommandRunPayload {\n\tresult: unknown;\n}\n\ndeclare module 'discord.js' {\n\tinterface ClientEvents {\n\t\t[SubcommandPluginEvents.ChatInputSubcommandDenied]: [error: UserError, payload: ChatInputSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandRun]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandSuccess]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandError]: [error: unknown, payload: ChatInputSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandNoMatch]: [interaction: ChatInputCommand.Interaction, context: ChatInputSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.MessageSubcommandDenied]: [error: UserError, payload: MessageSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandRun]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandSuccess]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandError]: [error: unknown, payload: MessageSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandNoMatch]: [message: Message, args: Args, context: MessageSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandAcceptedPayload\n\t\t];\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler]: [\n\t\t\tmessage: ChatInputCommand.Interaction,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandAcceptedPayload\n\t\t];\n\t}\n}\n"]}
|
|
@@ -47,7 +47,7 @@ var _PluginPrecondition = class _PluginPrecondition extends AllFlowsPrecondition
|
|
|
47
47
|
case BucketScope.Channel:
|
|
48
48
|
return `${message.channelId}.${subcommandIdentifier}`;
|
|
49
49
|
case BucketScope.Guild:
|
|
50
|
-
return `${message.guildId}.${subcommandIdentifier}`
|
|
50
|
+
return message.guildId ? `${message.guildId}.${subcommandIdentifier}` : `${message.channelId}.${subcommandIdentifier}`;
|
|
51
51
|
default:
|
|
52
52
|
return `${message.author.id}.${subcommandIdentifier}`;
|
|
53
53
|
}
|
|
@@ -60,7 +60,7 @@ var _PluginPrecondition = class _PluginPrecondition extends AllFlowsPrecondition
|
|
|
60
60
|
case BucketScope.Channel:
|
|
61
61
|
return `${interaction.channelId}.${subcommandIdentifier}`;
|
|
62
62
|
case BucketScope.Guild:
|
|
63
|
-
return `${interaction.guildId}.${subcommandIdentifier}`
|
|
63
|
+
return interaction.guildId ? `${interaction.guildId}.${subcommandIdentifier}` : `${interaction.channelId}.${subcommandIdentifier}`;
|
|
64
64
|
default:
|
|
65
65
|
return `${interaction.user.id}.${subcommandIdentifier}`;
|
|
66
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/preconditions/PluginSubcommandCooldown.ts"],"names":[],"mappings":";;;;;;;AA6BO,IAAM,mBAAA,GAAN,MAAM,mBAAA,SAA2B,oBAAA,CAAqB;AAAA,EAAtD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACN,IAAA,aAAA,CAAA,IAAA,EAAO,mBAAA,sBAAwB,OAAA,EAA8C,CAAA;AAAA,EAAA;AAAA,EAE7D,UAAA,CACf,OAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,gBAAA,CAAiB,OAAA,EAAS,OAAO,CAAA;AAEzD,IAAA,OAAO,IAAA,CAAK,UAAU,OAAA,CAAQ,MAAA,CAAO,IAAI,UAAA,EAAY,OAAA,EAAS,YAAY,SAAS,CAAA;AAAA,EACpF;AAAA,EAEgB,YAAA,CACf,WAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,oBAAA,CAAqB,WAAA,EAAa,OAAO,CAAA;AAEjE,IAAA,OAAO,IAAA,CAAK,UAAU,WAAA,CAAY,IAAA,CAAK,IAAI,UAAA,EAAY,OAAA,EAAS,YAAY,YAAY,CAAA;AAAA,EACzF;AAAA,EAEgB,cAAA,CACf,WAAA,EACA,UAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,oBAAA,CAAqB,WAAA,EAAa,OAAO,CAAA;AA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;AAAA,EAEQ,yBAAyB,OAAA,EAAsD;AACtF,IAAA,OAAO,OAAA,CAAQ,sBAAsB,CAAA,EAAG,OAAA,CAAQ,mBAAmB,CAAA,CAAA,EAAI,OAAA,CAAQ,oBAAoB,CAAA,CAAA,GAAK,OAAA,CAAQ,oBAAA;AAAA,EACjH;AAAA,EAEQ,UAAA,CAAW,YAAwB,OAAA,EAAsD;AAChG,IAAA,IAAI,OAAA,GAAU,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,UAAU,CAAA;AACnD,IAAA,IAAI,CAAC,OAAA,EAAS;AACb,MAAA,OAAA,GAAU,IAAI,gBAAA,CAAiB,OAAA,CAAQ,KAAA,EAAO,QAAQ,KAAK,CAAA;AAC3D,MAAA,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,UAAA,EAAY,OAAO,CAAA;AAAA,IAC/C;AACA,IAAA,OAAO,OAAA;AAAA,EACR;AACD,CAAA;AA1G6D,MAAA,CAAA,mBAAA,EAAA,oBAAA,CAAA;AAAtD,IAAM,kBAAA,GAAN","file":"PluginSubcommandCooldown.mjs","sourcesContent":["import { AllFlowsPrecondition, BucketScope, Command, CorePreconditions } from '@sapphire/framework';\nimport { RateLimitManager } from '@sapphire/ratelimits';\nimport {\n\tTimestampStyles,\n\ttime,\n\ttype ChatInputCommandInteraction,\n\ttype CommandInteraction,\n\ttype ContextMenuCommandInteraction,\n\ttype Message\n} from 'discord.js';\nimport { Subcommand } from '../lib/Subcommand';\nimport { SubcommandIdentifiers } from '../lib/types/Enums';\n\n/**\n * The context for the subcommand cooldown precondition\n * @since 5.1.0\n */\nexport interface PluginSubcommandCooldownPreconditionContext extends CorePreconditions.CooldownContext {\n\t/** The name of the subcommand */\n\tsubcommandMethodName: string;\n\t/** The name of the subcommand group, if any */\n\tsubcommandGroupName?: string;\n}\n\n/**\n * The subcommand cooldown precondition. This differs from the cooldown precondition in framework by using a separate\n * bucket as well as resolving the id differently to ensure it is specific to a subcommand.\n * @since 5.1.0\n */\nexport class PluginPrecondition extends AllFlowsPrecondition {\n\tpublic subcommandBuckets = new WeakMap<Subcommand, RateLimitManager<string>>();\n\n\tpublic override messageRun(\n\t\tmessage: Message,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromMessage(message, context);\n\n\t\treturn this.sharedRun(message.author.id, subcommand, context, cooldownId, 'message');\n\t}\n\n\tpublic override chatInputRun(\n\t\tinteraction: ChatInputCommandInteraction,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromInteraction(interaction, context);\n\n\t\treturn this.sharedRun(interaction.user.id, subcommand, context, cooldownId, 'chat input');\n\t}\n\n\tpublic override contextMenuRun(\n\t\tinteraction: ContextMenuCommandInteraction,\n\t\tsubcommand: Command,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext\n\t): AllFlowsPrecondition.Result {\n\t\tconst cooldownId = this.getIdFromInteraction(interaction, context);\n\n\t\treturn this.sharedRun(interaction.user.id, subcommand as Subcommand, context, cooldownId, 'context menu');\n\t}\n\n\tprivate sharedRun(\n\t\tauthorId: string,\n\t\tsubcommand: Subcommand,\n\t\tcontext: PluginSubcommandCooldownPreconditionContext,\n\t\tcooldownId: string,\n\t\tcommandType: string\n\t): AllFlowsPrecondition.Result {\n\t\t// If the subcommand it is testing for is not this one, return ok:\n\t\tif (context.external) return this.ok();\n\n\t\t// If there is no delay (undefined, null, 0), return ok:\n\t\tif (!context.delay) return this.ok();\n\n\t\t// If the user has provided any filtered users and the authorId is in that array, return ok:\n\t\tif (context.filteredUsers?.includes(authorId)) return this.ok();\n\n\t\tconst rateLimit = this.getManager(subcommand, context).acquire(cooldownId);\n\n\t\tif (rateLimit.limited) {\n\t\t\tconst remaining = rateLimit.remainingTime;\n\n\t\t\tconst nextAvailable = time(Math.floor(rateLimit.expires / 1000), TimestampStyles.RelativeTime);\n\t\t\treturn this.error({\n\t\t\t\tidentifier: SubcommandIdentifiers.SubcommandPreconditionCooldown,\n\t\t\t\tmessage: `There is a cooldown in effect for this ${commandType} subcommand. It'll be available ${nextAvailable}.`,\n\t\t\t\tcontext: { remaining }\n\t\t\t});\n\t\t}\n\n\t\trateLimit.consume();\n\t\treturn this.ok();\n\t}\n\n\tprivate getIdFromMessage(message: Message, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tconst subcommandIdentifier = this.getSubcommandMappingName(context);\n\t\tswitch (context.scope) {\n\t\t\tcase BucketScope.Global:\n\t\t\t\treturn `global.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Channel:\n\t\t\t\treturn `${message.channelId}.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Guild:\n\t\t\t\treturn message.guildId ? `${message.guildId}.${subcommandIdentifier}` : `${message.channelId}.${subcommandIdentifier}`;\n\t\t\tdefault:\n\t\t\t\treturn `${message.author.id}.${subcommandIdentifier}`;\n\t\t}\n\t}\n\n\tprivate getIdFromInteraction(interaction: CommandInteraction, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tconst subcommandIdentifier = this.getSubcommandMappingName(context);\n\t\tswitch (context.scope) {\n\t\t\tcase BucketScope.Global:\n\t\t\t\treturn `global.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Channel:\n\t\t\t\treturn `${interaction.channelId}.${subcommandIdentifier}`;\n\t\t\tcase BucketScope.Guild:\n\t\t\t\treturn interaction.guildId ? `${interaction.guildId}.${subcommandIdentifier}` : `${interaction.channelId}.${subcommandIdentifier}`;\n\t\t\tdefault:\n\t\t\t\treturn `${interaction.user.id}.${subcommandIdentifier}`;\n\t\t}\n\t}\n\n\tprivate getSubcommandMappingName(context: PluginSubcommandCooldownPreconditionContext) {\n\t\treturn context.subcommandGroupName ? `${context.subcommandGroupName}.${context.subcommandMethodName}` : context.subcommandMethodName;\n\t}\n\n\tprivate getManager(subcommand: Subcommand, context: PluginSubcommandCooldownPreconditionContext) {\n\t\tlet manager = this.subcommandBuckets.get(subcommand);\n\t\tif (!manager) {\n\t\t\tmanager = new RateLimitManager(context.delay, context.limit);\n\t\t\tthis.subcommandBuckets.set(subcommand, manager);\n\t\t}\n\t\treturn manager;\n\t}\n}\n"]}
|
package/dist/esm/register.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AASO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA,EAI7C,
|
|
1
|
+
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AASO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA,EAI7C,QAAwB,kBAAkB,CAAA,CAAwB,OAAA,EAA8B;AAC/F,IAAA,iBAAA,EAAkB;AAElB,IAAA,IAAI,OAAA,CAAQ,iCAAiC,KAAA,EAAO;AACnD,MAAA,aAAA,EAAc;AAAA,IACf;AAAA,EACD;AACD,CAAA;AAX8C,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA;AAAvC,IAAM,iBAAA,GAAN;AAaP,cAAA,CAAe,OAAA,CAAQ,8BAAA,CAA+B,iBAAA,CAAkB,kBAAkB,GAAG,+BAA+B,CAAA","file":"register.mjs","sourcesContent":["import './index';\n\nimport { Plugin, postInitialization, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { loadListeners, loadPreconditions } from './index';\n\n/**\n * @since 3.1.2\n */\nexport class SubcommandsPlugin extends Plugin {\n\t/**\n\t * @since 3.1.2\n\t */\n\tpublic static override [postInitialization](this: SapphireClient, options: ClientOptions): void {\n\t\tloadPreconditions();\n\n\t\tif (options.loadSubcommandErrorListeners !== false) {\n\t\t\tloadListeners();\n\t\t}\n\t}\n}\n\nSapphireClient.plugins.registerPostInitializationHook(SubcommandsPlugin[postInitialization], 'Subcommand-PostInitialization');\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-subcommands",
|
|
3
|
-
"version": "7.0.2-next.
|
|
3
|
+
"version": "7.0.2-next.84dd7bb",
|
|
4
4
|
"description": "Plugin for @sapphire/framework that adds support for subcommands.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"@favware/cliff-jumper": "^6.0.0",
|
|
85
85
|
"@favware/rollup-type-bundler": "^4.0.0",
|
|
86
86
|
"concurrently": "^9.2.1",
|
|
87
|
-
"tsup": "^8.5.
|
|
88
|
-
"tsx": "^4.
|
|
89
|
-
"typedoc": "^0.
|
|
87
|
+
"tsup": "^8.5.1",
|
|
88
|
+
"tsx": "^4.21.0",
|
|
89
|
+
"typedoc": "^0.28.14",
|
|
90
90
|
"typedoc-json-parser": "^10.2.0",
|
|
91
|
-
"typescript": "~5.
|
|
91
|
+
"typescript": "~5.9.3"
|
|
92
92
|
}
|
|
93
93
|
}
|