@sapphire/plugin-subcommands 6.0.4-next.fe95a62.0 → 7.0.0-next.6e7a5bf
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 +6 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +19 -3
- package/dist/cjs/lib/Subcommand.cjs +37 -52
- package/dist/cjs/lib/Subcommand.cjs.map +1 -1
- package/dist/cjs/lib/precondition-resolvers/subcommandCooldown.cjs +1 -1
- package/dist/cjs/lib/precondition-resolvers/subcommandCooldown.cjs.map +1 -1
- package/dist/cjs/lib/types/Enums.cjs +1 -1
- package/dist/cjs/lib/types/Enums.cjs.map +1 -1
- package/dist/cjs/lib/types/Events.cjs +3 -1
- package/dist/cjs/lib/types/Events.cjs.map +1 -1
- package/dist/cjs/lib/types/SubcommandMappings.cjs +1 -1
- package/dist/cjs/lib/types/SubcommandMappings.cjs.map +1 -1
- package/dist/cjs/listeners/PluginChatInputSubcommandError.cjs +1 -1
- package/dist/cjs/listeners/PluginChatInputSubcommandError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginChatInputSubcommandNoMatch.cjs +21 -0
- package/dist/cjs/listeners/PluginChatInputSubcommandNoMatch.cjs.map +1 -0
- package/dist/cjs/listeners/PluginMessageSubcommandError.cjs +1 -1
- package/dist/cjs/listeners/PluginMessageSubcommandError.cjs.map +1 -1
- package/dist/cjs/listeners/PluginMessageSubcommandNoMatch.cjs +21 -0
- package/dist/cjs/listeners/PluginMessageSubcommandNoMatch.cjs.map +1 -0
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.cjs +1 -1
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.cjs.map +1 -1
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.cjs +1 -1
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.cjs.map +1 -1
- package/dist/cjs/listeners/_load.cjs +13 -1
- package/dist/cjs/listeners/_load.cjs.map +1 -1
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs +5 -11
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs.map +1 -1
- package/dist/cjs/preconditions/_load.cjs +1 -1
- package/dist/cjs/preconditions/_load.cjs.map +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/cjs/register.cjs.map +1 -1
- package/dist/esm/chunk-3IXKS7M5.mjs +14 -0
- package/dist/esm/chunk-3IXKS7M5.mjs.map +1 -0
- package/dist/esm/index.d.mts +19 -3
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/Subcommand.mjs +33 -38
- package/dist/esm/lib/Subcommand.mjs.map +1 -1
- package/dist/esm/lib/precondition-resolvers/subcommandCooldown.mjs +2 -2
- package/dist/esm/lib/precondition-resolvers/subcommandCooldown.mjs.map +1 -1
- package/dist/esm/lib/types/Enums.mjs +2 -2
- package/dist/esm/lib/types/Enums.mjs.map +1 -1
- package/dist/esm/lib/types/Events.mjs +4 -2
- package/dist/esm/lib/types/Events.mjs.map +1 -1
- package/dist/esm/lib/types/SubcommandMappings.mjs +1 -1
- package/dist/esm/lib/types/SubcommandMappings.mjs.map +1 -1
- package/dist/esm/listeners/PluginChatInputSubcommandError.mjs +2 -2
- package/dist/esm/listeners/PluginChatInputSubcommandError.mjs.map +1 -1
- package/dist/esm/listeners/PluginChatInputSubcommandNoMatch.mjs +18 -0
- package/dist/esm/listeners/PluginChatInputSubcommandNoMatch.mjs.map +1 -0
- package/dist/esm/listeners/PluginMessageSubcommandError.mjs +2 -2
- package/dist/esm/listeners/PluginMessageSubcommandError.mjs.map +1 -1
- package/dist/esm/listeners/PluginMessageSubcommandNoMatch.mjs +18 -0
- package/dist/esm/listeners/PluginMessageSubcommandNoMatch.mjs.map +1 -0
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs +2 -2
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs.map +1 -1
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.mjs +2 -2
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.mjs.map +1 -1
- package/dist/esm/listeners/_load.mjs +14 -2
- package/dist/esm/listeners/_load.mjs.map +1 -1
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs +5 -8
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs.map +1 -1
- package/dist/esm/preconditions/_load.mjs +2 -2
- package/dist/esm/preconditions/_load.mjs.map +1 -1
- package/dist/esm/register.mjs +2 -2
- package/dist/esm/register.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/esm/chunk-K3DKV2RO.mjs +0 -24
- package/dist/esm/chunk-K3DKV2RO.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { Listener } from '@sapphire/framework';
|
|
3
3
|
import { SubcommandPluginEvents } from '../lib/types/Events.mjs';
|
|
4
4
|
|
|
@@ -15,5 +15,5 @@ __name(_PluginListener, "PluginListener");
|
|
|
15
15
|
var PluginListener = _PluginListener;
|
|
16
16
|
|
|
17
17
|
export { PluginListener };
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=PluginSubcommandMappingIsMissingMessageCommandHandler.mjs.map
|
|
19
19
|
//# sourceMappingURL=PluginSubcommandMappingIsMissingMessageCommandHandler.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.ts"],"names":[],"mappings":";;;;AAKO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAwF,CAAA;AAAA,EACpH,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,iDAAiD,CAAA,CAAA;AAAA,GACjG;AAAA,EAEgB,GAAA,CAAI,CAAY,EAAA,UAAA,EAAqC,OAAwC,EAAA;AAC5G,IAAA,MAAM,EAAE,IAAA,EAAM,QAAS,EAAA,GAAI,OAAQ,CAAA,OAAA,CAAA;AACnC,IAAK,IAAA,CAAA,SAAA,CAAU,OAAO,KAAM,CAAA,CAAA,qDAAA,EAAwD,IAAI,CAAS,MAAA,EAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA,EAAK,UAAU,CAAA,CAAA;AAAA,GAC9H;AACD,CAAA,CAAA;AAT4H,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAArH,IAAM,cAAN,GAAA","file":"PluginSubcommandMappingIsMissingMessageCommandHandler.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport { SubcommandPluginEvents, type MessageSubcommandErrorPayload } from '../lib/types/Events';\nimport type { SubcommandMappingMethod } from '../lib/types/SubcommandMappings';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler });\n\t}\n\n\tpublic override run(_: Message, subcommand: SubcommandMappingMethod, context: MessageSubcommandErrorPayload) {\n\t\tconst { name, location } = context.command;\n\t\tthis.container.logger.error(`Encountered a missing mapping on message subcommand \"${name}\" at \"${location.full}\"`, subcommand);\n\t}\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { container } from '@sapphire/pieces';
|
|
3
3
|
import { PluginListener } from './PluginChatInputSubcommandError.mjs';
|
|
4
|
+
import { PluginListener as PluginListener$5 } from './PluginChatInputSubcommandNoMatch.mjs';
|
|
4
5
|
import { PluginListener as PluginListener$1 } from './PluginMessageSubcommandError.mjs';
|
|
6
|
+
import { PluginListener as PluginListener$4 } from './PluginMessageSubcommandNoMatch.mjs';
|
|
5
7
|
import { PluginListener as PluginListener$2 } from './PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs';
|
|
6
8
|
import { PluginListener as PluginListener$3 } from './PluginSubcommandMappingIsMissingMessageCommandHandler.mjs';
|
|
7
9
|
|
|
@@ -19,9 +21,19 @@ function loadListeners() {
|
|
|
19
21
|
piece: PluginListener$3,
|
|
20
22
|
store
|
|
21
23
|
});
|
|
24
|
+
void container.stores.loadPiece({
|
|
25
|
+
name: "PluginMessageSubcommandNoMatch",
|
|
26
|
+
piece: PluginListener$4,
|
|
27
|
+
store
|
|
28
|
+
});
|
|
29
|
+
void container.stores.loadPiece({
|
|
30
|
+
name: "PluginChatInputSubcommandNoMatch",
|
|
31
|
+
piece: PluginListener$5,
|
|
32
|
+
store
|
|
33
|
+
});
|
|
22
34
|
}
|
|
23
35
|
__name(loadListeners, "loadListeners");
|
|
24
36
|
|
|
25
37
|
export { loadListeners };
|
|
26
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=_load.mjs.map
|
|
27
39
|
//# sourceMappingURL=_load.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/_load.ts"],"names":[
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/_load.ts"],"names":["PluginChatInputSubcommandError","PluginMessageSubcommandError","PluginSubcommandMappingIsMissingChatInputCommandHandler","PluginSubcommandMappingIsMissingMessageCommandHandler","PluginMessageSubcommandNoMatch","PluginChatInputSubcommandNoMatch"],"mappings":";;;;;;;;;AAQO,SAAS,aAAgB,GAAA;AAC/B,EAAA,MAAM,KAAQ,GAAA,WAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,gCAAkC,EAAA,KAAA,EAAOA,cAAgC,EAAA,KAAA,EAAO,CAAA,CAAA;AACxH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,8BAAgC,EAAA,KAAA,EAAOC,gBAA8B,EAAA,KAAA,EAAO,CAAA,CAAA;AACpH,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA;AAAA,IAC/B,IAAM,EAAA,yDAAA;AAAA,IACN,KAAO,EAAAC,gBAAA;AAAA,IACP,KAAA;AAAA,GACA,CAAA,CAAA;AACD,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA;AAAA,IAC/B,IAAM,EAAA,uDAAA;AAAA,IACN,KAAO,EAAAC,gBAAA;AAAA,IACP,KAAA;AAAA,GACA,CAAA,CAAA;AACD,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA;AAAA,IAC/B,IAAM,EAAA,gCAAA;AAAA,IACN,KAAO,EAAAC,gBAAA;AAAA,IACP,KAAA;AAAA,GACA,CAAA,CAAA;AACD,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA;AAAA,IAC/B,IAAM,EAAA,kCAAA;AAAA,IACN,KAAO,EAAAC,gBAAA;AAAA,IACP,KAAA;AAAA,GACA,CAAA,CAAA;AACF,CAAA;AAxBgB,MAAA,CAAA,aAAA,EAAA,eAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginListener as PluginChatInputSubcommandError } from './PluginChatInputSubcommandError';\nimport { PluginListener as PluginChatInputSubcommandNoMatch } from './PluginChatInputSubcommandNoMatch';\nimport { PluginListener as PluginMessageSubcommandError } from './PluginMessageSubcommandError';\nimport { PluginListener as PluginMessageSubcommandNoMatch } from './PluginMessageSubcommandNoMatch';\nimport { PluginListener as PluginSubcommandMappingIsMissingChatInputCommandHandler } from './PluginSubcommandMappingIsMissingChatInputCommandHandler';\nimport { PluginListener as PluginSubcommandMappingIsMissingMessageCommandHandler } from './PluginSubcommandMappingIsMissingMessageCommandHandler';\n\nexport function loadListeners() {\n\tconst store = 'listeners' as const;\n\tvoid container.stores.loadPiece({ name: 'PluginChatInputSubcommandError', piece: PluginChatInputSubcommandError, store });\n\tvoid container.stores.loadPiece({ name: 'PluginMessageSubcommandError', piece: PluginMessageSubcommandError, store });\n\tvoid container.stores.loadPiece({\n\t\tname: 'PluginSubcommandMappingIsMissingChatInputCommandHandler',\n\t\tpiece: PluginSubcommandMappingIsMissingChatInputCommandHandler,\n\t\tstore\n\t});\n\tvoid container.stores.loadPiece({\n\t\tname: 'PluginSubcommandMappingIsMissingMessageCommandHandler',\n\t\tpiece: PluginSubcommandMappingIsMissingMessageCommandHandler,\n\t\tstore\n\t});\n\tvoid container.stores.loadPiece({\n\t\tname: 'PluginMessageSubcommandNoMatch',\n\t\tpiece: PluginMessageSubcommandNoMatch,\n\t\tstore\n\t});\n\tvoid container.stores.loadPiece({\n\t\tname: 'PluginChatInputSubcommandNoMatch',\n\t\tpiece: PluginChatInputSubcommandNoMatch,\n\t\tstore\n\t});\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name, __publicField } from '../chunk-
|
|
1
|
+
import { __name, __publicField } from '../chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { AllFlowsPrecondition, BucketScope } from '@sapphire/framework';
|
|
3
3
|
import { RateLimitManager } from '@sapphire/ratelimits';
|
|
4
4
|
import { time, TimestampStyles } from 'discord.js';
|
|
@@ -23,12 +23,9 @@ var _PluginPrecondition = class _PluginPrecondition extends AllFlowsPrecondition
|
|
|
23
23
|
return this.sharedRun(interaction.user.id, subcommand, context, cooldownId, "context menu");
|
|
24
24
|
}
|
|
25
25
|
sharedRun(authorId, subcommand, context, cooldownId, commandType) {
|
|
26
|
-
if (context.external)
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
return this.ok();
|
|
30
|
-
if (context.filteredUsers?.includes(authorId))
|
|
31
|
-
return this.ok();
|
|
26
|
+
if (context.external) return this.ok();
|
|
27
|
+
if (!context.delay) return this.ok();
|
|
28
|
+
if (context.filteredUsers?.includes(authorId)) return this.ok();
|
|
32
29
|
const rateLimit = this.getManager(subcommand, context).acquire(cooldownId);
|
|
33
30
|
if (rateLimit.limited) {
|
|
34
31
|
const remaining = rateLimit.remainingTime;
|
|
@@ -84,5 +81,5 @@ __name(_PluginPrecondition, "PluginPrecondition");
|
|
|
84
81
|
var PluginPrecondition = _PluginPrecondition;
|
|
85
82
|
|
|
86
83
|
export { PluginPrecondition };
|
|
87
|
-
//# sourceMappingURL=
|
|
84
|
+
//# sourceMappingURL=PluginSubcommandCooldown.mjs.map
|
|
88
85
|
//# sourceMappingURL=PluginSubcommandCooldown.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/preconditions/PluginSubcommandCooldown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/preconditions/PluginSubcommandCooldown.ts"],"names":[],"mappings":";;;;;;;AA6BO,IAAM,mBAAA,GAAN,MAAM,mBAAA,SAA2B,oBAAqB,CAAA;AAAA,EAAtD,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CAAA;AACN,IAAO,aAAA,CAAA,IAAA,EAAA,mBAAA,sBAAwB,OAA8C,EAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAE7D,UAAA,CACf,OACA,EAAA,UAAA,EACA,OAC8B,EAAA;AAC9B,IAAA,MAAM,UAAa,GAAA,IAAA,CAAK,gBAAiB,CAAA,OAAA,EAAS,OAAO,CAAA,CAAA;AAEzD,IAAO,OAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,MAAA,CAAO,IAAI,UAAY,EAAA,OAAA,EAAS,YAAY,SAAS,CAAA,CAAA;AAAA,GACpF;AAAA,EAEgB,YAAA,CACf,WACA,EAAA,UAAA,EACA,OAC8B,EAAA;A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AAChB,QAAA,OAAO,CAAG,EAAA,WAAA,CAAY,SAAS,CAAA,CAAA,EAAI,oBAAoB,CAAA,CAAA,CAAA;AAAA,MACxD,KAAK,WAAY,CAAA,KAAA;AAChB,QAAO,OAAA,CAAA,EAAG,WAAY,CAAA,OAAO,CAAI,CAAA,EAAA,oBAAoB,MAAM,CAAG,EAAA,WAAA,CAAY,SAAS,CAAA,CAAA,EAAI,oBAAoB,CAAA,CAAA,CAAA;AAAA,MAC5G;AACC,QAAA,OAAO,CAAG,EAAA,WAAA,CAAY,IAAK,CAAA,EAAE,IAAI,oBAAoB,CAAA,CAAA,CAAA;AAAA,KACvD;AAAA,GACD;AAAA,EAEQ,yBAAyB,OAAsD,EAAA;AACtF,IAAO,OAAA,OAAA,CAAQ,sBAAsB,CAAG,EAAA,OAAA,CAAQ,mBAAmB,CAAI,CAAA,EAAA,OAAA,CAAQ,oBAAoB,CAAA,CAAA,GAAK,OAAQ,CAAA,oBAAA,CAAA;AAAA,GACjH;AAAA,EAEQ,UAAA,CAAW,YAAwB,OAAsD,EAAA;AAChG,IAAA,IAAI,OAAU,GAAA,IAAA,CAAK,iBAAkB,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AACnD,IAAA,IAAI,CAAC,OAAS,EAAA;AACb,MAAA,OAAA,GAAU,IAAI,gBAAA,CAAiB,OAAQ,CAAA,KAAA,EAAO,QAAQ,KAAK,CAAA,CAAA;AAC3D,MAAK,IAAA,CAAA,iBAAA,CAAkB,GAAI,CAAA,UAAA,EAAY,OAAO,CAAA,CAAA;AAAA,KAC/C;AACA,IAAO,OAAA,OAAA,CAAA;AAAA,GACR;AACD,CAAA,CAAA;AA1G6D,MAAA,CAAA,mBAAA,EAAA,oBAAA,CAAA,CAAA;AAAtD,IAAM,kBAAN,GAAA","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}.${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}.${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,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../chunk-
|
|
1
|
+
import { __name } from '../chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { container } from '@sapphire/pieces';
|
|
3
3
|
import { PluginPrecondition } from './PluginSubcommandCooldown.mjs';
|
|
4
4
|
|
|
@@ -9,5 +9,5 @@ function loadPreconditions() {
|
|
|
9
9
|
__name(loadPreconditions, "loadPreconditions");
|
|
10
10
|
|
|
11
11
|
export { loadPreconditions };
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=_load.mjs.map
|
|
13
13
|
//# sourceMappingURL=_load.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/preconditions/_load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/preconditions/_load.ts"],"names":["PluginSubcommandCooldown"],"mappings":";;;;AAGO,SAAS,iBAAoB,GAAA;AACnC,EAAA,MAAM,KAAQ,GAAA,eAAA,CAAA;AACd,EAAK,KAAA,SAAA,CAAU,OAAO,SAAU,CAAA,EAAE,MAAM,0BAA4B,EAAA,KAAA,EAAOA,kBAA0B,EAAA,KAAA,EAAO,CAAA,CAAA;AAC7G,CAAA;AAHgB,MAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA","file":"_load.mjs","sourcesContent":["import { container } from '@sapphire/pieces';\nimport { PluginPrecondition as PluginSubcommandCooldown } from './PluginSubcommandCooldown';\n\nexport function loadPreconditions() {\n\tconst store = 'preconditions' as const;\n\tvoid container.stores.loadPiece({ name: 'PluginSubcommandCooldown', piece: PluginSubcommandCooldown, store });\n}\n"]}
|
package/dist/esm/register.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from './chunk-
|
|
1
|
+
import { __name } from './chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { loadPreconditions, loadListeners } from './index.mjs';
|
|
3
3
|
import { SapphireClient, postInitialization, Plugin } from '@sapphire/framework';
|
|
4
4
|
|
|
@@ -18,5 +18,5 @@ var SubcommandsPlugin = _SubcommandsPlugin;
|
|
|
18
18
|
SapphireClient.plugins.registerPostInitializationHook(SubcommandsPlugin[postInitialization], "Subcommand-PostInitialization");
|
|
19
19
|
|
|
20
20
|
export { SubcommandsPlugin };
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=register.mjs.map
|
|
22
22
|
//# sourceMappingURL=register.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AASO,IAAM,kBAAA,GAAN,MAAM,kBAAA,SAA0B,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,EAI7C,QAAe,kBAAkB,CAAA,CAAwB,OAA8B,EAAA;AACtF,IAAkB,iBAAA,EAAA,CAAA;AAElB,IAAI,IAAA,OAAA,CAAQ,iCAAiC,KAAO,EAAA;AACnD,MAAc,aAAA,EAAA,CAAA;AAAA,KACf;AAAA,GACD;AACD,CAAA,CAAA;AAX8C,MAAA,CAAA,kBAAA,EAAA,mBAAA,CAAA,CAAA;AAAvC,IAAM,iBAAN,GAAA,mBAAA;AAaP,cAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,iBAAkB,CAAA,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 [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": "
|
|
3
|
+
"version": "7.0.0-next.6e7a5bf",
|
|
4
4
|
"description": "Plugin for @sapphire/framework that adds support for subcommands.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"check-update": "cliff-jumper --dry-run"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sapphire/utilities": "^3.
|
|
52
|
+
"@sapphire/utilities": "^3.17.0"
|
|
53
53
|
},
|
|
54
54
|
"repository": {
|
|
55
55
|
"type": "git",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@favware/cliff-jumper": "^
|
|
84
|
+
"@favware/cliff-jumper": "^4.0.3",
|
|
85
85
|
"@favware/rollup-type-bundler": "^3.3.0",
|
|
86
86
|
"concurrently": "^8.2.2",
|
|
87
|
-
"tsup": "^8.
|
|
88
|
-
"tsx": "^4.
|
|
89
|
-
"typedoc": "^0.25.
|
|
90
|
-
"typedoc-json-parser": "^
|
|
91
|
-
"typescript": "
|
|
87
|
+
"tsup": "^8.2.4",
|
|
88
|
+
"tsx": "^4.16.5",
|
|
89
|
+
"typedoc": "^0.25.13",
|
|
90
|
+
"typedoc-json-parser": "^10.0.0",
|
|
91
|
+
"typescript": "~5.4.5"
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
var __publicField = (obj, key, value) => {
|
|
5
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
return value;
|
|
7
|
-
};
|
|
8
|
-
var __accessCheck = (obj, member, msg) => {
|
|
9
|
-
if (!member.has(obj))
|
|
10
|
-
throw TypeError("Cannot " + msg);
|
|
11
|
-
};
|
|
12
|
-
var __privateAdd = (obj, member, value) => {
|
|
13
|
-
if (member.has(obj))
|
|
14
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
15
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
16
|
-
};
|
|
17
|
-
var __privateMethod = (obj, member, method) => {
|
|
18
|
-
__accessCheck(obj, member, "access private method");
|
|
19
|
-
return method;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { __name, __privateAdd, __privateMethod, __publicField };
|
|
23
|
-
//# sourceMappingURL=out.js.map
|
|
24
|
-
//# sourceMappingURL=chunk-K3DKV2RO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|