@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
package/dist/lib/Subcommand.js
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var _Subcommand_instances, _Subcommand_getMessageParametersAsString, _Subcommand_handleMessageRun, _Subcommand_handleChatInputInteractionRun, _Subcommand_findSubcommand, _Subcommand_supportsCommandType;
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Subcommand = void 0;
|
|
10
|
-
const framework_1 = require("@sapphire/framework");
|
|
11
|
-
const utilities_1 = require("@sapphire/utilities");
|
|
12
|
-
const index_1 = require("../index");
|
|
13
|
-
const Events_1 = require("./types/Events");
|
|
14
|
-
/**
|
|
15
|
-
* The class to extends for commands that have subcommands.
|
|
16
|
-
* Specify the subcommands through the {@link Subcommand.Options.subcommands} option.
|
|
17
|
-
*
|
|
18
|
-
* Note that you should not make **all** your commands extend this class, _only_ the ones that have subcommands.
|
|
19
|
-
* The reason for this is that this class implements {@link Command.messageRun} and {@link Command.chatInputRun}
|
|
20
|
-
* which you wouldn't necessarily want to do for commands that don't have subcommands.
|
|
21
|
-
* Furthermore, it also just adds general unnecessary memory overhead.
|
|
22
|
-
*/
|
|
23
|
-
class Subcommand extends framework_1.Command {
|
|
24
|
-
constructor(context, options) {
|
|
25
|
-
// #region Base parsing
|
|
26
|
-
super(context, options);
|
|
27
|
-
_Subcommand_instances.add(this);
|
|
28
|
-
/**
|
|
29
|
-
* The preconditions to be run for each specified subcommand.
|
|
30
|
-
* @since 4.1.0
|
|
31
|
-
*/
|
|
32
|
-
Object.defineProperty(this, "subcommandPreconditions", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: new Map()
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* The parsed subcommand mappings that were provided with the {@link SubcommandOptions.subcommands} option.
|
|
40
|
-
* This is built at construction time and is used to determine which subcommand to run.
|
|
41
|
-
*/
|
|
42
|
-
Object.defineProperty(this, "parsedSubcommandMappings", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Whether to use case insensitive subcommands. This is only relevant for message-command styled commands as
|
|
50
|
-
* chat input commands are always lowercase. This can be enabled through `clientOptions.caseInsensitiveCommands`.
|
|
51
|
-
*/
|
|
52
|
-
Object.defineProperty(this, "caseInsensitiveSubcommands", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: false
|
|
57
|
-
});
|
|
58
|
-
this.parsedSubcommandMappings = options.subcommands ?? [];
|
|
59
|
-
const clientOptions = this.container.client.options;
|
|
60
|
-
// #endregion
|
|
61
|
-
// #region Case Insensitive Commands
|
|
62
|
-
if (clientOptions.caseInsensitiveCommands) {
|
|
63
|
-
this.caseInsensitiveSubcommands = true;
|
|
64
|
-
// Because slash commands must be lowercase anyway, we can transform all to lowercase.
|
|
65
|
-
for (const cmd of this.parsedSubcommandMappings) {
|
|
66
|
-
cmd.name = cmd.name.toLowerCase();
|
|
67
|
-
if (cmd.type === 'group') {
|
|
68
|
-
for (const groupCommand of cmd.entries) {
|
|
69
|
-
groupCommand.name = groupCommand.name.toLowerCase();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// #endregion
|
|
75
|
-
// #region Generate Dashless Aliases
|
|
76
|
-
if (options.generateDashLessAliases) {
|
|
77
|
-
for (const mapping of this.parsedSubcommandMappings) {
|
|
78
|
-
if (!Reflect.has(mapping, 'messageRun')) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const dashLessMappings = [];
|
|
82
|
-
if (mapping.type === 'group') {
|
|
83
|
-
// Keep track of whether we have changed entries or not, so we don't need to do expensive object comparison later.
|
|
84
|
-
let hasChangedEntries = null;
|
|
85
|
-
// Deeply clone the entire mapping to avoid mutating the original.
|
|
86
|
-
const clonedMapping = (0, utilities_1.deepClone)(mapping);
|
|
87
|
-
// Loop through the group's subcommands and add a dash-less alias for each, if applicable.
|
|
88
|
-
for (const groupCommand of mapping.entries) {
|
|
89
|
-
if (groupCommand.name.includes('-')) {
|
|
90
|
-
// If we are inside this if statement then we flip `hasChangedEntries` to true to be able to read it later.
|
|
91
|
-
hasChangedEntries ?? (hasChangedEntries = true);
|
|
92
|
-
clonedMapping.entries.push({
|
|
93
|
-
...groupCommand,
|
|
94
|
-
name: groupCommand.name.replaceAll('-', '')
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* If any of the entries in the group had a dash then `hasChangedEntries` was flipped to true
|
|
100
|
-
* and so we want to register a mapping with the base name and all dash-less entries
|
|
101
|
-
* in the group.
|
|
102
|
-
*/
|
|
103
|
-
if (hasChangedEntries) {
|
|
104
|
-
dashLessMappings.push({
|
|
105
|
-
...mapping,
|
|
106
|
-
entries: clonedMapping.entries
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* If the group name itself has a dash then register a dash-less copy of it.
|
|
111
|
-
* If the entries in the group didn't have any dashes then `clonedMapping.entries` is still
|
|
112
|
-
* the same original array, so it can be safely overwritten.
|
|
113
|
-
*
|
|
114
|
-
* If the entries in the group did have any dashes then `clonedMapping.entries` has
|
|
115
|
-
* all entries both with and without dashes.
|
|
116
|
-
*/
|
|
117
|
-
if (clonedMapping.name.includes('-')) {
|
|
118
|
-
clonedMapping.name = clonedMapping.name.replaceAll('-', '');
|
|
119
|
-
dashLessMappings.push(clonedMapping);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else if (mapping.name.includes('-')) {
|
|
123
|
-
dashLessMappings.push({
|
|
124
|
-
...mapping,
|
|
125
|
-
name: mapping.name.replaceAll('-', '')
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// For every dash-less mapping, push a new subcommand
|
|
129
|
-
for (const dashLessMapping of dashLessMappings) {
|
|
130
|
-
this.parsedSubcommandMappings.push(dashLessMapping);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// #endregion
|
|
135
|
-
// #region Subcommand Preconditions
|
|
136
|
-
for (const subcommand of this.parsedSubcommandMappings) {
|
|
137
|
-
subcommand.type ?? (subcommand.type = 'method');
|
|
138
|
-
if (subcommand.type === 'method') {
|
|
139
|
-
const preconditionContainerArray = new framework_1.PreconditionContainerArray(subcommand.preconditions);
|
|
140
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRunIn(subcommand.runIn, this.resolveConstructorPreConditionsRunType.bind(this), preconditionContainerArray);
|
|
141
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsNsfw(subcommand.nsfw, preconditionContainerArray);
|
|
142
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(subcommand.requiredClientPermissions, preconditionContainerArray);
|
|
143
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(subcommand.requiredUserPermissions, preconditionContainerArray);
|
|
144
|
-
index_1.SubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({
|
|
145
|
-
subcommand: this,
|
|
146
|
-
cooldownDelay: subcommand.cooldownDelay,
|
|
147
|
-
cooldownFilteredUsers: subcommand.cooldownFilteredUsers,
|
|
148
|
-
cooldownLimit: subcommand.cooldownLimit,
|
|
149
|
-
cooldownScope: subcommand.cooldownScope,
|
|
150
|
-
subcommandMethodName: subcommand.name,
|
|
151
|
-
preconditionContainerArray
|
|
152
|
-
});
|
|
153
|
-
this.subcommandPreconditions.set(subcommand.name, preconditionContainerArray);
|
|
154
|
-
}
|
|
155
|
-
if (subcommand.type === 'group') {
|
|
156
|
-
for (const groupedSubcommand of subcommand.entries) {
|
|
157
|
-
const preconditionContainerArray = new framework_1.PreconditionContainerArray(groupedSubcommand.preconditions);
|
|
158
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRunIn(groupedSubcommand.runIn, this.resolveConstructorPreConditionsRunType.bind(this), preconditionContainerArray);
|
|
159
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsNsfw(groupedSubcommand.nsfw, preconditionContainerArray);
|
|
160
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(groupedSubcommand.requiredClientPermissions, preconditionContainerArray);
|
|
161
|
-
framework_1.PreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(groupedSubcommand.requiredUserPermissions, preconditionContainerArray);
|
|
162
|
-
index_1.SubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({
|
|
163
|
-
subcommand: this,
|
|
164
|
-
cooldownDelay: groupedSubcommand.cooldownDelay,
|
|
165
|
-
cooldownFilteredUsers: groupedSubcommand.cooldownFilteredUsers,
|
|
166
|
-
cooldownLimit: groupedSubcommand.cooldownLimit,
|
|
167
|
-
cooldownScope: groupedSubcommand.cooldownScope,
|
|
168
|
-
subcommandGroupName: subcommand.name,
|
|
169
|
-
subcommandMethodName: groupedSubcommand.name,
|
|
170
|
-
preconditionContainerArray
|
|
171
|
-
});
|
|
172
|
-
this.subcommandPreconditions.set(`${subcommand.name}.${groupedSubcommand.name}`, preconditionContainerArray);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// #endregion
|
|
177
|
-
}
|
|
178
|
-
onLoad() {
|
|
179
|
-
super.onLoad();
|
|
180
|
-
const externalMapping = Reflect.get(this, 'subcommandMappings');
|
|
181
|
-
if (externalMapping) {
|
|
182
|
-
const subcommands = Array.isArray(externalMapping) ? externalMapping : [];
|
|
183
|
-
this.parsedSubcommandMappings = subcommands;
|
|
184
|
-
this.options.subcommands = subcommands;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Whether this command has message-based subcommands or not
|
|
189
|
-
* @returns `true` if this command has message-based subcommands, otherwise `false`
|
|
190
|
-
*/
|
|
191
|
-
supportsMessageCommands() {
|
|
192
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_supportsCommandType).call(this, 'messageRun');
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Whether this command has chat input subcommands or not
|
|
196
|
-
* @returns `true` if this command has chat input subcommands, otherwise `false`
|
|
197
|
-
*/
|
|
198
|
-
supportsChatInputCommands() {
|
|
199
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_supportsCommandType).call(this, 'chatInputRun');
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* The method that is ran when a message-based subcommand is ran.
|
|
203
|
-
*
|
|
204
|
-
* **DO NOT** override this in your implementation of a subcommand!
|
|
205
|
-
*/
|
|
206
|
-
async messageRun(message, args, context) {
|
|
207
|
-
args.save();
|
|
208
|
-
const subcommandOrGroup = args.nextMaybe();
|
|
209
|
-
const subcommandName = args.nextMaybe();
|
|
210
|
-
let defaultCommand = null;
|
|
211
|
-
let actualSubcommandToRun = null;
|
|
212
|
-
let matchedWithGroupedSubcommand = false;
|
|
213
|
-
for (const mapping of this.parsedSubcommandMappings) {
|
|
214
|
-
mapping.type ?? (mapping.type = 'method');
|
|
215
|
-
if (mapping.type === 'method') {
|
|
216
|
-
if (mapping.default && !defaultCommand) {
|
|
217
|
-
matchedWithGroupedSubcommand = false;
|
|
218
|
-
defaultCommand = mapping;
|
|
219
|
-
}
|
|
220
|
-
if (subcommandOrGroup.isSomeAnd((value) => mapping.name === (this.caseInsensitiveSubcommands ? value.toLowerCase() : value))) {
|
|
221
|
-
actualSubcommandToRun = mapping;
|
|
222
|
-
matchedWithGroupedSubcommand = false;
|
|
223
|
-
// Exit early
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
// We expect a group mapping
|
|
228
|
-
if (mapping.type === 'group' && subcommandOrGroup.isSome() && subcommandName.isSome()) {
|
|
229
|
-
const unwrappedSubcommandGroupName = subcommandOrGroup.unwrap();
|
|
230
|
-
const unwrappedSubcommandName = subcommandName.unwrap();
|
|
231
|
-
// We know a group was passed in here
|
|
232
|
-
if (mapping.name === unwrappedSubcommandGroupName) {
|
|
233
|
-
// Find the actual subcommand to run
|
|
234
|
-
const findResult = __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_findSubcommand).call(this, mapping.entries, this.caseInsensitiveSubcommands ? unwrappedSubcommandName.toLowerCase() : unwrappedSubcommandName);
|
|
235
|
-
if (findResult.defaultMatch) {
|
|
236
|
-
defaultCommand = findResult.mapping;
|
|
237
|
-
matchedWithGroupedSubcommand = true;
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
actualSubcommandToRun = findResult.mapping;
|
|
241
|
-
matchedWithGroupedSubcommand = true;
|
|
242
|
-
// Exit early
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
// Preemptively restore the args state, to provide a correct args result for users
|
|
249
|
-
args.restore();
|
|
250
|
-
if (actualSubcommandToRun) {
|
|
251
|
-
// Skip over the subcommandOrGroup
|
|
252
|
-
args.next();
|
|
253
|
-
// If we matched with a subcommand in a group we need to skip 1 more arg
|
|
254
|
-
let subcommandGroupName = undefined;
|
|
255
|
-
if (matchedWithGroupedSubcommand) {
|
|
256
|
-
subcommandGroupName = subcommandOrGroup.unwrap();
|
|
257
|
-
args.next();
|
|
258
|
-
}
|
|
259
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_handleMessageRun).call(this, message, args, context, actualSubcommandToRun, subcommandGroupName);
|
|
260
|
-
}
|
|
261
|
-
// No subcommand matched, let's try to run default, if any:
|
|
262
|
-
if (defaultCommand) {
|
|
263
|
-
// If we matched with a subcommand in a group we need to skip 1 the group name
|
|
264
|
-
let subcommandGroupName = undefined;
|
|
265
|
-
if (matchedWithGroupedSubcommand) {
|
|
266
|
-
subcommandGroupName = subcommandOrGroup.unwrap();
|
|
267
|
-
args.next();
|
|
268
|
-
}
|
|
269
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_handleMessageRun).call(this, message, args, context, defaultCommand, subcommandGroupName);
|
|
270
|
-
}
|
|
271
|
-
// No match and no subcommand, return an err:
|
|
272
|
-
throw new framework_1.UserError({
|
|
273
|
-
identifier: Events_1.SubcommandPluginIdentifiers.MessageSubcommandNoMatch,
|
|
274
|
-
message: 'No subcommand was matched with the provided arguments.',
|
|
275
|
-
context: {
|
|
276
|
-
...context,
|
|
277
|
-
possibleSubcommandName: subcommandName.unwrapOr(null),
|
|
278
|
-
possibleSubcommandGroupOrName: subcommandOrGroup.unwrapOr(null)
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* The method that is ran when a chat input based subcommand is ran.
|
|
284
|
-
*
|
|
285
|
-
* **DO NOT** override this in your implementation of a subcommand!
|
|
286
|
-
*/
|
|
287
|
-
async chatInputRun(interaction, context) {
|
|
288
|
-
const subcommandName = interaction.options.getSubcommand(false);
|
|
289
|
-
const subcommandGroupName = interaction.options.getSubcommandGroup(false);
|
|
290
|
-
for (const mapping of this.parsedSubcommandMappings) {
|
|
291
|
-
mapping.type ?? (mapping.type = 'method');
|
|
292
|
-
// If we have a group, we know we also have a subcommand and we should find and run it
|
|
293
|
-
if (subcommandGroupName && subcommandName) {
|
|
294
|
-
if (mapping.type !== 'group')
|
|
295
|
-
continue;
|
|
296
|
-
if (mapping.name !== subcommandGroupName)
|
|
297
|
-
continue;
|
|
298
|
-
const foundSubcommand = __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_findSubcommand).call(this, mapping.entries, subcommandName);
|
|
299
|
-
// Only run if its not the "default" found command mapping, as interactions don't have that
|
|
300
|
-
if (!foundSubcommand.defaultMatch) {
|
|
301
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_handleChatInputInteractionRun).call(this, interaction, context, foundSubcommand.mapping, subcommandGroupName);
|
|
302
|
-
}
|
|
303
|
-
// Skip to the next entry
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
// If we have a direct subcommand, and no group, then run the mapping
|
|
307
|
-
if (mapping.type === 'method' && mapping.name === subcommandName) {
|
|
308
|
-
return __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_handleChatInputInteractionRun).call(this, interaction, context, mapping, undefined);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
// No match and no subcommand, return an err:
|
|
312
|
-
throw new framework_1.UserError({
|
|
313
|
-
identifier: Events_1.SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch,
|
|
314
|
-
message: 'No subcommand was matched with the provided command.',
|
|
315
|
-
context
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
exports.Subcommand = Subcommand;
|
|
320
|
-
_Subcommand_instances = new WeakSet(), _Subcommand_getMessageParametersAsString = async function _Subcommand_getMessageParametersAsString(args) {
|
|
321
|
-
args.save();
|
|
322
|
-
const parameters = await args.restResult('string');
|
|
323
|
-
args.restore();
|
|
324
|
-
const params = {};
|
|
325
|
-
if (parameters.isOk()) {
|
|
326
|
-
params.parameters = parameters.unwrap();
|
|
327
|
-
}
|
|
328
|
-
return params;
|
|
329
|
-
}, _Subcommand_handleMessageRun = async function _Subcommand_handleMessageRun(message, args, context, subcommand, subcommandGroupName) {
|
|
330
|
-
const payload = {
|
|
331
|
-
message,
|
|
332
|
-
command: this,
|
|
333
|
-
context,
|
|
334
|
-
matchedSubcommandMapping: subcommand
|
|
335
|
-
};
|
|
336
|
-
// Check if any subcommand preconditions were defined for thus subcommand:
|
|
337
|
-
const preconditionsForSubcommand = this.subcommandPreconditions.get(subcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name);
|
|
338
|
-
if (preconditionsForSubcommand) {
|
|
339
|
-
// Attempt to get the remaining parameters as string:
|
|
340
|
-
const messageParametersAsString = await __classPrivateFieldGet(this, _Subcommand_instances, "m", _Subcommand_getMessageParametersAsString).call(this, args);
|
|
341
|
-
// Build the precondition payload:
|
|
342
|
-
const preconditionPayload = { ...messageParametersAsString, ...payload };
|
|
343
|
-
// Run the subcommand specific preconditions:
|
|
344
|
-
const localSubcommandResult = await preconditionsForSubcommand.messageRun(message, this, preconditionPayload);
|
|
345
|
-
if (localSubcommandResult.isErr()) {
|
|
346
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.MessageSubcommandDenied, localSubcommandResult.unwrapErr(), preconditionPayload);
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
// If subcommand preconditions have passed then we run the actual subcommand:
|
|
351
|
-
const result = await framework_1.Result.fromAsync(async () => {
|
|
352
|
-
if (subcommand.messageRun) {
|
|
353
|
-
const casted = subcommand;
|
|
354
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.MessageSubcommandRun, message, casted, payload);
|
|
355
|
-
let result;
|
|
356
|
-
if (typeof subcommand.messageRun === 'string') {
|
|
357
|
-
const method = Reflect.get(this, subcommand.messageRun);
|
|
358
|
-
if (!method) {
|
|
359
|
-
throw new framework_1.UserError({
|
|
360
|
-
identifier: Events_1.SubcommandPluginIdentifiers.SubcommandNotFound,
|
|
361
|
-
message: `The method configured at "messageRun" for the subcommand ${subcommand.name} was not implemented in the class.`,
|
|
362
|
-
context: { ...payload }
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
result = await Reflect.apply((0, utilities_1.cast)(method), this, [message, args, context]);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
result = await subcommand.messageRun(message, args, context);
|
|
369
|
-
}
|
|
370
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.MessageSubcommandSuccess, message, casted, { ...payload, result });
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler, message, subcommand, payload);
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
result.inspectErr((error) => this.container.client.emit(Events_1.SubcommandPluginEvents.MessageSubcommandError, error, payload));
|
|
377
|
-
}, _Subcommand_handleChatInputInteractionRun = async function _Subcommand_handleChatInputInteractionRun(interaction, context, subcommand, subcommandGroupName) {
|
|
378
|
-
const payload = {
|
|
379
|
-
command: this,
|
|
380
|
-
context,
|
|
381
|
-
interaction,
|
|
382
|
-
matchedSubcommandMapping: subcommand
|
|
383
|
-
};
|
|
384
|
-
// Check if any subcommand preconditions were defined for thus subcommand:
|
|
385
|
-
const preconditionsForSubcommand = this.subcommandPreconditions.get(subcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name);
|
|
386
|
-
if (preconditionsForSubcommand) {
|
|
387
|
-
// Run the subcommand specific preconditions:
|
|
388
|
-
const localSubcommandResult = await preconditionsForSubcommand.chatInputRun(interaction, this, payload);
|
|
389
|
-
if (localSubcommandResult.isErr()) {
|
|
390
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.ChatInputSubcommandDenied, localSubcommandResult.unwrapErr(), payload);
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
const result = await framework_1.Result.fromAsync(async () => {
|
|
395
|
-
if (subcommand.chatInputRun) {
|
|
396
|
-
const casted = subcommand;
|
|
397
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.ChatInputSubcommandRun, interaction, casted, payload);
|
|
398
|
-
let result;
|
|
399
|
-
if (typeof subcommand.chatInputRun === 'string') {
|
|
400
|
-
const method = Reflect.get(this, subcommand.chatInputRun);
|
|
401
|
-
if (!method) {
|
|
402
|
-
throw new framework_1.UserError({
|
|
403
|
-
identifier: Events_1.SubcommandPluginIdentifiers.SubcommandNotFound,
|
|
404
|
-
message: `The method configured at "chatInputRun" for the subcommand ${subcommand.name} was not implemented in the class.`,
|
|
405
|
-
context: { ...payload }
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
result = await Reflect.apply((0, utilities_1.cast)(method), this, [interaction, context]);
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
result = await subcommand.chatInputRun(interaction, context);
|
|
412
|
-
}
|
|
413
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.ChatInputSubcommandSuccess, interaction, casted, { ...payload, result });
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
this.container.client.emit(Events_1.SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler, interaction, subcommand, payload);
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
result.inspectErr((error) => this.container.client.emit(Events_1.SubcommandPluginEvents.ChatInputSubcommandError, error, payload));
|
|
420
|
-
}, _Subcommand_findSubcommand = function _Subcommand_findSubcommand(mappings, expectedName) {
|
|
421
|
-
let foundDefault = null;
|
|
422
|
-
for (const mapping of mappings) {
|
|
423
|
-
mapping.type ?? (mapping.type = 'method');
|
|
424
|
-
if (mapping.default) {
|
|
425
|
-
foundDefault = mapping;
|
|
426
|
-
}
|
|
427
|
-
if (mapping.name === expectedName) {
|
|
428
|
-
return { mapping, defaultMatch: false };
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return { mapping: foundDefault, defaultMatch: true };
|
|
432
|
-
}, _Subcommand_supportsCommandType = function _Subcommand_supportsCommandType(commandType) {
|
|
433
|
-
return this.parsedSubcommandMappings.some((mapping) => {
|
|
434
|
-
if (mapping.type === 'group') {
|
|
435
|
-
return mapping.entries.some((groupCommand) => Reflect.has(groupCommand, commandType));
|
|
436
|
-
}
|
|
437
|
-
return Reflect.has(mapping, commandType);
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
//# sourceMappingURL=Subcommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Subcommand.js","sourceRoot":"","sources":["../../src/lib/Subcommand.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAU6B;AAC7B,mDAAsD;AAEtD,oCAA2D;AAC3D,2CAKwB;AAQxB;;;;;;;;GAQG;AACH,MAAa,UAAwG,SAAQ,mBAG5H;IAm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B;IACxE,IAAI,YAAY,GAAmC,IAAI,CAAC;IAExD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,KAAZ,OAAO,CAAC,IAAI,GAAK,QAAQ,EAAC;QAE1B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,YAAY,GAAG,OAAO,CAAC;QACxB,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACnC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAW,CAAC;QAClD,CAAC;IACF,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAW,CAAC;AAC/D,CAAC,6EAEoB,WAA0C;IAC9D,OAAO,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QACrD,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;QACvF,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Args, BucketScope, PreconditionContainerArray } from '@sapphire/framework';
|
|
2
|
-
import { Subcommand } from '../Subcommand';
|
|
3
|
-
/** The options for adding this subcommand cooldown precondition */
|
|
4
|
-
export interface ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> {
|
|
5
|
-
/** The command to parse cooldowns for. */
|
|
6
|
-
subcommand: Subcommand<PreParseReturn, Options>;
|
|
7
|
-
/** The cooldown limit to use. */
|
|
8
|
-
cooldownLimit: number | undefined;
|
|
9
|
-
/** The cooldown delay to use. */
|
|
10
|
-
cooldownDelay: number | undefined;
|
|
11
|
-
/** The cooldown scope to use. */
|
|
12
|
-
cooldownScope: BucketScope | undefined;
|
|
13
|
-
/** The cooldown filtered users to use. */
|
|
14
|
-
cooldownFilteredUsers: string[] | undefined;
|
|
15
|
-
/** The name this precondition is for. */
|
|
16
|
-
subcommandMethodName: string;
|
|
17
|
-
/** The group this precondition is for, if any. */
|
|
18
|
-
subcommandGroupName?: string;
|
|
19
|
-
/** The precondition container array to append the precondition to. */
|
|
20
|
-
preconditionContainerArray: PreconditionContainerArray;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Appends the `SubcommandCooldown` precondition when {@link Subcommand.Options.cooldownLimit} and
|
|
24
|
-
* {@link Subcommand.Options.cooldownDelay} are both non-zero.
|
|
25
|
-
*
|
|
26
|
-
* @param options The {@link ParseSubcommandConstructorPreConditionsCooldownParameters} for adding this subcommand cooldown precondition
|
|
27
|
-
*/
|
|
28
|
-
export 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;
|
|
29
|
-
//# sourceMappingURL=subcommandCooldown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subcommandCooldown.d.ts","sourceRoot":"","sources":["../../../src/lib/precondition-resolvers/subcommandCooldown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,mEAAmE;AACnE,MAAM,WAAW,yDAAyD,CACzE,cAAc,SAAS,IAAI,GAAG,IAAI,EAClC,OAAO,SAAS,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO;IAEvD,0CAA0C;IAC1C,UAAU,EAAE,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAChD,iCAAiC;IACjC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iCAAiC;IACjC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iCAAiC;IACjC,aAAa,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,0CAA0C;IAC1C,qBAAqB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5C,yCAAyC;IACzC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,0BAA0B,EAAE,0BAA0B,CAAC;CACvD;AAED;;;;;GAKG;AACH,wBAAgB,+CAA+C,CAC9D,cAAc,SAAS,IAAI,GAAG,IAAI,EAClC,OAAO,SAAS,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,EACtD,EACD,UAAU,EAAE,OAAO,EACnB,aAAa,EACb,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,EAAE,yDAAyD,CAAC,cAAc,EAAE,OAAO,CAAC,QAsBpF"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSubcommandConstructorPreConditionsCooldown = void 0;
|
|
4
|
-
const framework_1 = require("@sapphire/framework");
|
|
5
|
-
const pieces_1 = require("@sapphire/pieces");
|
|
6
|
-
const Enums_1 = require("../types/Enums");
|
|
7
|
-
/**
|
|
8
|
-
* Appends the `SubcommandCooldown` precondition when {@link Subcommand.Options.cooldownLimit} and
|
|
9
|
-
* {@link Subcommand.Options.cooldownDelay} are both non-zero.
|
|
10
|
-
*
|
|
11
|
-
* @param options The {@link ParseSubcommandConstructorPreConditionsCooldownParameters} for adding this subcommand cooldown precondition
|
|
12
|
-
*/
|
|
13
|
-
function parseSubcommandConstructorPreConditionsCooldown({ subcommand: command, cooldownLimit, cooldownDelay, cooldownScope, cooldownFilteredUsers, subcommandMethodName, subcommandGroupName, preconditionContainerArray }) {
|
|
14
|
-
const { subcommandDefaultCooldown } = pieces_1.container.client.options;
|
|
15
|
-
// We will check for whether the subcommand is filtered from the defaults, but we will allow overridden values to
|
|
16
|
-
// be set. If an overridden value is passed, it will have priority. Otherwise, it will default to 0 if filtered
|
|
17
|
-
// (causing the precondition to not be registered) or the default value with a fallback to a single-use cooldown.
|
|
18
|
-
const filtered = subcommandDefaultCooldown?.filteredCommands?.includes(subcommandGroupName ? `${command.name}.${subcommandGroupName}.${subcommandMethodName}` : `${command.name}.${subcommandMethodName}`) ?? false;
|
|
19
|
-
const limit = cooldownLimit ?? (filtered ? 0 : subcommandDefaultCooldown?.limit ?? 1);
|
|
20
|
-
const delay = cooldownDelay ?? (filtered ? 0 : subcommandDefaultCooldown?.delay ?? 0);
|
|
21
|
-
if (limit && delay) {
|
|
22
|
-
const scope = cooldownScope ?? subcommandDefaultCooldown?.scope ?? framework_1.BucketScope.User;
|
|
23
|
-
const filteredUsers = cooldownFilteredUsers ?? subcommandDefaultCooldown?.filteredUsers;
|
|
24
|
-
preconditionContainerArray.append({
|
|
25
|
-
name: Enums_1.SubcommandCommandPreConditions.SubcommandCooldown,
|
|
26
|
-
context: { scope, limit, delay, filteredUsers, subcommandGroupName, subcommandMethodName }
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.parseSubcommandConstructorPreConditionsCooldown = parseSubcommandConstructorPreConditionsCooldown;
|
|
31
|
-
//# sourceMappingURL=subcommandCooldown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subcommandCooldown.js","sourceRoot":"","sources":["../../../src/lib/precondition-resolvers/subcomm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oB,EAAE;SAC1F,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAlCD,0GAkCC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The available command pre-conditions.
|
|
3
|
-
* @since 2.0.0
|
|
4
|
-
*/
|
|
5
|
-
export declare enum SubcommandCommandPreConditions {
|
|
6
|
-
SubcommandCooldown = "SubcommandCooldown"
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The available subcommand pre-conditions.
|
|
10
|
-
* @since 5.1.0
|
|
11
|
-
*/
|
|
12
|
-
export declare enum SubcommandIdentifiers {
|
|
13
|
-
/** The identifier for the subcommand cooldown precondition */
|
|
14
|
-
SubcommandPreconditionCooldown = "subcommandPreconditionCooldown"
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=Enums.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Enums.d.ts","sourceRoot":"","sources":["../../../src/lib/types/Enums.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,8BAA8B;IACzC,kBAAkB,uBAAuB;CACzC;AAED;;;GAGG;AACH,oBAAY,qBAAqB;IAChC,8DAA8D;IAC9D,8BAA8B,mCAAmC;CACjE"}
|
package/dist/lib/types/Enums.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SubcommandIdentifiers = exports.SubcommandCommandPreConditions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The available command pre-conditions.
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
*/
|
|
8
|
-
var SubcommandCommandPreConditions;
|
|
9
|
-
(function (SubcommandCommandPreConditions) {
|
|
10
|
-
SubcommandCommandPreConditions["SubcommandCooldown"] = "SubcommandCooldown";
|
|
11
|
-
})(SubcommandCommandPreConditions || (exports.SubcommandCommandPreConditions = SubcommandCommandPreConditions = {}));
|
|
12
|
-
/**
|
|
13
|
-
* The available subcommand pre-conditions.
|
|
14
|
-
* @since 5.1.0
|
|
15
|
-
*/
|
|
16
|
-
var SubcommandIdentifiers;
|
|
17
|
-
(function (SubcommandIdentifiers) {
|
|
18
|
-
/** The identifier for the subcommand cooldown precondition */
|
|
19
|
-
SubcommandIdentifiers["SubcommandPreconditionCooldown"] = "subcommandPreconditionCooldown";
|
|
20
|
-
})(SubcommandIdentifiers || (exports.SubcommandIdentifiers = SubcommandIdentifiers = {}));
|
|
21
|
-
//# sourceMappingURL=Enums.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Enums.js","sourceRoot":"","sources":["../../../src/lib/types/Enums.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,8BAEX;AAFD,WAAY,8BAA8B;IACzC,2EAAyC,CAAA;AAC1C,CAAC,EAFW,8BAA8B,8CAA9B,8BAA8B,QAEzC;AAED;;;GAGG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAChC,8DAA8D;IAC9D,0FAAiE,CAAA;AAClE,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC"}
|