@sapphire/plugin-subcommands 5.1.1-next.f01b974.0 → 6.0.0-next.37591c8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +74 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +395 -0
- package/dist/cjs/lib/Subcommand.cjs +421 -0
- package/dist/cjs/lib/Subcommand.cjs.map +1 -0
- package/dist/cjs/lib/precondition-resolvers/subcommandCooldown.cjs +39 -0
- package/dist/cjs/lib/precondition-resolvers/subcommandCooldown.cjs.map +1 -0
- package/dist/cjs/lib/types/Enums.cjs +16 -0
- package/dist/cjs/lib/types/Enums.cjs.map +1 -0
- package/dist/cjs/lib/types/Events.cjs +26 -0
- package/dist/cjs/lib/types/Events.cjs.map +1 -0
- package/dist/cjs/lib/types/SubcommandMappings.cjs +4 -0
- package/dist/cjs/lib/types/SubcommandMappings.cjs.map +1 -0
- package/dist/cjs/listeners/PluginChatInputSubcommandError.cjs +22 -0
- package/dist/cjs/listeners/PluginChatInputSubcommandError.cjs.map +1 -0
- package/dist/cjs/listeners/PluginMessageSubcommandError.cjs +22 -0
- package/dist/cjs/listeners/PluginMessageSubcommandError.cjs.map +1 -0
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.cjs +22 -0
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.cjs.map +1 -0
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.cjs +22 -0
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.cjs.map +1 -0
- package/dist/cjs/listeners/_load.cjs +30 -0
- package/dist/cjs/listeners/_load.cjs.map +1 -0
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs +96 -0
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs.map +1 -0
- package/dist/cjs/preconditions/_load.cjs +16 -0
- package/dist/cjs/preconditions/_load.cjs.map +1 -0
- package/dist/cjs/register.cjs +25 -0
- package/dist/cjs/register.cjs.map +1 -0
- package/dist/{register.d.ts → cjs/register.d.ts} +5 -4
- package/dist/esm/chunk-K3DKV2RO.mjs +24 -0
- package/dist/esm/chunk-K3DKV2RO.mjs.map +1 -0
- package/dist/esm/index.d.mts +395 -0
- package/dist/esm/index.mjs +19 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/lib/Subcommand.mjs +400 -0
- package/dist/esm/lib/Subcommand.mjs.map +1 -0
- package/dist/esm/lib/precondition-resolvers/subcommandCooldown.mjs +36 -0
- package/dist/esm/lib/precondition-resolvers/subcommandCooldown.mjs.map +1 -0
- package/dist/esm/lib/types/Enums.mjs +15 -0
- package/dist/esm/lib/types/Enums.mjs.map +1 -0
- package/dist/esm/lib/types/Events.mjs +25 -0
- package/dist/esm/lib/types/Events.mjs.map +1 -0
- package/dist/esm/lib/types/SubcommandMappings.mjs +3 -0
- package/dist/esm/lib/types/SubcommandMappings.mjs.map +1 -0
- package/dist/esm/listeners/PluginChatInputSubcommandError.mjs +19 -0
- package/dist/esm/listeners/PluginChatInputSubcommandError.mjs.map +1 -0
- package/dist/esm/listeners/PluginMessageSubcommandError.mjs +19 -0
- package/dist/esm/listeners/PluginMessageSubcommandError.mjs.map +1 -0
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs +19 -0
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs.map +1 -0
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.mjs +19 -0
- package/dist/esm/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.mjs.map +1 -0
- package/dist/esm/listeners/_load.mjs +27 -0
- package/dist/esm/listeners/_load.mjs.map +1 -0
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs +88 -0
- package/dist/esm/preconditions/PluginSubcommandCooldown.mjs.map +1 -0
- package/dist/esm/preconditions/_load.mjs +13 -0
- package/dist/esm/preconditions/_load.mjs.map +1 -0
- package/dist/esm/register.d.mts +14 -0
- package/dist/esm/register.mjs +22 -0
- package/dist/esm/register.mjs.map +1 -0
- package/package.json +34 -19
- package/dist/index.d.ts +0 -48
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -43
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -10
- package/dist/lib/Subcommand.d.ts +0 -81
- package/dist/lib/Subcommand.d.ts.map +0 -1
- package/dist/lib/Subcommand.js +0 -440
- package/dist/lib/Subcommand.js.map +0 -1
- package/dist/lib/precondition-resolvers/subcommandCooldown.d.ts +0 -29
- package/dist/lib/precondition-resolvers/subcommandCooldown.d.ts.map +0 -1
- package/dist/lib/precondition-resolvers/subcommandCooldown.js +0 -31
- package/dist/lib/precondition-resolvers/subcommandCooldown.js.map +0 -1
- package/dist/lib/types/Enums.d.ts +0 -16
- package/dist/lib/types/Enums.d.ts.map +0 -1
- package/dist/lib/types/Enums.js +0 -21
- package/dist/lib/types/Enums.js.map +0 -1
- package/dist/lib/types/Events.d.ts +0 -99
- package/dist/lib/types/Events.d.ts.map +0 -1
- package/dist/lib/types/Events.js +0 -22
- package/dist/lib/types/Events.js.map +0 -1
- package/dist/lib/types/SubcommandMappings.d.ts +0 -90
- package/dist/lib/types/SubcommandMappings.d.ts.map +0 -1
- package/dist/lib/types/SubcommandMappings.js +0 -3
- package/dist/lib/types/SubcommandMappings.js.map +0 -1
- package/dist/listeners/PluginChatInputSubcommandError.d.ts +0 -7
- package/dist/listeners/PluginChatInputSubcommandError.d.ts.map +0 -1
- package/dist/listeners/PluginChatInputSubcommandError.js +0 -16
- package/dist/listeners/PluginChatInputSubcommandError.js.map +0 -1
- package/dist/listeners/PluginMessageSubcommandError.d.ts +0 -7
- package/dist/listeners/PluginMessageSubcommandError.d.ts.map +0 -1
- package/dist/listeners/PluginMessageSubcommandError.js +0 -16
- package/dist/listeners/PluginMessageSubcommandError.js.map +0 -1
- package/dist/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.d.ts +0 -8
- package/dist/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.d.ts.map +0 -1
- package/dist/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.js +0 -16
- package/dist/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.js.map +0 -1
- package/dist/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.d.ts +0 -9
- package/dist/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.d.ts.map +0 -1
- package/dist/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.js +0 -16
- package/dist/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.js.map +0 -1
- package/dist/listeners/_load.d.ts +0 -2
- package/dist/listeners/_load.d.ts.map +0 -1
- package/dist/listeners/_load.js +0 -25
- package/dist/listeners/_load.js.map +0 -1
- package/dist/preconditions/PluginSubcommandCooldown.d.ts +0 -31
- package/dist/preconditions/PluginSubcommandCooldown.d.ts.map +0 -1
- package/dist/preconditions/PluginSubcommandCooldown.js +0 -97
- package/dist/preconditions/PluginSubcommandCooldown.js.map +0 -1
- package/dist/preconditions/_load.d.ts +0 -2
- package/dist/preconditions/_load.d.ts.map +0 -1
- package/dist/preconditions/_load.js +0 -11
- package/dist/preconditions/_load.js.map +0 -1
- package/dist/register.d.ts.map +0 -1
- package/dist/register.js +0 -24
- package/dist/register.js.map +0 -1
- package/dist/register.mjs +0 -4
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PluginSubcommandCooldown_cjs = require('./preconditions/PluginSubcommandCooldown.cjs');
|
|
4
|
+
var Subcommand_cjs = require('./lib/Subcommand.cjs');
|
|
5
|
+
var subcommandCooldown_cjs = require('./lib/precondition-resolvers/subcommandCooldown.cjs');
|
|
6
|
+
var Enums_cjs = require('./lib/types/Enums.cjs');
|
|
7
|
+
var Events_cjs = require('./lib/types/Events.cjs');
|
|
8
|
+
var SubcommandMappings_cjs = require('./lib/types/SubcommandMappings.cjs');
|
|
9
|
+
var _load_cjs = require('./listeners/_load.cjs');
|
|
10
|
+
var _load_cjs$1 = require('./preconditions/_load.cjs');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var subcommandCooldown_cjs__namespace = /*#__PURE__*/_interopNamespace(subcommandCooldown_cjs);
|
|
31
|
+
|
|
32
|
+
// src/index.ts
|
|
33
|
+
var SubcommandPreconditions = {
|
|
34
|
+
SubcommandCooldown: PluginSubcommandCooldown_cjs.PluginPrecondition
|
|
35
|
+
};
|
|
36
|
+
var version = "6.0.0-next.37591c8.0";
|
|
37
|
+
|
|
38
|
+
exports.SubcommandPreconditionResolvers = subcommandCooldown_cjs__namespace;
|
|
39
|
+
Object.defineProperty(exports, 'loadListeners', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return _load_cjs.loadListeners; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, 'loadPreconditions', {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return _load_cjs$1.loadPreconditions; }
|
|
46
|
+
});
|
|
47
|
+
exports.SubcommandPreconditions = SubcommandPreconditions;
|
|
48
|
+
exports.version = version;
|
|
49
|
+
Object.keys(Subcommand_cjs).forEach(function (k) {
|
|
50
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return Subcommand_cjs[k]; }
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
Object.keys(Enums_cjs).forEach(function (k) {
|
|
56
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return Enums_cjs[k]; }
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
Object.keys(Events_cjs).forEach(function (k) {
|
|
62
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return Events_cjs[k]; }
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
Object.keys(SubcommandMappings_cjs).forEach(function (k) {
|
|
68
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return SubcommandMappings_cjs[k]; }
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=out.js.map
|
|
74
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";AACA,SAAS,sBAAsB,0BAAsE;AAErG,cAAc;AACd,YAAY,qCAAqC;AACjD,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAiC3B,IAAM,0BAA0B;AAAA,EACtC;AACD;AAkBO,IAAM,UAAkB","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport { PluginPrecondition as SubcommandCooldown, type SubcommandCooldownPreconditionContext } 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';\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\tSubcommandCooldown: SubcommandPreconditions.SubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n */\nexport const SubcommandPreconditions = {\n\tSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type SubcommandCooldownContext = SubcommandCooldownPreconditionContext;\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 = '6.0.0-next.37591c8.0';\n"]}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import * as _sapphire_framework from '@sapphire/framework';
|
|
2
|
+
import { Command, Args, PreconditionContainerArray, ChatInputCommand, MessageCommand, CorePreconditions, AllFlowsPrecondition, BucketScope, UserError, MessageCommandDeniedPayload, CooldownOptions } from '@sapphire/framework';
|
|
3
|
+
import { Message, CacheType, ChatInputCommandInteraction, ContextMenuCommandInteraction } from 'discord.js';
|
|
4
|
+
import { RateLimitManager } from '@sapphire/ratelimits';
|
|
5
|
+
|
|
6
|
+
type SubcommandMapping = SubcommandMappingMethod | SubcommandMappingGroup;
|
|
7
|
+
type SubcommandMappingArray = SubcommandMapping[];
|
|
8
|
+
/**
|
|
9
|
+
* Describes the mapping of all the subcommands to their respective implementations for this command.
|
|
10
|
+
*/
|
|
11
|
+
interface SubcommandMappingBase {
|
|
12
|
+
/**
|
|
13
|
+
* The name of this subcommand, or subcommand group
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether this subcommand mapping describes a `'method'` or `'group'`
|
|
18
|
+
* @default 'method'
|
|
19
|
+
*/
|
|
20
|
+
type?: 'group' | 'method';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Describes how a subcommand method maps to the actual implementation of that subcommand.
|
|
24
|
+
*/
|
|
25
|
+
interface SubcommandMappingMethod extends SubcommandMappingBase, Pick<Command.Options, 'preconditions' | 'runIn' | 'nsfw' | 'cooldownLimit' | 'cooldownDelay' | 'cooldownScope' | 'cooldownFilteredUsers' | 'requiredClientPermissions' | 'requiredUserPermissions'> {
|
|
26
|
+
/**
|
|
27
|
+
* This subcommand mapping describes a subcommand method and can therefore only ever be `'method'`
|
|
28
|
+
*/
|
|
29
|
+
type?: 'method';
|
|
30
|
+
/**
|
|
31
|
+
* Whether this is the default subcommand when none is provided.
|
|
32
|
+
*
|
|
33
|
+
* Note that this is effectively only used for Message based subcommand
|
|
34
|
+
* (those implementing {@link SubcommandMappingMethod.messageRun})
|
|
35
|
+
* because the subcommand is always provided for chat input commands.
|
|
36
|
+
*/
|
|
37
|
+
default?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The class method to call when invoking this subcommand through a **message command**,
|
|
40
|
+
* or a callback implementation of the subcommand.
|
|
41
|
+
*
|
|
42
|
+
* Note that when providing a string you have to first define the method that will be called within your function
|
|
43
|
+
* before this will allow any values. This is to ensure that the property is strictly typed to the context of the
|
|
44
|
+
* class.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* messageRun: 'runAdminConfig'
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* messageRun(message: Message) {
|
|
54
|
+
* return message.reply(`<@${message.author.id}> has been granted admin`);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
messageRun?: string | Command['messageRun'];
|
|
59
|
+
/**
|
|
60
|
+
* The class method to call when invoking this subcommand through a **chat input command**,
|
|
61
|
+
* or a callback implementation of the subcommand.
|
|
62
|
+
*
|
|
63
|
+
* Note that when providing a string you have to first define the method that will be called within your function
|
|
64
|
+
* before this will allow any values. This is to ensure that the property is strictly typed to the context of the
|
|
65
|
+
* class.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* chatInputRun: 'runModeratorConfig'
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* chatInputRun(interaction: Subcommand.Interaction) {
|
|
75
|
+
* return interaction.reply(`<@${interaction.user.id}> has been granted moderator`);
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
chatInputRun?: string | Command['chatInputRun'];
|
|
80
|
+
}
|
|
81
|
+
interface SubcommandMappingGroup extends SubcommandMappingBase {
|
|
82
|
+
/**
|
|
83
|
+
* This subcommand mapping describes a subcommand group and can therefore only ever be `'group'`
|
|
84
|
+
*/
|
|
85
|
+
type: 'group';
|
|
86
|
+
/**
|
|
87
|
+
* The {@link SubcommandMappingMethod}s that are contained within this subcommand group.
|
|
88
|
+
*/
|
|
89
|
+
entries: SubcommandMappingMethod[];
|
|
90
|
+
}
|
|
91
|
+
type MessageSubcommandMappingMethod = Omit<SubcommandMappingMethod, 'messageRun'> & Required<Pick<SubcommandMappingMethod, 'messageRun'>>;
|
|
92
|
+
type ChatInputCommandSubcommandMappingMethod = Omit<SubcommandMappingMethod, 'chatInputRun'> & Required<Pick<SubcommandMappingMethod, 'chatInputRun'>>;
|
|
93
|
+
|
|
94
|
+
interface SubcommandOptions extends Command.Options {
|
|
95
|
+
subcommands?: SubcommandMappingArray;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to add aliases for subcommands with dashes in them
|
|
98
|
+
*
|
|
99
|
+
* When this option is enabled *and* the subcommand implements `messageRun`, dashless aliases will be added.
|
|
100
|
+
*
|
|
101
|
+
* For subcommands groups both the group itself and all subcommands within the group will have dashless aliases added.
|
|
102
|
+
*
|
|
103
|
+
* @since 3.0.0
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
generateDashLessAliases?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The class to extends for commands that have subcommands.
|
|
110
|
+
* Specify the subcommands through the {@link Subcommand.Options.subcommands} option.
|
|
111
|
+
*
|
|
112
|
+
* Note that you should not make **all** your commands extend this class, _only_ the ones that have subcommands.
|
|
113
|
+
* The reason for this is that this class implements {@link Command.messageRun} and {@link Command.chatInputRun}
|
|
114
|
+
* which you wouldn't necessarily want to do for commands that don't have subcommands.
|
|
115
|
+
* Furthermore, it also just adds general unnecessary memory overhead.
|
|
116
|
+
*/
|
|
117
|
+
declare class Subcommand<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> extends Command<PreParseReturn, Options> {
|
|
118
|
+
#private;
|
|
119
|
+
/**
|
|
120
|
+
* The preconditions to be run for each specified subcommand.
|
|
121
|
+
* @since 4.1.0
|
|
122
|
+
*/
|
|
123
|
+
readonly subcommandPreconditions: Map<string, PreconditionContainerArray>;
|
|
124
|
+
/**
|
|
125
|
+
* The parsed subcommand mappings that were provided with the {@link SubcommandOptions.subcommands} option.
|
|
126
|
+
* This is built at construction time and is used to determine which subcommand to run.
|
|
127
|
+
*/
|
|
128
|
+
parsedSubcommandMappings: SubcommandMappingArray;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to use case insensitive subcommands. This is only relevant for message-command styled commands as
|
|
131
|
+
* chat input commands are always lowercase. This can be enabled through `clientOptions.caseInsensitiveCommands`.
|
|
132
|
+
*/
|
|
133
|
+
caseInsensitiveSubcommands: boolean;
|
|
134
|
+
constructor(context: Subcommand.LoaderContext, options: Options);
|
|
135
|
+
onLoad(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Whether this command has message-based subcommands or not
|
|
138
|
+
* @returns `true` if this command has message-based subcommands, otherwise `false`
|
|
139
|
+
*/
|
|
140
|
+
supportsMessageCommands(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether this command has chat input subcommands or not
|
|
143
|
+
* @returns `true` if this command has chat input subcommands, otherwise `false`
|
|
144
|
+
*/
|
|
145
|
+
supportsChatInputCommands(): this is ChatInputCommand;
|
|
146
|
+
/**
|
|
147
|
+
* The method that is ran when a message-based subcommand is ran.
|
|
148
|
+
*
|
|
149
|
+
* **DO NOT** override this in your implementation of a subcommand!
|
|
150
|
+
*/
|
|
151
|
+
messageRun(message: Message, args: PreParseReturn, context: MessageCommand.RunContext): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* The method that is ran when a chat input based subcommand is ran.
|
|
154
|
+
*
|
|
155
|
+
* **DO NOT** override this in your implementation of a subcommand!
|
|
156
|
+
*/
|
|
157
|
+
chatInputRun(interaction: ChatInputCommand.Interaction, context: ChatInputCommand.RunContext): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
declare namespace Subcommand {
|
|
160
|
+
type Options = SubcommandOptions;
|
|
161
|
+
type JSON = Command.JSON;
|
|
162
|
+
/** @deprecated Use {@linkcode LoaderContext} instead. */
|
|
163
|
+
type Context = LoaderContext;
|
|
164
|
+
type LoaderContext = Command.LoaderContext;
|
|
165
|
+
type RunInTypes = Command.RunInTypes;
|
|
166
|
+
type ChatInputCommandInteraction<Cached extends CacheType = CacheType> = Command.ChatInputCommandInteraction<Cached>;
|
|
167
|
+
type ContextMenuCommandInteraction<Cached extends CacheType = CacheType> = Command.ContextMenuCommandInteraction<Cached>;
|
|
168
|
+
type AutocompleteInteraction<Cached extends CacheType = CacheType> = Command.AutocompleteInteraction<Cached>;
|
|
169
|
+
type Registry = Command.Registry;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The context for the subcommand cooldown precondition
|
|
174
|
+
* @since 5.1.0
|
|
175
|
+
*/
|
|
176
|
+
interface SubcommandCooldownPreconditionContext 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: SubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
190
|
+
chatInputRun(interaction: ChatInputCommandInteraction, subcommand: Subcommand, context: SubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
191
|
+
contextMenuRun(interaction: ContextMenuCommandInteraction, subcommand: Command, context: SubcommandCooldownPreconditionContext): AllFlowsPrecondition.Result;
|
|
192
|
+
private sharedRun;
|
|
193
|
+
private getIdFromMessage;
|
|
194
|
+
private getIdFromInteraction;
|
|
195
|
+
private getSubcommandMappingName;
|
|
196
|
+
private getManager;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** The options for adding this subcommand cooldown precondition */
|
|
200
|
+
interface ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> {
|
|
201
|
+
/** The command to parse cooldowns for. */
|
|
202
|
+
subcommand: Subcommand<PreParseReturn, Options>;
|
|
203
|
+
/** The cooldown limit to use. */
|
|
204
|
+
cooldownLimit: number | undefined;
|
|
205
|
+
/** The cooldown delay to use. */
|
|
206
|
+
cooldownDelay: number | undefined;
|
|
207
|
+
/** The cooldown scope to use. */
|
|
208
|
+
cooldownScope: BucketScope | undefined;
|
|
209
|
+
/** The cooldown filtered users to use. */
|
|
210
|
+
cooldownFilteredUsers: string[] | undefined;
|
|
211
|
+
/** The name this precondition is for. */
|
|
212
|
+
subcommandMethodName: string;
|
|
213
|
+
/** The group this precondition is for, if any. */
|
|
214
|
+
subcommandGroupName?: string;
|
|
215
|
+
/** The precondition container array to append the precondition to. */
|
|
216
|
+
preconditionContainerArray: PreconditionContainerArray;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Appends the `SubcommandCooldown` precondition when {@link Subcommand.Options.cooldownLimit} and
|
|
220
|
+
* {@link Subcommand.Options.cooldownDelay} are both non-zero.
|
|
221
|
+
*
|
|
222
|
+
* @param options The {@link ParseSubcommandConstructorPreConditionsCooldownParameters} for adding this subcommand cooldown precondition
|
|
223
|
+
*/
|
|
224
|
+
declare function parseSubcommandConstructorPreConditionsCooldown<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options>({ subcommand: command, cooldownLimit, cooldownDelay, cooldownScope, cooldownFilteredUsers, subcommandMethodName, subcommandGroupName, preconditionContainerArray }: ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn, Options>): void;
|
|
225
|
+
|
|
226
|
+
type subcommandCooldown_ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> = ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn, Options>;
|
|
227
|
+
declare const subcommandCooldown_parseSubcommandConstructorPreConditionsCooldown: typeof parseSubcommandConstructorPreConditionsCooldown;
|
|
228
|
+
declare namespace subcommandCooldown {
|
|
229
|
+
export { type subcommandCooldown_ParseSubcommandConstructorPreConditionsCooldownParameters as ParseSubcommandConstructorPreConditionsCooldownParameters, subcommandCooldown_parseSubcommandConstructorPreConditionsCooldown as parseSubcommandConstructorPreConditionsCooldown };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The available command pre-conditions.
|
|
234
|
+
* @since 2.0.0
|
|
235
|
+
*/
|
|
236
|
+
declare enum SubcommandCommandPreConditions {
|
|
237
|
+
SubcommandCooldown = "SubcommandCooldown"
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The available subcommand pre-conditions.
|
|
241
|
+
* @since 5.1.0
|
|
242
|
+
*/
|
|
243
|
+
declare enum SubcommandIdentifiers {
|
|
244
|
+
/** The identifier for the subcommand cooldown precondition */
|
|
245
|
+
SubcommandPreconditionCooldown = "subcommandPreconditionCooldown"
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare const SubcommandPluginEvents: {
|
|
249
|
+
ChatInputSubcommandDenied: "chatInputSubcommandDenied";
|
|
250
|
+
ChatInputSubcommandRun: "chatInputSubcommandRun";
|
|
251
|
+
ChatInputSubcommandSuccess: "chatInputSubcommandSuccess";
|
|
252
|
+
ChatInputSubcommandError: "chatInputSubcommandError";
|
|
253
|
+
MessageSubcommandDenied: "messageSubcommandDenied";
|
|
254
|
+
MessageSubcommandRun: "messageSubcommandRun";
|
|
255
|
+
MessageSubcommandSuccess: "messageSubcommandSuccess";
|
|
256
|
+
MessageSubcommandError: "messageSubcommandError";
|
|
257
|
+
SubcommandMappingIsMissingMessageCommandHandler: "subcommandMappingIsMissingMessageCommandHandler";
|
|
258
|
+
SubcommandMappingIsMissingChatInputCommandHandler: "subcommandMappingIsMissingChatInputCommandHandler";
|
|
259
|
+
};
|
|
260
|
+
declare enum SubcommandPluginIdentifiers {
|
|
261
|
+
MessageSubcommandNoMatch = "messageSubcommandNoMatch",
|
|
262
|
+
ChatInputSubcommandNoMatch = "chatInputSubcommandNoMatch",
|
|
263
|
+
SubcommandNotFound = "subcommandNotFound"
|
|
264
|
+
}
|
|
265
|
+
interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {
|
|
266
|
+
possibleSubcommandName: string | null;
|
|
267
|
+
possibleSubcommandGroupOrName: string | null;
|
|
268
|
+
}
|
|
269
|
+
interface IMessageSubcommandPayload {
|
|
270
|
+
message: Message;
|
|
271
|
+
command: Subcommand;
|
|
272
|
+
}
|
|
273
|
+
interface MessageSubcommandDeniedPayload extends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'>, MessageSubcommandAcceptedPayload {
|
|
274
|
+
parameters?: string;
|
|
275
|
+
}
|
|
276
|
+
interface MessageSubcommandAcceptedPayload extends IMessageSubcommandPayload {
|
|
277
|
+
context: MessageCommand.RunContext;
|
|
278
|
+
matchedSubcommandMapping: SubcommandMappingMethod;
|
|
279
|
+
}
|
|
280
|
+
interface MessageSubcommandRunPayload extends MessageSubcommandAcceptedPayload {
|
|
281
|
+
}
|
|
282
|
+
interface MessageSubcommandErrorPayload extends MessageSubcommandRunPayload {
|
|
283
|
+
}
|
|
284
|
+
interface MessageSubcommandSuccessPayload extends MessageSubcommandRunPayload {
|
|
285
|
+
result: unknown;
|
|
286
|
+
}
|
|
287
|
+
interface IChatInputSubcommandPayload {
|
|
288
|
+
interaction: ChatInputCommand.Interaction;
|
|
289
|
+
command: Subcommand;
|
|
290
|
+
}
|
|
291
|
+
interface ChatInputSubcommandAcceptedPayload extends IChatInputSubcommandPayload {
|
|
292
|
+
context: ChatInputCommand.RunContext;
|
|
293
|
+
matchedSubcommandMapping: SubcommandMappingMethod;
|
|
294
|
+
}
|
|
295
|
+
interface ChatInputSubcommandDeniedPayload extends ChatInputSubcommandAcceptedPayload {
|
|
296
|
+
}
|
|
297
|
+
interface ChatInputSubcommandRunPayload extends ChatInputSubcommandAcceptedPayload {
|
|
298
|
+
}
|
|
299
|
+
interface ChatInputSubcommandErrorPayload extends ChatInputSubcommandRunPayload {
|
|
300
|
+
}
|
|
301
|
+
interface ChatInputSubcommandSuccessPayload extends ChatInputSubcommandRunPayload {
|
|
302
|
+
result: unknown;
|
|
303
|
+
}
|
|
304
|
+
declare module 'discord.js' {
|
|
305
|
+
interface ClientEvents {
|
|
306
|
+
[SubcommandPluginEvents.ChatInputSubcommandDenied]: [error: UserError, payload: ChatInputSubcommandDeniedPayload];
|
|
307
|
+
[SubcommandPluginEvents.ChatInputSubcommandRun]: [
|
|
308
|
+
interaction: ChatInputCommand.Interaction,
|
|
309
|
+
subcommand: ChatInputCommandSubcommandMappingMethod,
|
|
310
|
+
payload: ChatInputSubcommandRunPayload
|
|
311
|
+
];
|
|
312
|
+
[SubcommandPluginEvents.ChatInputSubcommandSuccess]: [
|
|
313
|
+
interaction: ChatInputCommand.Interaction,
|
|
314
|
+
subcommand: ChatInputCommandSubcommandMappingMethod,
|
|
315
|
+
payload: ChatInputSubcommandSuccessPayload
|
|
316
|
+
];
|
|
317
|
+
[SubcommandPluginEvents.ChatInputSubcommandError]: [error: unknown, payload: ChatInputSubcommandErrorPayload];
|
|
318
|
+
[SubcommandPluginEvents.MessageSubcommandDenied]: [error: UserError, payload: MessageSubcommandDeniedPayload];
|
|
319
|
+
[SubcommandPluginEvents.MessageSubcommandRun]: [
|
|
320
|
+
message: Message,
|
|
321
|
+
subcommand: MessageSubcommandMappingMethod,
|
|
322
|
+
payload: MessageSubcommandRunPayload
|
|
323
|
+
];
|
|
324
|
+
[SubcommandPluginEvents.MessageSubcommandSuccess]: [
|
|
325
|
+
message: Message,
|
|
326
|
+
subcommand: MessageSubcommandMappingMethod,
|
|
327
|
+
payload: MessageSubcommandSuccessPayload
|
|
328
|
+
];
|
|
329
|
+
[SubcommandPluginEvents.MessageSubcommandError]: [error: unknown, payload: MessageSubcommandErrorPayload];
|
|
330
|
+
[SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler]: [
|
|
331
|
+
message: Message,
|
|
332
|
+
subcommand: SubcommandMappingMethod,
|
|
333
|
+
payload: MessageSubcommandAcceptedPayload
|
|
334
|
+
];
|
|
335
|
+
[SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler]: [
|
|
336
|
+
message: ChatInputCommand.Interaction,
|
|
337
|
+
subcommand: SubcommandMappingMethod,
|
|
338
|
+
payload: ChatInputSubcommandAcceptedPayload
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
declare function loadListeners(): void;
|
|
344
|
+
|
|
345
|
+
declare function loadPreconditions(): void;
|
|
346
|
+
|
|
347
|
+
declare module 'discord.js' {
|
|
348
|
+
interface ClientOptions {
|
|
349
|
+
/**
|
|
350
|
+
* If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance
|
|
351
|
+
* @since 3.1.2
|
|
352
|
+
* @default true
|
|
353
|
+
*/
|
|
354
|
+
loadSubcommandErrorListeners?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Sets the default cooldown time for all subcommands.
|
|
357
|
+
* @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands
|
|
358
|
+
* @remark Note that for the `filteredCommands` option you have to provide it as
|
|
359
|
+
* - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).
|
|
360
|
+
* - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).
|
|
361
|
+
* @since 5.1.0
|
|
362
|
+
* @default "No cooldown options"
|
|
363
|
+
*/
|
|
364
|
+
subcommandDefaultCooldown?: CooldownOptions;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
declare module '@sapphire/framework' {
|
|
368
|
+
interface Preconditions {
|
|
369
|
+
SubcommandCooldown: SubcommandPreconditions.SubcommandCooldownContext;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The preconditions specific to subcommands
|
|
374
|
+
* @since 5.1.0
|
|
375
|
+
*/
|
|
376
|
+
declare const SubcommandPreconditions: {
|
|
377
|
+
SubcommandCooldown: typeof PluginPrecondition;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* The preconditions specific to subcommands
|
|
381
|
+
* @since 5.1.0
|
|
382
|
+
*/
|
|
383
|
+
declare namespace SubcommandPreconditions {
|
|
384
|
+
/** The context for the subcommand cooldown precondition */
|
|
385
|
+
type SubcommandCooldownContext = SubcommandCooldownPreconditionContext;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.
|
|
389
|
+
* An example use of this is showing it of in a bot information command.
|
|
390
|
+
*
|
|
391
|
+
* Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild
|
|
392
|
+
*/
|
|
393
|
+
declare const version: string;
|
|
394
|
+
|
|
395
|
+
export { type ChatInputCommandSubcommandMappingMethod, type ChatInputSubcommandAcceptedPayload, type ChatInputSubcommandDeniedPayload, type ChatInputSubcommandErrorPayload, type ChatInputSubcommandRunPayload, type ChatInputSubcommandSuccessPayload, type IChatInputSubcommandPayload, type IMessageSubcommandPayload, type MessageSubcommandAcceptedPayload, type MessageSubcommandDeniedPayload, type MessageSubcommandErrorPayload, type MessageSubcommandMappingMethod, type MessageSubcommandNoMatchContext, type MessageSubcommandRunPayload, type MessageSubcommandSuccessPayload, Subcommand, SubcommandCommandPreConditions, SubcommandIdentifiers, type SubcommandMapping, type SubcommandMappingArray, type SubcommandMappingGroup, type SubcommandMappingMethod, type SubcommandOptions, SubcommandPluginEvents, SubcommandPluginIdentifiers, subcommandCooldown as SubcommandPreconditionResolvers, SubcommandPreconditions, loadListeners, loadPreconditions, version };
|