@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,18 +1,14 @@
|
|
|
1
|
-
import { __name, __privateAdd, __publicField, __privateMethod } from '../chunk-
|
|
2
|
-
import { Command, PreconditionContainerArray, PreconditionResolvers,
|
|
1
|
+
import { __name, __privateAdd, __publicField, __privateMethod } from '../chunk-3IXKS7M5.mjs';
|
|
2
|
+
import { Command, PreconditionContainerArray, PreconditionResolvers, Result, UserError } from '@sapphire/framework';
|
|
3
3
|
import { deepClone, cast } from '@sapphire/utilities';
|
|
4
4
|
import { SubcommandPreconditionResolvers } from '../index.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { SubcommandPluginEvents, SubcommandPluginIdentifiers } from './types/Events.mjs';
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _Subcommand_instances, getCommandPrefix_fn, getMessageParametersAsString_fn, handleMessageRun_fn, handleChatInputInteractionRun_fn, findSubcommand_fn, supportsCommandType_fn;
|
|
8
8
|
var _Subcommand = class _Subcommand extends Command {
|
|
9
9
|
constructor(context, options) {
|
|
10
10
|
super(context, options);
|
|
11
|
-
__privateAdd(this,
|
|
12
|
-
__privateAdd(this, _handleMessageRun);
|
|
13
|
-
__privateAdd(this, _handleChatInputInteractionRun);
|
|
14
|
-
__privateAdd(this, _findSubcommand);
|
|
15
|
-
__privateAdd(this, _supportsCommandType);
|
|
11
|
+
__privateAdd(this, _Subcommand_instances);
|
|
16
12
|
/**
|
|
17
13
|
* The preconditions to be run for each specified subcommand.
|
|
18
14
|
* @since 4.1.0
|
|
@@ -155,14 +151,14 @@ var _Subcommand = class _Subcommand extends Command {
|
|
|
155
151
|
* @returns `true` if this command has message-based subcommands, otherwise `false`
|
|
156
152
|
*/
|
|
157
153
|
supportsMessageCommands() {
|
|
158
|
-
return __privateMethod(this,
|
|
154
|
+
return __privateMethod(this, _Subcommand_instances, supportsCommandType_fn).call(this, "messageRun");
|
|
159
155
|
}
|
|
160
156
|
/**
|
|
161
157
|
* Whether this command has chat input subcommands or not
|
|
162
158
|
* @returns `true` if this command has chat input subcommands, otherwise `false`
|
|
163
159
|
*/
|
|
164
160
|
supportsChatInputCommands() {
|
|
165
|
-
return __privateMethod(this,
|
|
161
|
+
return __privateMethod(this, _Subcommand_instances, supportsCommandType_fn).call(this, "chatInputRun");
|
|
166
162
|
}
|
|
167
163
|
/**
|
|
168
164
|
* The method that is ran when a message-based subcommand is ran.
|
|
@@ -193,7 +189,7 @@ var _Subcommand = class _Subcommand extends Command {
|
|
|
193
189
|
const unwrappedSubcommandGroupName = subcommandOrGroup.unwrap();
|
|
194
190
|
const unwrappedSubcommandName = subcommandName.unwrap();
|
|
195
191
|
if (mapping.name === unwrappedSubcommandGroupName) {
|
|
196
|
-
const findResult = __privateMethod(this,
|
|
192
|
+
const findResult = __privateMethod(this, _Subcommand_instances, findSubcommand_fn).call(this, mapping.entries, this.caseInsensitiveSubcommands ? unwrappedSubcommandName.toLowerCase() : unwrappedSubcommandName);
|
|
197
193
|
if (findResult.defaultMatch) {
|
|
198
194
|
defaultCommand = findResult.mapping;
|
|
199
195
|
matchedWithGroupedSubcommand = true;
|
|
@@ -213,7 +209,7 @@ var _Subcommand = class _Subcommand extends Command {
|
|
|
213
209
|
subcommandGroupName = subcommandOrGroup.unwrap();
|
|
214
210
|
args.next();
|
|
215
211
|
}
|
|
216
|
-
return __privateMethod(this,
|
|
212
|
+
return __privateMethod(this, _Subcommand_instances, handleMessageRun_fn).call(this, message, args, context, actualSubcommandToRun, subcommandGroupName);
|
|
217
213
|
}
|
|
218
214
|
if (defaultCommand) {
|
|
219
215
|
let subcommandGroupName = void 0;
|
|
@@ -221,16 +217,17 @@ var _Subcommand = class _Subcommand extends Command {
|
|
|
221
217
|
subcommandGroupName = subcommandOrGroup.unwrap();
|
|
222
218
|
args.next();
|
|
223
219
|
}
|
|
224
|
-
return __privateMethod(this,
|
|
220
|
+
return __privateMethod(this, _Subcommand_instances, handleMessageRun_fn).call(this, message, args, context, defaultCommand, subcommandGroupName);
|
|
225
221
|
}
|
|
226
|
-
|
|
222
|
+
const commandPrefix = __privateMethod(this, _Subcommand_instances, getCommandPrefix_fn).call(this, message.content, args.commandContext.prefix);
|
|
223
|
+
const prefixLessContent = message.content.slice(commandPrefix.length).trim();
|
|
224
|
+
this.container.client.emit(SubcommandPluginEvents.MessageSubcommandNoMatch, message, args, {
|
|
225
|
+
...context,
|
|
226
|
+
command: this,
|
|
227
227
|
identifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch,
|
|
228
|
-
message:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
possibleSubcommandName: subcommandName.unwrapOr(null),
|
|
232
|
-
possibleSubcommandGroupOrName: subcommandOrGroup.unwrapOr(null)
|
|
233
|
-
}
|
|
228
|
+
message: `Unable to match a subcommand on message command "${this.name}" at path "${this.location.full}" with content ${prefixLessContent}`,
|
|
229
|
+
possibleSubcommandName: subcommandName.unwrapOr(null),
|
|
230
|
+
possibleSubcommandGroupOrName: subcommandOrGroup.unwrapOr(null)
|
|
234
231
|
});
|
|
235
232
|
}
|
|
236
233
|
/**
|
|
@@ -244,28 +241,30 @@ var _Subcommand = class _Subcommand extends Command {
|
|
|
244
241
|
for (const mapping of this.parsedSubcommandMappings) {
|
|
245
242
|
mapping.type ??= "method";
|
|
246
243
|
if (subcommandGroupName && subcommandName) {
|
|
247
|
-
if (mapping.type !== "group")
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
continue;
|
|
251
|
-
const foundSubcommand = __privateMethod(this, _findSubcommand, findSubcommand_fn).call(this, mapping.entries, subcommandName);
|
|
244
|
+
if (mapping.type !== "group") continue;
|
|
245
|
+
if (mapping.name !== subcommandGroupName) continue;
|
|
246
|
+
const foundSubcommand = __privateMethod(this, _Subcommand_instances, findSubcommand_fn).call(this, mapping.entries, subcommandName);
|
|
252
247
|
if (!foundSubcommand.defaultMatch) {
|
|
253
|
-
return __privateMethod(this,
|
|
248
|
+
return __privateMethod(this, _Subcommand_instances, handleChatInputInteractionRun_fn).call(this, interaction, context, foundSubcommand.mapping, subcommandGroupName);
|
|
254
249
|
}
|
|
255
250
|
continue;
|
|
256
251
|
}
|
|
257
252
|
if (mapping.type === "method" && mapping.name === subcommandName) {
|
|
258
|
-
return __privateMethod(this,
|
|
253
|
+
return __privateMethod(this, _Subcommand_instances, handleChatInputInteractionRun_fn).call(this, interaction, context, mapping, void 0);
|
|
259
254
|
}
|
|
260
255
|
}
|
|
261
|
-
|
|
256
|
+
this.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandNoMatch, interaction, {
|
|
257
|
+
...context,
|
|
258
|
+
command: this,
|
|
262
259
|
identifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch,
|
|
263
|
-
message:
|
|
264
|
-
context
|
|
260
|
+
message: `Unable to match a subcommand on chat input command "${this.name}" at path "${this.location.full}"`
|
|
265
261
|
});
|
|
266
262
|
}
|
|
267
263
|
};
|
|
268
|
-
|
|
264
|
+
_Subcommand_instances = new WeakSet();
|
|
265
|
+
getCommandPrefix_fn = /* @__PURE__ */ __name(function(content, prefix) {
|
|
266
|
+
return typeof prefix === "string" ? prefix : prefix.exec(content)[0];
|
|
267
|
+
}, "#getCommandPrefix");
|
|
269
268
|
getMessageParametersAsString_fn = /* @__PURE__ */ __name(async function(args) {
|
|
270
269
|
args.save();
|
|
271
270
|
const parameters = await args.restResult("string");
|
|
@@ -276,7 +275,6 @@ getMessageParametersAsString_fn = /* @__PURE__ */ __name(async function(args) {
|
|
|
276
275
|
}
|
|
277
276
|
return params;
|
|
278
277
|
}, "#getMessageParametersAsString");
|
|
279
|
-
_handleMessageRun = new WeakSet();
|
|
280
278
|
handleMessageRun_fn = /* @__PURE__ */ __name(async function(message, args, context, subcommand, subcommandGroupName) {
|
|
281
279
|
const payload = {
|
|
282
280
|
message,
|
|
@@ -288,7 +286,7 @@ handleMessageRun_fn = /* @__PURE__ */ __name(async function(message, args, conte
|
|
|
288
286
|
subcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name
|
|
289
287
|
);
|
|
290
288
|
if (preconditionsForSubcommand) {
|
|
291
|
-
const messageParametersAsString = await __privateMethod(this,
|
|
289
|
+
const messageParametersAsString = await __privateMethod(this, _Subcommand_instances, getMessageParametersAsString_fn).call(this, args);
|
|
292
290
|
const preconditionPayload = { ...messageParametersAsString, ...payload };
|
|
293
291
|
const localSubcommandResult = await preconditionsForSubcommand.messageRun(message, this, preconditionPayload);
|
|
294
292
|
if (localSubcommandResult.isErr()) {
|
|
@@ -321,7 +319,6 @@ handleMessageRun_fn = /* @__PURE__ */ __name(async function(message, args, conte
|
|
|
321
319
|
});
|
|
322
320
|
result.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.MessageSubcommandError, error, payload));
|
|
323
321
|
}, "#handleMessageRun");
|
|
324
|
-
_handleChatInputInteractionRun = new WeakSet();
|
|
325
322
|
handleChatInputInteractionRun_fn = /* @__PURE__ */ __name(async function(interaction, context, subcommand, subcommandGroupName) {
|
|
326
323
|
const payload = {
|
|
327
324
|
command: this,
|
|
@@ -369,7 +366,6 @@ handleChatInputInteractionRun_fn = /* @__PURE__ */ __name(async function(interac
|
|
|
369
366
|
});
|
|
370
367
|
result.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandError, error, payload));
|
|
371
368
|
}, "#handleChatInputInteractionRun");
|
|
372
|
-
_findSubcommand = new WeakSet();
|
|
373
369
|
findSubcommand_fn = /* @__PURE__ */ __name(function(mappings, expectedName) {
|
|
374
370
|
let foundDefault = null;
|
|
375
371
|
for (const mapping of mappings) {
|
|
@@ -383,7 +379,6 @@ findSubcommand_fn = /* @__PURE__ */ __name(function(mappings, expectedName) {
|
|
|
383
379
|
}
|
|
384
380
|
return { mapping: foundDefault, defaultMatch: true };
|
|
385
381
|
}, "#findSubcommand");
|
|
386
|
-
_supportsCommandType = new WeakSet();
|
|
387
382
|
supportsCommandType_fn = /* @__PURE__ */ __name(function(commandType) {
|
|
388
383
|
return this.parsedSubcommandMappings.some((mapping) => {
|
|
389
384
|
if (mapping.type === "group") {
|
|
@@ -396,5 +391,5 @@ __name(_Subcommand, "Subcommand");
|
|
|
396
391
|
var Subcommand = _Subcommand;
|
|
397
392
|
|
|
398
393
|
export { Subcommand };
|
|
399
|
-
//# sourceMappingURL=
|
|
394
|
+
//# sourceMappingURL=Subcommand.mjs.map
|
|
400
395
|
//# sourceMappingURL=Subcommand.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/Subcommand.ts"],"names":["result"],"mappings":";;;;;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP,SAAS,MAAM,iBAAiB;AAEhC,SAAS,uCAAuC;AAChD;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AAnBP;AAoCO,IAAM,cAAN,MAAM,oBAAgH,QAG3H;AAAA,EAmBM,YAAY,SAAmC,SAAkB;AAEvE,UAAM,SAAS,OAAO;AAsUvB,uBAAM;AAcN,uBAAM;AAkEN,uBAAM;AA+DN;AAkBA;AAvfA;AAAA;AAAA;AAAA;AAAA,wBAAgB,2BAA0B,oBAAI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UAAU,KAAK,UAAU,OAAO,KAAK,uBAAuB,0BAA0B,OAAO,OAAO,CAAC;AACzH,GA7DoC;AA+DpC;AAAA,oBAAe,gCAAC,UAAqC,cAAsB;AAC1E,MAAI,eAA+C;AAEnD,aAAW,WAAW,UAAU;AAC/B,YAAQ,SAAS;AAEjB,QAAI,QAAQ,SAAS;AACpB,qBAAe;AAAA,IAChB;AAEA,QAAI,QAAQ,SAAS,cAAc;AAClC,aAAO,EAAE,SAAS,cAAc,MAAM;AAAA,IACvC;AAAA,EACD;AAEA,SAAO,EAAE,SAAS,cAAc,cAAc,KAAK;AACpD,GAhBe;AAkBf;AAAA,yBAAoB,gCAAC,aAAqD;AACzE,SAAO,KAAK,yBAAyB,KAAK,CAAC,YAAY;AACtD,QAAI,QAAQ,SAAS,SAAS;AAC7B,aAAO,QAAQ,QAAQ,KAAK,CAAC,iBAAiB,QAAQ,IAAI,cAAc,WAAW,CAAC;AAAA,IACrF;AACA,WAAO,QAAQ,IAAI,SAAS,WAAW;AAAA,EACxC,CAAC;AACF,GAPoB;AA5fnB;AAHK,IAAM,aAAN","sourcesContent":["import {\n\tCommand,\n\tPreconditionContainerArray,\n\tPreconditionResolvers,\n\tResult,\n\tUserError,\n\ttype Args,\n\ttype ChatInputCommand,\n\ttype MessageCommand,\n\ttype MessageCommandDeniedPayload\n} from '@sapphire/framework';\nimport { cast, deepClone } from '@sapphire/utilities';\nimport type { CacheType, Message } from 'discord.js';\nimport { SubcommandPreconditionResolvers } from '../index';\nimport {\n\tSubcommandPluginEvents,\n\tSubcommandPluginIdentifiers,\n\ttype ChatInputSubcommandAcceptedPayload,\n\ttype MessageSubcommandAcceptedPayload\n} from './types/Events';\nimport type {\n\tChatInputCommandSubcommandMappingMethod,\n\tMessageSubcommandMappingMethod,\n\tSubcommandMappingArray,\n\tSubcommandMappingMethod\n} from './types/SubcommandMappings';\n\n/**\n * The class to extends for commands that have subcommands.\n * Specify the subcommands through the {@link Subcommand.Options.subcommands} option.\n *\n * Note that you should not make **all** your commands extend this class, _only_ the ones that have subcommands.\n * The reason for this is that this class implements {@link Command.messageRun} and {@link Command.chatInputRun}\n * which you wouldn't necessarily want to do for commands that don't have subcommands.\n * Furthermore, it also just adds general unnecessary memory overhead.\n */\nexport class Subcommand<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> extends Command<\n\tPreParseReturn,\n\tOptions\n> {\n\t/**\n\t * The preconditions to be run for each specified subcommand.\n\t * @since 4.1.0\n\t */\n\tpublic readonly subcommandPreconditions = new Map<string, PreconditionContainerArray>();\n\n\t/**\n\t * The parsed subcommand mappings that were provided with the {@link SubcommandOptions.subcommands} option.\n\t * This is built at construction time and is used to determine which subcommand to run.\n\t */\n\tpublic parsedSubcommandMappings: SubcommandMappingArray;\n\n\t/**\n\t * Whether to use case insensitive subcommands. This is only relevant for message-command styled commands as\n\t * chat input commands are always lowercase. This can be enabled through `clientOptions.caseInsensitiveCommands`.\n\t */\n\tpublic caseInsensitiveSubcommands = false;\n\n\tpublic constructor(context: Subcommand.LoaderContext, options: Options) {\n\t\t// #region Base parsing\n\t\tsuper(context, options);\n\t\tthis.parsedSubcommandMappings = options.subcommands ?? [];\n\n\t\tconst clientOptions = this.container.client.options;\n\t\t// #endregion\n\n\t\t// #region Case Insensitive Commands\n\t\tif (clientOptions.caseInsensitiveCommands) {\n\t\t\tthis.caseInsensitiveSubcommands = true;\n\n\t\t\t// Because slash commands must be lowercase anyway, we can transform all to lowercase.\n\t\t\tfor (const cmd of this.parsedSubcommandMappings) {\n\t\t\t\tcmd.name = cmd.name.toLowerCase();\n\t\t\t\tif (cmd.type === 'group') {\n\t\t\t\t\tfor (const groupCommand of cmd.entries) {\n\t\t\t\t\t\tgroupCommand.name = groupCommand.name.toLowerCase();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\n\t\t// #region Generate Dashless Aliases\n\t\tif (options.generateDashLessAliases) {\n\t\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\t\tif (!Reflect.has(mapping, 'messageRun')) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst dashLessMappings: SubcommandMappingArray = [];\n\n\t\t\t\tif (mapping.type === 'group') {\n\t\t\t\t\t// Keep track of whether we have changed entries or not, so we don't need to do expensive object comparison later.\n\t\t\t\t\tlet hasChangedEntries: boolean | null = null;\n\n\t\t\t\t\t// Deeply clone the entire mapping to avoid mutating the original.\n\t\t\t\t\tconst clonedMapping = deepClone(mapping);\n\n\t\t\t\t\t// Loop through the group's subcommands and add a dash-less alias for each, if applicable.\n\t\t\t\t\tfor (const groupCommand of mapping.entries) {\n\t\t\t\t\t\tif (groupCommand.name.includes('-')) {\n\t\t\t\t\t\t\t// If we are inside this if statement then we flip `hasChangedEntries` to true to be able to read it later.\n\t\t\t\t\t\t\thasChangedEntries ??= true;\n\n\t\t\t\t\t\t\tclonedMapping.entries.push({\n\t\t\t\t\t\t\t\t...groupCommand,\n\t\t\t\t\t\t\t\tname: groupCommand.name.replaceAll('-', '')\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If any of the entries in the group had a dash then `hasChangedEntries` was flipped to true\n\t\t\t\t\t * and so we want to register a mapping with the base name and all dash-less entries\n\t\t\t\t\t * in the group.\n\t\t\t\t\t */\n\t\t\t\t\tif (hasChangedEntries) {\n\t\t\t\t\t\tdashLessMappings.push({\n\t\t\t\t\t\t\t...mapping,\n\t\t\t\t\t\t\tentries: clonedMapping.entries\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If the group name itself has a dash then register a dash-less copy of it.\n\t\t\t\t\t * If the entries in the group didn't have any dashes then `clonedMapping.entries` is still\n\t\t\t\t\t * the same original array, so it can be safely overwritten.\n\t\t\t\t\t *\n\t\t\t\t\t * If the entries in the group did have any dashes then `clonedMapping.entries` has\n\t\t\t\t\t * all entries both with and without dashes.\n\t\t\t\t\t */\n\t\t\t\t\tif (clonedMapping.name.includes('-')) {\n\t\t\t\t\t\tclonedMapping.name = clonedMapping.name.replaceAll('-', '');\n\t\t\t\t\t\tdashLessMappings.push(clonedMapping);\n\t\t\t\t\t}\n\t\t\t\t} else if (mapping.name.includes('-')) {\n\t\t\t\t\tdashLessMappings.push({\n\t\t\t\t\t\t...mapping,\n\t\t\t\t\t\tname: mapping.name.replaceAll('-', '')\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// For every dash-less mapping, push a new subcommand\n\t\t\t\tfor (const dashLessMapping of dashLessMappings) {\n\t\t\t\t\tthis.parsedSubcommandMappings.push(dashLessMapping);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\n\t\t// #region Subcommand Preconditions\n\t\tfor (const subcommand of this.parsedSubcommandMappings) {\n\t\t\tsubcommand.type ??= 'method';\n\n\t\t\tif (subcommand.type === 'method') {\n\t\t\t\tconst preconditionContainerArray = new PreconditionContainerArray(subcommand.preconditions);\n\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRunIn(\n\t\t\t\t\tsubcommand.runIn,\n\t\t\t\t\tthis.resolveConstructorPreConditionsRunType.bind(this),\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsNsfw(subcommand.nsfw, preconditionContainerArray);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(\n\t\t\t\t\tsubcommand.requiredClientPermissions,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(\n\t\t\t\t\tsubcommand.requiredUserPermissions,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tSubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({\n\t\t\t\t\tsubcommand: this,\n\t\t\t\t\tcooldownDelay: subcommand.cooldownDelay,\n\t\t\t\t\tcooldownFilteredUsers: subcommand.cooldownFilteredUsers,\n\t\t\t\t\tcooldownLimit: subcommand.cooldownLimit,\n\t\t\t\t\tcooldownScope: subcommand.cooldownScope,\n\t\t\t\t\tsubcommandMethodName: subcommand.name,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t});\n\n\t\t\t\tthis.subcommandPreconditions.set(subcommand.name, preconditionContainerArray);\n\t\t\t}\n\n\t\t\tif (subcommand.type === 'group') {\n\t\t\t\tfor (const groupedSubcommand of subcommand.entries) {\n\t\t\t\t\tconst preconditionContainerArray = new PreconditionContainerArray(groupedSubcommand.preconditions);\n\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRunIn(\n\t\t\t\t\t\tgroupedSubcommand.runIn,\n\t\t\t\t\t\tthis.resolveConstructorPreConditionsRunType.bind(this),\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsNsfw(groupedSubcommand.nsfw, preconditionContainerArray);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(\n\t\t\t\t\t\tgroupedSubcommand.requiredClientPermissions,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(\n\t\t\t\t\t\tgroupedSubcommand.requiredUserPermissions,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tSubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({\n\t\t\t\t\t\tsubcommand: this,\n\t\t\t\t\t\tcooldownDelay: groupedSubcommand.cooldownDelay,\n\t\t\t\t\t\tcooldownFilteredUsers: groupedSubcommand.cooldownFilteredUsers,\n\t\t\t\t\t\tcooldownLimit: groupedSubcommand.cooldownLimit,\n\t\t\t\t\t\tcooldownScope: groupedSubcommand.cooldownScope,\n\t\t\t\t\t\tsubcommandGroupName: subcommand.name,\n\t\t\t\t\t\tsubcommandMethodName: groupedSubcommand.name,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.subcommandPreconditions.set(`${subcommand.name}.${groupedSubcommand.name}`, preconditionContainerArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\t}\n\n\tpublic override onLoad() {\n\t\tsuper.onLoad();\n\n\t\tconst externalMapping = Reflect.get(this, 'subcommandMappings');\n\t\tif (externalMapping) {\n\t\t\tconst subcommands = Array.isArray(externalMapping) ? externalMapping : [];\n\t\t\tthis.parsedSubcommandMappings = subcommands;\n\t\t\tthis.options.subcommands = subcommands;\n\t\t}\n\t}\n\n\t/**\n\t * Whether this command has message-based subcommands or not\n\t * @returns `true` if this command has message-based subcommands, otherwise `false`\n\t */\n\tpublic override supportsMessageCommands(): boolean {\n\t\treturn this.#supportsCommandType('messageRun');\n\t}\n\n\t/**\n\t * Whether this command has chat input subcommands or not\n\t * @returns `true` if this command has chat input subcommands, otherwise `false`\n\t */\n\tpublic override supportsChatInputCommands(): this is ChatInputCommand {\n\t\treturn this.#supportsCommandType('chatInputRun');\n\t}\n\n\t/**\n\t * The method that is ran when a message-based subcommand is ran.\n\t *\n\t * **DO NOT** override this in your implementation of a subcommand!\n\t */\n\tpublic override async messageRun(message: Message, args: PreParseReturn, context: MessageCommand.RunContext) {\n\t\targs.save();\n\t\tconst subcommandOrGroup = args.nextMaybe();\n\t\tconst subcommandName = args.nextMaybe();\n\t\tlet defaultCommand: SubcommandMappingMethod | null = null;\n\t\tlet actualSubcommandToRun: SubcommandMappingMethod | null = null;\n\t\tlet matchedWithGroupedSubcommand = false;\n\n\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\tif (mapping.type === 'method') {\n\t\t\t\tif (mapping.default && !defaultCommand) {\n\t\t\t\t\tmatchedWithGroupedSubcommand = false;\n\t\t\t\t\tdefaultCommand = mapping;\n\t\t\t\t}\n\n\t\t\t\tif (subcommandOrGroup.isSomeAnd((value) => mapping.name === (this.caseInsensitiveSubcommands ? value.toLowerCase() : value))) {\n\t\t\t\t\tactualSubcommandToRun = mapping;\n\t\t\t\t\tmatchedWithGroupedSubcommand = false;\n\t\t\t\t\t// Exit early\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We expect a group mapping\n\t\t\tif (mapping.type === 'group' && subcommandOrGroup.isSome() && subcommandName.isSome()) {\n\t\t\t\tconst unwrappedSubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\tconst unwrappedSubcommandName = subcommandName.unwrap();\n\n\t\t\t\t// We know a group was passed in here\n\t\t\t\tif (mapping.name === unwrappedSubcommandGroupName) {\n\t\t\t\t\t// Find the actual subcommand to run\n\t\t\t\t\tconst findResult = this.#findSubcommand(\n\t\t\t\t\t\tmapping.entries,\n\t\t\t\t\t\tthis.caseInsensitiveSubcommands ? unwrappedSubcommandName.toLowerCase() : unwrappedSubcommandName\n\t\t\t\t\t);\n\n\t\t\t\t\tif (findResult.defaultMatch) {\n\t\t\t\t\t\tdefaultCommand = findResult.mapping;\n\t\t\t\t\t\tmatchedWithGroupedSubcommand = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactualSubcommandToRun = findResult.mapping;\n\t\t\t\t\t\tmatchedWithGroupedSubcommand = true;\n\t\t\t\t\t\t// Exit early\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Preemptively restore the args state, to provide a correct args result for users\n\t\targs.restore();\n\n\t\tif (actualSubcommandToRun) {\n\t\t\t// Skip over the subcommandOrGroup\n\t\t\targs.next();\n\n\t\t\t// If we matched with a subcommand in a group we need to skip 1 more arg\n\t\t\tlet subcommandGroupName: string | undefined = undefined;\n\t\t\tif (matchedWithGroupedSubcommand) {\n\t\t\t\tsubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\targs.next();\n\t\t\t}\n\n\t\t\treturn this.#handleMessageRun(message, args, context, actualSubcommandToRun, subcommandGroupName);\n\t\t}\n\n\t\t// No subcommand matched, let's try to run default, if any:\n\t\tif (defaultCommand) {\n\t\t\t// If we matched with a subcommand in a group we need to skip 1 the group name\n\t\t\tlet subcommandGroupName: string | undefined = undefined;\n\t\t\tif (matchedWithGroupedSubcommand) {\n\t\t\t\tsubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\targs.next();\n\t\t\t}\n\n\t\t\treturn this.#handleMessageRun(message, args, context, defaultCommand, subcommandGroupName);\n\t\t}\n\n\t\t// No match and no subcommand, return an err:\n\t\tthrow new UserError({\n\t\t\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch,\n\t\t\tmessage: 'No subcommand was matched with the provided arguments.',\n\t\t\tcontext: {\n\t\t\t\t...context,\n\t\t\t\tpossibleSubcommandName: subcommandName.unwrapOr(null),\n\t\t\t\tpossibleSubcommandGroupOrName: subcommandOrGroup.unwrapOr(null)\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * The method that is ran when a chat input based subcommand is ran.\n\t *\n\t * **DO NOT** override this in your implementation of a subcommand!\n\t */\n\tpublic override async chatInputRun(interaction: ChatInputCommand.Interaction, context: ChatInputCommand.RunContext) {\n\t\tconst subcommandName = interaction.options.getSubcommand(false);\n\t\tconst subcommandGroupName = interaction.options.getSubcommandGroup(false);\n\n\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\t// If we have a group, we know we also have a subcommand and we should find and run it\n\t\t\tif (subcommandGroupName && subcommandName) {\n\t\t\t\tif (mapping.type !== 'group') continue;\n\t\t\t\tif (mapping.name !== subcommandGroupName) continue;\n\n\t\t\t\tconst foundSubcommand = this.#findSubcommand(mapping.entries, subcommandName!);\n\n\t\t\t\t// Only run if its not the \"default\" found command mapping, as interactions don't have that\n\t\t\t\tif (!foundSubcommand.defaultMatch) {\n\t\t\t\t\treturn this.#handleChatInputInteractionRun(interaction, context, foundSubcommand.mapping, subcommandGroupName);\n\t\t\t\t}\n\n\t\t\t\t// Skip to the next entry\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If we have a direct subcommand, and no group, then run the mapping\n\t\t\tif (mapping.type === 'method' && mapping.name === subcommandName) {\n\t\t\t\treturn this.#handleChatInputInteractionRun(interaction, context, mapping, undefined);\n\t\t\t}\n\t\t}\n\n\t\t// No match and no subcommand, return an err:\n\t\tthrow new UserError({\n\t\t\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch,\n\t\t\tmessage: 'No subcommand was matched with the provided command.',\n\t\t\tcontext\n\t\t});\n\t}\n\n\tasync #getMessageParametersAsString(args: Args): Promise<Partial<Pick<MessageCommandDeniedPayload, 'parameters'>>> {\n\t\targs.save();\n\t\tconst parameters = await args.restResult('string');\n\t\targs.restore();\n\n\t\tconst params: Partial<Pick<MessageCommandDeniedPayload, 'parameters'>> = {};\n\n\t\tif (parameters.isOk()) {\n\t\t\tparams.parameters = parameters.unwrap();\n\t\t}\n\n\t\treturn params;\n\t}\n\n\tasync #handleMessageRun(\n\t\tmessage: Message,\n\t\targs: Args,\n\t\tcontext: MessageCommand.RunContext,\n\t\tsubcommand: SubcommandMappingMethod,\n\t\tsubcommandGroupName: string | undefined\n\t) {\n\t\tconst payload: MessageSubcommandAcceptedPayload = {\n\t\t\tmessage,\n\t\t\tcommand: this,\n\t\t\tcontext,\n\t\t\tmatchedSubcommandMapping: subcommand\n\t\t};\n\n\t\t// Check if any subcommand preconditions were defined for thus subcommand:\n\t\tconst preconditionsForSubcommand = this.subcommandPreconditions.get(\n\t\t\tsubcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name\n\t\t);\n\n\t\tif (preconditionsForSubcommand) {\n\t\t\t// Attempt to get the remaining parameters as string:\n\t\t\tconst messageParametersAsString = await this.#getMessageParametersAsString(args);\n\n\t\t\t// Build the precondition payload:\n\t\t\tconst preconditionPayload = { ...messageParametersAsString, ...payload };\n\n\t\t\t// Run the subcommand specific preconditions:\n\t\t\tconst localSubcommandResult = await preconditionsForSubcommand.messageRun(message, this, preconditionPayload as any);\n\t\t\tif (localSubcommandResult.isErr()) {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandDenied, localSubcommandResult.unwrapErr(), preconditionPayload);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If subcommand preconditions have passed then we run the actual subcommand:\n\t\tconst result = await Result.fromAsync(async () => {\n\t\t\tif (subcommand.messageRun) {\n\t\t\t\tconst casted = subcommand as MessageSubcommandMappingMethod;\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandRun, message, casted, payload);\n\t\t\t\tlet result: unknown;\n\n\t\t\t\tif (typeof subcommand.messageRun === 'string') {\n\t\t\t\t\tconst method = Reflect.get(this, subcommand.messageRun);\n\t\t\t\t\tif (!method) {\n\t\t\t\t\t\tthrow new UserError({\n\t\t\t\t\t\t\tidentifier: SubcommandPluginIdentifiers.SubcommandNotFound,\n\t\t\t\t\t\t\tmessage: `The method configured at \"messageRun\" for the subcommand ${subcommand.name} was not implemented in the class.`,\n\t\t\t\t\t\t\tcontext: { ...payload }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tresult = await Reflect.apply(cast<this['messageRun']>(method), this, [message, args, context]);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await subcommand.messageRun(message, args, context);\n\t\t\t\t}\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandSuccess, message, casted, { ...payload, result });\n\t\t\t} else {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler, message, subcommand, payload);\n\t\t\t}\n\t\t});\n\n\t\tresult.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.MessageSubcommandError, error, payload));\n\t}\n\n\tasync #handleChatInputInteractionRun(\n\t\tinteraction: ChatInputCommand.Interaction,\n\t\tcontext: ChatInputCommand.RunContext,\n\t\tsubcommand: SubcommandMappingMethod,\n\t\tsubcommandGroupName: string | undefined\n\t) {\n\t\tconst payload: ChatInputSubcommandAcceptedPayload = {\n\t\t\tcommand: this,\n\t\t\tcontext,\n\t\t\tinteraction,\n\t\t\tmatchedSubcommandMapping: subcommand\n\t\t};\n\n\t\t// Check if any subcommand preconditions were defined for thus subcommand:\n\t\tconst preconditionsForSubcommand = this.subcommandPreconditions.get(\n\t\t\tsubcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name\n\t\t);\n\n\t\tif (preconditionsForSubcommand) {\n\t\t\t// Run the subcommand specific preconditions:\n\t\t\tconst localSubcommandResult = await preconditionsForSubcommand.chatInputRun(interaction, this, payload as any);\n\t\t\tif (localSubcommandResult.isErr()) {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandDenied, localSubcommandResult.unwrapErr(), payload);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst result = await Result.fromAsync(async () => {\n\t\t\tif (subcommand.chatInputRun) {\n\t\t\t\tconst casted = subcommand as ChatInputCommandSubcommandMappingMethod;\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandRun, interaction, casted, payload);\n\t\t\t\tlet result: unknown;\n\n\t\t\t\tif (typeof subcommand.chatInputRun === 'string') {\n\t\t\t\t\tconst method = Reflect.get(this, subcommand.chatInputRun);\n\t\t\t\t\tif (!method) {\n\t\t\t\t\t\tthrow new UserError({\n\t\t\t\t\t\t\tidentifier: SubcommandPluginIdentifiers.SubcommandNotFound,\n\t\t\t\t\t\t\tmessage: `The method configured at \"chatInputRun\" for the subcommand ${subcommand.name} was not implemented in the class.`,\n\t\t\t\t\t\t\tcontext: { ...payload }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tresult = await Reflect.apply(cast<this['chatInputRun']>(method), this, [interaction, context]);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await subcommand.chatInputRun(interaction, context);\n\t\t\t\t}\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandSuccess, interaction, casted, { ...payload, result });\n\t\t\t} else {\n\t\t\t\tthis.container.client.emit(\n\t\t\t\t\tSubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler,\n\t\t\t\t\tinteraction,\n\t\t\t\t\tsubcommand,\n\t\t\t\t\tpayload\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tresult.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandError, error, payload));\n\t}\n\n\t#findSubcommand(mappings: SubcommandMappingMethod[], expectedName: string) {\n\t\tlet foundDefault: SubcommandMappingMethod | null = null;\n\n\t\tfor (const mapping of mappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\tif (mapping.default) {\n\t\t\t\tfoundDefault = mapping;\n\t\t\t}\n\n\t\t\tif (mapping.name === expectedName) {\n\t\t\t\treturn { mapping, defaultMatch: false } as const;\n\t\t\t}\n\t\t}\n\n\t\treturn { mapping: foundDefault, defaultMatch: true } as const;\n\t}\n\n\t#supportsCommandType(commandType: 'messageRun' | 'chatInputRun'): boolean {\n\t\treturn this.parsedSubcommandMappings.some((mapping) => {\n\t\t\tif (mapping.type === 'group') {\n\t\t\t\treturn mapping.entries.some((groupCommand) => Reflect.has(groupCommand, commandType));\n\t\t\t}\n\t\t\treturn Reflect.has(mapping, commandType);\n\t\t});\n\t}\n}\n\nexport interface SubcommandOptions extends Command.Options {\n\tsubcommands?: SubcommandMappingArray;\n\t/**\n\t * Whether to add aliases for subcommands with dashes in them\n\t *\n\t * When this option is enabled *and* the subcommand implements `messageRun`, dashless aliases will be added.\n\t *\n\t * For subcommands groups both the group itself and all subcommands within the group will have dashless aliases added.\n\t *\n\t * @since 3.0.0\n\t * @default false\n\t */\n\tgenerateDashLessAliases?: boolean;\n}\n\nexport namespace Subcommand {\n\texport type Options = SubcommandOptions;\n\texport type JSON = Command.JSON;\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Command.LoaderContext;\n\texport type RunInTypes = Command.RunInTypes;\n\texport type ChatInputCommandInteraction<Cached extends CacheType = CacheType> = Command.ChatInputCommandInteraction<Cached>;\n\texport type ContextMenuCommandInteraction<Cached extends CacheType = CacheType> = Command.ContextMenuCommandInteraction<Cached>;\n\texport type AutocompleteInteraction<Cached extends CacheType = CacheType> = Command.AutocompleteInteraction<Cached>;\n\texport type Registry = Command.Registry;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/Subcommand.ts"],"names":["result"],"mappings":";;;;;;AAAA,IAAA,qBAAA,EAAA,mBAAA,EAAA,+BAAA,EAAA,mBAAA,EAAA,gCAAA,EAAA,iBAAA,EAAA,sBAAA,CAAA;AAoCO,IAAM,WAAA,GAAN,MAAM,WAAA,SAAgH,OAG3H,CAAA;AAAA,EAmBM,WAAA,CAAY,SAAmC,OAAkB,EAAA;AAEvE,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA,CAAA;AAxBjB,IAAA,YAAA,CAAA,IAAA,EAAA,qBAAA,CAAA,CAAA;AAQN;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,yBAAA,sBAA8B,GAAwC,EAAA,CAAA,CAAA;AAMtF;AAAA;AAAA;AAAA;AAAA,IAAO,aAAA,CAAA,IAAA,EAAA,0BAAA,CAAA,CAAA;AAMP;AAAA;AAAA;AAAA;AAAA,IAAA,aAAA,CAAA,IAAA,EAAO,4BAA6B,EAAA,KAAA,CAAA,CAAA;AAKnC,IAAK,IAAA,CAAA,wBAAA,GAA2B,OAAQ,CAAA,WAAA,IAAe,EAAC,CAAA;AAExD,IAAM,MAAA,aAAA,GAAgB,IAAK,CAAA,SAAA,CAAU,MAAO,CAAA,OAAA,CAAA;AAI5C,IAAA,IAAI,cAAc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tD,IAAI,IAAA,OAAA,CAAQ,SAAS,OAAS,EAAA;AAC7B,MAAO,OAAA,OAAA,CAAQ,QAAQ,IAAK,CAAA,CAAC,iBAAiB,OAAQ,CAAA,GAAA,CAAI,YAAc,EAAA,WAAW,CAAC,CAAA,CAAA;AAAA,KACrF;AACA,IAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,OAAA,EAAS,WAAW,CAAA,CAAA;AAAA,GACvC,CAAA,CAAA;AACF,CAPoB,EAAA,sBAAA,CAAA,CAAA;AAngBnB,MAAA,CAAA,WAAA,EAAA,YAAA,CAAA,CAAA;AAHK,IAAM,UAAN,GAAA","file":"Subcommand.mjs","sourcesContent":["import {\n\tCommand,\n\tPreconditionContainerArray,\n\tPreconditionResolvers,\n\tResult,\n\tUserError,\n\ttype Args,\n\ttype ChatInputCommand,\n\ttype MessageCommand,\n\ttype MessageCommandDeniedPayload\n} from '@sapphire/framework';\nimport { cast, deepClone } from '@sapphire/utilities';\nimport type { CacheType, Message } from 'discord.js';\nimport { SubcommandPreconditionResolvers } from '../index';\nimport {\n\tSubcommandPluginEvents,\n\tSubcommandPluginIdentifiers,\n\ttype ChatInputSubcommandAcceptedPayload,\n\ttype MessageSubcommandAcceptedPayload\n} from './types/Events';\nimport type {\n\tChatInputCommandSubcommandMappingMethod,\n\tMessageSubcommandMappingMethod,\n\tSubcommandMappingArray,\n\tSubcommandMappingMethod\n} from './types/SubcommandMappings';\n\n/**\n * The class to extends for commands that have subcommands.\n * Specify the subcommands through the {@link Subcommand.Options.subcommands} option.\n *\n * Note that you should not make **all** your commands extend this class, _only_ the ones that have subcommands.\n * The reason for this is that this class implements {@link Command.messageRun} and {@link Command.chatInputRun}\n * which you wouldn't necessarily want to do for commands that don't have subcommands.\n * Furthermore, it also just adds general unnecessary memory overhead.\n */\nexport class Subcommand<PreParseReturn extends Args = Args, Options extends Subcommand.Options = Subcommand.Options> extends Command<\n\tPreParseReturn,\n\tOptions\n> {\n\t/**\n\t * The preconditions to be run for each specified subcommand.\n\t * @since 4.1.0\n\t */\n\tpublic readonly subcommandPreconditions = new Map<string, PreconditionContainerArray>();\n\n\t/**\n\t * The parsed subcommand mappings that were provided with the {@link SubcommandOptions.subcommands} option.\n\t * This is built at construction time and is used to determine which subcommand to run.\n\t */\n\tpublic parsedSubcommandMappings: SubcommandMappingArray;\n\n\t/**\n\t * Whether to use case insensitive subcommands. This is only relevant for message-command styled commands as\n\t * chat input commands are always lowercase. This can be enabled through `clientOptions.caseInsensitiveCommands`.\n\t */\n\tpublic caseInsensitiveSubcommands = false;\n\n\tpublic constructor(context: Subcommand.LoaderContext, options: Options) {\n\t\t// #region Base parsing\n\t\tsuper(context, options);\n\t\tthis.parsedSubcommandMappings = options.subcommands ?? [];\n\n\t\tconst clientOptions = this.container.client.options;\n\t\t// #endregion\n\n\t\t// #region Case Insensitive Commands\n\t\tif (clientOptions.caseInsensitiveCommands) {\n\t\t\tthis.caseInsensitiveSubcommands = true;\n\n\t\t\t// Because slash commands must be lowercase anyway, we can transform all to lowercase.\n\t\t\tfor (const cmd of this.parsedSubcommandMappings) {\n\t\t\t\tcmd.name = cmd.name.toLowerCase();\n\t\t\t\tif (cmd.type === 'group') {\n\t\t\t\t\tfor (const groupCommand of cmd.entries) {\n\t\t\t\t\t\tgroupCommand.name = groupCommand.name.toLowerCase();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\n\t\t// #region Generate Dashless Aliases\n\t\tif (options.generateDashLessAliases) {\n\t\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\t\tif (!Reflect.has(mapping, 'messageRun')) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst dashLessMappings: SubcommandMappingArray = [];\n\n\t\t\t\tif (mapping.type === 'group') {\n\t\t\t\t\t// Keep track of whether we have changed entries or not, so we don't need to do expensive object comparison later.\n\t\t\t\t\tlet hasChangedEntries: boolean | null = null;\n\n\t\t\t\t\t// Deeply clone the entire mapping to avoid mutating the original.\n\t\t\t\t\tconst clonedMapping = deepClone(mapping);\n\n\t\t\t\t\t// Loop through the group's subcommands and add a dash-less alias for each, if applicable.\n\t\t\t\t\tfor (const groupCommand of mapping.entries) {\n\t\t\t\t\t\tif (groupCommand.name.includes('-')) {\n\t\t\t\t\t\t\t// If we are inside this if statement then we flip `hasChangedEntries` to true to be able to read it later.\n\t\t\t\t\t\t\thasChangedEntries ??= true;\n\n\t\t\t\t\t\t\tclonedMapping.entries.push({\n\t\t\t\t\t\t\t\t...groupCommand,\n\t\t\t\t\t\t\t\tname: groupCommand.name.replaceAll('-', '')\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If any of the entries in the group had a dash then `hasChangedEntries` was flipped to true\n\t\t\t\t\t * and so we want to register a mapping with the base name and all dash-less entries\n\t\t\t\t\t * in the group.\n\t\t\t\t\t */\n\t\t\t\t\tif (hasChangedEntries) {\n\t\t\t\t\t\tdashLessMappings.push({\n\t\t\t\t\t\t\t...mapping,\n\t\t\t\t\t\t\tentries: clonedMapping.entries\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t/**\n\t\t\t\t\t * If the group name itself has a dash then register a dash-less copy of it.\n\t\t\t\t\t * If the entries in the group didn't have any dashes then `clonedMapping.entries` is still\n\t\t\t\t\t * the same original array, so it can be safely overwritten.\n\t\t\t\t\t *\n\t\t\t\t\t * If the entries in the group did have any dashes then `clonedMapping.entries` has\n\t\t\t\t\t * all entries both with and without dashes.\n\t\t\t\t\t */\n\t\t\t\t\tif (clonedMapping.name.includes('-')) {\n\t\t\t\t\t\tclonedMapping.name = clonedMapping.name.replaceAll('-', '');\n\t\t\t\t\t\tdashLessMappings.push(clonedMapping);\n\t\t\t\t\t}\n\t\t\t\t} else if (mapping.name.includes('-')) {\n\t\t\t\t\tdashLessMappings.push({\n\t\t\t\t\t\t...mapping,\n\t\t\t\t\t\tname: mapping.name.replaceAll('-', '')\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// For every dash-less mapping, push a new subcommand\n\t\t\t\tfor (const dashLessMapping of dashLessMappings) {\n\t\t\t\t\tthis.parsedSubcommandMappings.push(dashLessMapping);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\n\t\t// #region Subcommand Preconditions\n\t\tfor (const subcommand of this.parsedSubcommandMappings) {\n\t\t\tsubcommand.type ??= 'method';\n\n\t\t\tif (subcommand.type === 'method') {\n\t\t\t\tconst preconditionContainerArray = new PreconditionContainerArray(subcommand.preconditions);\n\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRunIn(\n\t\t\t\t\tsubcommand.runIn,\n\t\t\t\t\tthis.resolveConstructorPreConditionsRunType.bind(this),\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsNsfw(subcommand.nsfw, preconditionContainerArray);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(\n\t\t\t\t\tsubcommand.requiredClientPermissions,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(\n\t\t\t\t\tsubcommand.requiredUserPermissions,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t);\n\t\t\t\tSubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({\n\t\t\t\t\tsubcommand: this,\n\t\t\t\t\tcooldownDelay: subcommand.cooldownDelay,\n\t\t\t\t\tcooldownFilteredUsers: subcommand.cooldownFilteredUsers,\n\t\t\t\t\tcooldownLimit: subcommand.cooldownLimit,\n\t\t\t\t\tcooldownScope: subcommand.cooldownScope,\n\t\t\t\t\tsubcommandMethodName: subcommand.name,\n\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t});\n\n\t\t\t\tthis.subcommandPreconditions.set(subcommand.name, preconditionContainerArray);\n\t\t\t}\n\n\t\t\tif (subcommand.type === 'group') {\n\t\t\t\tfor (const groupedSubcommand of subcommand.entries) {\n\t\t\t\t\tconst preconditionContainerArray = new PreconditionContainerArray(groupedSubcommand.preconditions);\n\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRunIn(\n\t\t\t\t\t\tgroupedSubcommand.runIn,\n\t\t\t\t\t\tthis.resolveConstructorPreConditionsRunType.bind(this),\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsNsfw(groupedSubcommand.nsfw, preconditionContainerArray);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredClientPermissions(\n\t\t\t\t\t\tgroupedSubcommand.requiredClientPermissions,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tPreconditionResolvers.parseConstructorPreConditionsRequiredUserPermissions(\n\t\t\t\t\t\tgroupedSubcommand.requiredUserPermissions,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t);\n\t\t\t\t\tSubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({\n\t\t\t\t\t\tsubcommand: this,\n\t\t\t\t\t\tcooldownDelay: groupedSubcommand.cooldownDelay,\n\t\t\t\t\t\tcooldownFilteredUsers: groupedSubcommand.cooldownFilteredUsers,\n\t\t\t\t\t\tcooldownLimit: groupedSubcommand.cooldownLimit,\n\t\t\t\t\t\tcooldownScope: groupedSubcommand.cooldownScope,\n\t\t\t\t\t\tsubcommandGroupName: subcommand.name,\n\t\t\t\t\t\tsubcommandMethodName: groupedSubcommand.name,\n\t\t\t\t\t\tpreconditionContainerArray\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.subcommandPreconditions.set(`${subcommand.name}.${groupedSubcommand.name}`, preconditionContainerArray);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// #endregion\n\t}\n\n\tpublic override onLoad() {\n\t\tsuper.onLoad();\n\n\t\tconst externalMapping = Reflect.get(this, 'subcommandMappings');\n\t\tif (externalMapping) {\n\t\t\tconst subcommands = Array.isArray(externalMapping) ? externalMapping : [];\n\t\t\tthis.parsedSubcommandMappings = subcommands;\n\t\t\tthis.options.subcommands = subcommands;\n\t\t}\n\t}\n\n\t/**\n\t * Whether this command has message-based subcommands or not\n\t * @returns `true` if this command has message-based subcommands, otherwise `false`\n\t */\n\tpublic override supportsMessageCommands(): this is MessageCommand {\n\t\treturn this.#supportsCommandType('messageRun');\n\t}\n\n\t/**\n\t * Whether this command has chat input subcommands or not\n\t * @returns `true` if this command has chat input subcommands, otherwise `false`\n\t */\n\tpublic override supportsChatInputCommands(): this is ChatInputCommand {\n\t\treturn this.#supportsCommandType('chatInputRun');\n\t}\n\n\t/**\n\t * The method that is ran when a message-based subcommand is ran.\n\t *\n\t * **DO NOT** override this in your implementation of a subcommand!\n\t */\n\tpublic override async messageRun(message: Message, args: PreParseReturn, context: MessageCommand.RunContext) {\n\t\targs.save();\n\t\tconst subcommandOrGroup = args.nextMaybe();\n\t\tconst subcommandName = args.nextMaybe();\n\t\tlet defaultCommand: SubcommandMappingMethod | null = null;\n\t\tlet actualSubcommandToRun: SubcommandMappingMethod | null = null;\n\t\tlet matchedWithGroupedSubcommand = false;\n\n\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\tif (mapping.type === 'method') {\n\t\t\t\tif (mapping.default && !defaultCommand) {\n\t\t\t\t\tmatchedWithGroupedSubcommand = false;\n\t\t\t\t\tdefaultCommand = mapping;\n\t\t\t\t}\n\n\t\t\t\tif (subcommandOrGroup.isSomeAnd((value) => mapping.name === (this.caseInsensitiveSubcommands ? value.toLowerCase() : value))) {\n\t\t\t\t\tactualSubcommandToRun = mapping;\n\t\t\t\t\tmatchedWithGroupedSubcommand = false;\n\t\t\t\t\t// Exit early\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We expect a group mapping\n\t\t\tif (mapping.type === 'group' && subcommandOrGroup.isSome() && subcommandName.isSome()) {\n\t\t\t\tconst unwrappedSubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\tconst unwrappedSubcommandName = subcommandName.unwrap();\n\n\t\t\t\t// We know a group was passed in here\n\t\t\t\tif (mapping.name === unwrappedSubcommandGroupName) {\n\t\t\t\t\t// Find the actual subcommand to run\n\t\t\t\t\tconst findResult = this.#findSubcommand(\n\t\t\t\t\t\tmapping.entries,\n\t\t\t\t\t\tthis.caseInsensitiveSubcommands ? unwrappedSubcommandName.toLowerCase() : unwrappedSubcommandName\n\t\t\t\t\t);\n\n\t\t\t\t\tif (findResult.defaultMatch) {\n\t\t\t\t\t\tdefaultCommand = findResult.mapping;\n\t\t\t\t\t\tmatchedWithGroupedSubcommand = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactualSubcommandToRun = findResult.mapping;\n\t\t\t\t\t\tmatchedWithGroupedSubcommand = true;\n\t\t\t\t\t\t// Exit early\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Preemptively restore the args state, to provide a correct args result for users\n\t\targs.restore();\n\n\t\tif (actualSubcommandToRun) {\n\t\t\t// Skip over the subcommandOrGroup\n\t\t\targs.next();\n\n\t\t\t// If we matched with a subcommand in a group we need to skip 1 more arg\n\t\t\tlet subcommandGroupName: string | undefined = undefined;\n\t\t\tif (matchedWithGroupedSubcommand) {\n\t\t\t\tsubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\targs.next();\n\t\t\t}\n\n\t\t\treturn this.#handleMessageRun(message, args, context, actualSubcommandToRun, subcommandGroupName);\n\t\t}\n\n\t\t// No subcommand matched, let's try to run default, if any:\n\t\tif (defaultCommand) {\n\t\t\t// If we matched with a subcommand in a group we need to skip 1 the group name\n\t\t\tlet subcommandGroupName: string | undefined = undefined;\n\t\t\tif (matchedWithGroupedSubcommand) {\n\t\t\t\tsubcommandGroupName = subcommandOrGroup.unwrap();\n\t\t\t\targs.next();\n\t\t\t}\n\n\t\t\treturn this.#handleMessageRun(message, args, context, defaultCommand, subcommandGroupName);\n\t\t}\n\n\t\tconst commandPrefix = this.#getCommandPrefix(message.content, args.commandContext.prefix);\n\t\tconst prefixLessContent = message.content.slice(commandPrefix.length).trim();\n\n\t\t// No match and no subcommand, emit an error:\n\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandNoMatch, message, args, {\n\t\t\t...context,\n\t\t\tcommand: this,\n\t\t\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch,\n\t\t\tmessage: `Unable to match a subcommand on message command \"${this.name}\" at path \"${this.location.full}\" with content ${prefixLessContent}`,\n\t\t\tpossibleSubcommandName: subcommandName.unwrapOr(null),\n\t\t\tpossibleSubcommandGroupOrName: subcommandOrGroup.unwrapOr(null)\n\t\t});\n\t}\n\n\t/**\n\t * The method that is ran when a chat input based subcommand is ran.\n\t *\n\t * **DO NOT** override this in your implementation of a subcommand!\n\t */\n\tpublic override async chatInputRun(interaction: ChatInputCommand.Interaction, context: ChatInputCommand.RunContext) {\n\t\tconst subcommandName = interaction.options.getSubcommand(false);\n\t\tconst subcommandGroupName = interaction.options.getSubcommandGroup(false);\n\n\t\tfor (const mapping of this.parsedSubcommandMappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\t// If we have a group, we know we also have a subcommand and we should find and run it\n\t\t\tif (subcommandGroupName && subcommandName) {\n\t\t\t\tif (mapping.type !== 'group') continue;\n\t\t\t\tif (mapping.name !== subcommandGroupName) continue;\n\n\t\t\t\tconst foundSubcommand = this.#findSubcommand(mapping.entries, subcommandName!);\n\n\t\t\t\t// Only run if its not the \"default\" found command mapping, as interactions don't have that\n\t\t\t\tif (!foundSubcommand.defaultMatch) {\n\t\t\t\t\treturn this.#handleChatInputInteractionRun(interaction, context, foundSubcommand.mapping, subcommandGroupName);\n\t\t\t\t}\n\n\t\t\t\t// Skip to the next entry\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If we have a direct subcommand, and no group, then run the mapping\n\t\t\tif (mapping.type === 'method' && mapping.name === subcommandName) {\n\t\t\t\treturn this.#handleChatInputInteractionRun(interaction, context, mapping, undefined);\n\t\t\t}\n\t\t}\n\n\t\t// No match and no subcommand, emit an error:\n\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandNoMatch, interaction, {\n\t\t\t...context,\n\t\t\tcommand: this,\n\t\t\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch,\n\t\t\tmessage: `Unable to match a subcommand on chat input command \"${this.name}\" at path \"${this.location.full}\"`\n\t\t});\n\t}\n\n\t#getCommandPrefix(content: string, prefix: string | RegExp): string {\n\t\treturn typeof prefix === 'string' ? prefix : prefix.exec(content)![0];\n\t}\n\n\tasync #getMessageParametersAsString(args: Args): Promise<Partial<Pick<MessageCommandDeniedPayload, 'parameters'>>> {\n\t\targs.save();\n\t\tconst parameters = await args.restResult('string');\n\t\targs.restore();\n\n\t\tconst params: Partial<Pick<MessageCommandDeniedPayload, 'parameters'>> = {};\n\n\t\tif (parameters.isOk()) {\n\t\t\tparams.parameters = parameters.unwrap();\n\t\t}\n\n\t\treturn params;\n\t}\n\n\tasync #handleMessageRun(\n\t\tmessage: Message,\n\t\targs: Args,\n\t\tcontext: MessageCommand.RunContext,\n\t\tsubcommand: SubcommandMappingMethod,\n\t\tsubcommandGroupName: string | undefined\n\t) {\n\t\tconst payload: MessageSubcommandAcceptedPayload = {\n\t\t\tmessage,\n\t\t\tcommand: this,\n\t\t\tcontext,\n\t\t\tmatchedSubcommandMapping: subcommand\n\t\t};\n\n\t\t// Check if any subcommand preconditions were defined for thus subcommand:\n\t\tconst preconditionsForSubcommand = this.subcommandPreconditions.get(\n\t\t\tsubcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name\n\t\t);\n\n\t\tif (preconditionsForSubcommand) {\n\t\t\t// Attempt to get the remaining parameters as string:\n\t\t\tconst messageParametersAsString = await this.#getMessageParametersAsString(args);\n\n\t\t\t// Build the precondition payload:\n\t\t\tconst preconditionPayload = { ...messageParametersAsString, ...payload };\n\n\t\t\t// Run the subcommand specific preconditions:\n\t\t\tconst localSubcommandResult = await preconditionsForSubcommand.messageRun(message, this, preconditionPayload as any);\n\t\t\tif (localSubcommandResult.isErr()) {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandDenied, localSubcommandResult.unwrapErr(), preconditionPayload);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If subcommand preconditions have passed then we run the actual subcommand:\n\t\tconst result = await Result.fromAsync(async () => {\n\t\t\tif (subcommand.messageRun) {\n\t\t\t\tconst casted = subcommand as MessageSubcommandMappingMethod;\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandRun, message, casted, payload);\n\t\t\t\tlet result: unknown;\n\n\t\t\t\tif (typeof subcommand.messageRun === 'string') {\n\t\t\t\t\tconst method = Reflect.get(this, subcommand.messageRun);\n\t\t\t\t\tif (!method) {\n\t\t\t\t\t\tthrow new UserError({\n\t\t\t\t\t\t\tidentifier: SubcommandPluginIdentifiers.SubcommandNotFound,\n\t\t\t\t\t\t\tmessage: `The method configured at \"messageRun\" for the subcommand ${subcommand.name} was not implemented in the class.`,\n\t\t\t\t\t\t\tcontext: { ...payload }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tresult = await Reflect.apply(cast<this['messageRun']>(method), this, [message, args, context]);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await subcommand.messageRun(message, args, context);\n\t\t\t\t}\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.MessageSubcommandSuccess, message, casted, { ...payload, result });\n\t\t\t} else {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler, message, subcommand, payload);\n\t\t\t}\n\t\t});\n\n\t\tresult.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.MessageSubcommandError, error, payload));\n\t}\n\n\tasync #handleChatInputInteractionRun(\n\t\tinteraction: ChatInputCommand.Interaction,\n\t\tcontext: ChatInputCommand.RunContext,\n\t\tsubcommand: SubcommandMappingMethod,\n\t\tsubcommandGroupName: string | undefined\n\t) {\n\t\tconst payload: ChatInputSubcommandAcceptedPayload = {\n\t\t\tcommand: this,\n\t\t\tcontext,\n\t\t\tinteraction,\n\t\t\tmatchedSubcommandMapping: subcommand\n\t\t};\n\n\t\t// Check if any subcommand preconditions were defined for thus subcommand:\n\t\tconst preconditionsForSubcommand = this.subcommandPreconditions.get(\n\t\t\tsubcommandGroupName ? `${subcommandGroupName}.${subcommand.name}` : subcommand.name\n\t\t);\n\n\t\tif (preconditionsForSubcommand) {\n\t\t\t// Run the subcommand specific preconditions:\n\t\t\tconst localSubcommandResult = await preconditionsForSubcommand.chatInputRun(interaction, this, payload as any);\n\t\t\tif (localSubcommandResult.isErr()) {\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandDenied, localSubcommandResult.unwrapErr(), payload);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst result = await Result.fromAsync(async () => {\n\t\t\tif (subcommand.chatInputRun) {\n\t\t\t\tconst casted = subcommand as ChatInputCommandSubcommandMappingMethod;\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandRun, interaction, casted, payload);\n\t\t\t\tlet result: unknown;\n\n\t\t\t\tif (typeof subcommand.chatInputRun === 'string') {\n\t\t\t\t\tconst method = Reflect.get(this, subcommand.chatInputRun);\n\t\t\t\t\tif (!method) {\n\t\t\t\t\t\tthrow new UserError({\n\t\t\t\t\t\t\tidentifier: SubcommandPluginIdentifiers.SubcommandNotFound,\n\t\t\t\t\t\t\tmessage: `The method configured at \"chatInputRun\" for the subcommand ${subcommand.name} was not implemented in the class.`,\n\t\t\t\t\t\t\tcontext: { ...payload }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tresult = await Reflect.apply(cast<this['chatInputRun']>(method), this, [interaction, context]);\n\t\t\t\t} else {\n\t\t\t\t\tresult = await subcommand.chatInputRun(interaction, context);\n\t\t\t\t}\n\n\t\t\t\tthis.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandSuccess, interaction, casted, { ...payload, result });\n\t\t\t} else {\n\t\t\t\tthis.container.client.emit(\n\t\t\t\t\tSubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler,\n\t\t\t\t\tinteraction,\n\t\t\t\t\tsubcommand,\n\t\t\t\t\tpayload\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tresult.inspectErr((error) => this.container.client.emit(SubcommandPluginEvents.ChatInputSubcommandError, error, payload));\n\t}\n\n\t#findSubcommand(mappings: SubcommandMappingMethod[], expectedName: string) {\n\t\tlet foundDefault: SubcommandMappingMethod | null = null;\n\n\t\tfor (const mapping of mappings) {\n\t\t\tmapping.type ??= 'method';\n\n\t\t\tif (mapping.default) {\n\t\t\t\tfoundDefault = mapping;\n\t\t\t}\n\n\t\t\tif (mapping.name === expectedName) {\n\t\t\t\treturn { mapping, defaultMatch: false } as const;\n\t\t\t}\n\t\t}\n\n\t\treturn { mapping: foundDefault, defaultMatch: true } as const;\n\t}\n\n\t#supportsCommandType(commandType: 'messageRun' | 'chatInputRun'): boolean {\n\t\treturn this.parsedSubcommandMappings.some((mapping) => {\n\t\t\tif (mapping.type === 'group') {\n\t\t\t\treturn mapping.entries.some((groupCommand) => Reflect.has(groupCommand, commandType));\n\t\t\t}\n\t\t\treturn Reflect.has(mapping, commandType);\n\t\t});\n\t}\n}\n\nexport interface SubcommandOptions extends Command.Options {\n\tsubcommands?: SubcommandMappingArray;\n\t/**\n\t * Whether to add aliases for subcommands with dashes in them\n\t *\n\t * When this option is enabled *and* the subcommand implements `messageRun`, dashless aliases will be added.\n\t *\n\t * For subcommands groups both the group itself and all subcommands within the group will have dashless aliases added.\n\t *\n\t * @since 3.0.0\n\t * @default false\n\t */\n\tgenerateDashLessAliases?: boolean;\n}\n\nexport namespace Subcommand {\n\texport type Options = SubcommandOptions;\n\texport type JSON = Command.JSON;\n\t/** @deprecated Use {@linkcode LoaderContext} instead. */\n\texport type Context = LoaderContext;\n\texport type LoaderContext = Command.LoaderContext;\n\texport type RunInTypes = Command.RunInTypes;\n\texport type ChatInputCommandInteraction<Cached extends CacheType = CacheType> = Command.ChatInputCommandInteraction<Cached>;\n\texport type ContextMenuCommandInteraction<Cached extends CacheType = CacheType> = Command.ContextMenuCommandInteraction<Cached>;\n\texport type AutocompleteInteraction<Cached extends CacheType = CacheType> = Command.AutocompleteInteraction<Cached>;\n\texport type Registry = Command.Registry;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name } from '../../chunk-
|
|
1
|
+
import { __name } from '../../chunk-3IXKS7M5.mjs';
|
|
2
2
|
import { BucketScope } from '@sapphire/framework';
|
|
3
3
|
import { container } from '@sapphire/pieces';
|
|
4
4
|
import '../Subcommand.mjs';
|
|
@@ -32,5 +32,5 @@ function parseSubcommandConstructorPreConditionsCooldown({
|
|
|
32
32
|
__name(parseSubcommandConstructorPreConditionsCooldown, "parseSubcommandConstructorPreConditionsCooldown");
|
|
33
33
|
|
|
34
34
|
export { parseSubcommandConstructorPreConditionsCooldown };
|
|
35
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=subcommandCooldown.mjs.map
|
|
36
36
|
//# sourceMappingURL=subcommandCooldown.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/precondition-resolvers/subcommandCooldown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/precondition-resolvers/subcommandCooldown.ts"],"names":[],"mappings":";;;;;;AAkCO,SAAS,+CAGd,CAAA;AAAA,EACD,UAAY,EAAA,OAAA;AAAA,EACZ,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,qBAAA;AAAA,EACA,oBAAA;AAAA,EACA,mBAAA;AAAA,EACA,0BAAA;AACD,CAAuF,EAAA;AACtF,EAAA,MAAM,EAAE,yBAAA,EAA8B,GAAA,SAAA,CAAU,MAAO,CAAA,OAAA,CAAA;AAKvD,EAAM,MAAA,QAAA,GACL,2BAA2B,gBAAkB,EAAA,QAAA;AAAA,IAC5C,mBAAsB,GAAA,CAAA,EAAG,OAAQ,CAAA,IAAI,CAAI,CAAA,EAAA,mBAAmB,CAAI,CAAA,EAAA,oBAAoB,CAAK,CAAA,GAAA,CAAA,EAAG,OAAQ,CAAA,IAAI,IAAI,oBAAoB,CAAA,CAAA;AAAA,GAC5H,IAAA,KAAA,CAAA;AACN,EAAA,MAAM,KAAQ,GAAA,aAAA,KAAkB,QAAW,GAAA,CAAA,GAAK,2BAA2B,KAAS,IAAA,CAAA,CAAA,CAAA;AACpF,EAAA,MAAM,KAAQ,GAAA,aAAA,KAAkB,QAAW,GAAA,CAAA,GAAK,2BAA2B,KAAS,IAAA,CAAA,CAAA,CAAA;AAEpF,EAAA,IAAI,SAAS,KAAO,EAAA;AACnB,IAAA,MAAM,KAAQ,GAAA,aAAA,IAAiB,yBAA2B,EAAA,KAAA,IAAS,WAAY,CAAA,IAAA,CAAA;AAC/E,IAAM,MAAA,aAAA,GAAgB,yBAAyB,yBAA2B,EAAA,aAAA,CAAA;AAE1E,IAAA,0BAAA,CAA2B,MAAO,CAAA;AAAA,MACjC,MAAM,8BAA+B,CAAA,wBAAA;AAAA,MACrC,SAAS,EAAE,KAAA,EAAO,OAAO,KAAO,EAAA,aAAA,EAAe,qBAAqB,oBAAqB,EAAA;AAAA,KACzF,CAAA,CAAA;AAAA,GACF;AACD,CAAA;AAlCgB,MAAA,CAAA,+CAAA,EAAA,iDAAA,CAAA","file":"subcommandCooldown.mjs","sourcesContent":["import { Args, BucketScope, PreconditionContainerArray } from '@sapphire/framework';\nimport { container } from '@sapphire/pieces';\nimport { Subcommand } from '../Subcommand';\nimport { SubcommandCommandPreConditions } from '../types/Enums';\n\n/** The options for adding this subcommand cooldown precondition */\nexport interface ParseSubcommandConstructorPreConditionsCooldownParameters<\n\tPreParseReturn extends Args = Args,\n\tOptions extends Subcommand.Options = Subcommand.Options\n> {\n\t/** The command to parse cooldowns for. */\n\tsubcommand: Subcommand<PreParseReturn, Options>;\n\t/** The cooldown limit to use. */\n\tcooldownLimit: number | undefined;\n\t/** The cooldown delay to use. */\n\tcooldownDelay: number | undefined;\n\t/** The cooldown scope to use. */\n\tcooldownScope: BucketScope | undefined;\n\t/** The cooldown filtered users to use. */\n\tcooldownFilteredUsers: string[] | undefined;\n\t/** The name this precondition is for. */\n\tsubcommandMethodName: string;\n\t/** The group this precondition is for, if any. */\n\tsubcommandGroupName?: string;\n\t/** The precondition container array to append the precondition to. */\n\tpreconditionContainerArray: PreconditionContainerArray;\n}\n\n/**\n * Appends the `PluginSubcommandCooldown` precondition when {@link Subcommand.Options.cooldownLimit} and\n * {@link Subcommand.Options.cooldownDelay} are both non-zero.\n *\n * @param options The {@link ParseSubcommandConstructorPreConditionsCooldownParameters} for adding this subcommand cooldown precondition\n */\nexport function parseSubcommandConstructorPreConditionsCooldown<\n\tPreParseReturn extends Args = Args,\n\tOptions extends Subcommand.Options = Subcommand.Options\n>({\n\tsubcommand: command,\n\tcooldownLimit,\n\tcooldownDelay,\n\tcooldownScope,\n\tcooldownFilteredUsers,\n\tsubcommandMethodName,\n\tsubcommandGroupName,\n\tpreconditionContainerArray\n}: ParseSubcommandConstructorPreConditionsCooldownParameters<PreParseReturn, Options>) {\n\tconst { subcommandDefaultCooldown } = container.client.options;\n\n\t// We will check for whether the subcommand is filtered from the defaults, but we will allow overridden values to\n\t// be set. If an overridden value is passed, it will have priority. Otherwise, it will default to 0 if filtered\n\t// (causing the precondition to not be registered) or the default value with a fallback to a single-use cooldown.\n\tconst filtered =\n\t\tsubcommandDefaultCooldown?.filteredCommands?.includes(\n\t\t\tsubcommandGroupName ? `${command.name}.${subcommandGroupName}.${subcommandMethodName}` : `${command.name}.${subcommandMethodName}`\n\t\t) ?? false;\n\tconst limit = cooldownLimit ?? (filtered ? 0 : (subcommandDefaultCooldown?.limit ?? 1));\n\tconst delay = cooldownDelay ?? (filtered ? 0 : (subcommandDefaultCooldown?.delay ?? 0));\n\n\tif (limit && delay) {\n\t\tconst scope = cooldownScope ?? subcommandDefaultCooldown?.scope ?? BucketScope.User;\n\t\tconst filteredUsers = cooldownFilteredUsers ?? subcommandDefaultCooldown?.filteredUsers;\n\n\t\tpreconditionContainerArray.append({\n\t\t\tname: SubcommandCommandPreConditions.PluginSubcommandCooldown,\n\t\t\tcontext: { scope, limit, delay, filteredUsers, subcommandGroupName, subcommandMethodName }\n\t\t});\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '../../chunk-
|
|
1
|
+
import '../../chunk-3IXKS7M5.mjs';
|
|
2
2
|
|
|
3
3
|
// src/lib/types/Enums.ts
|
|
4
4
|
var SubcommandCommandPreConditions = /* @__PURE__ */ ((SubcommandCommandPreConditions2) => {
|
|
@@ -11,5 +11,5 @@ var SubcommandIdentifiers = /* @__PURE__ */ ((SubcommandIdentifiers2) => {
|
|
|
11
11
|
})(SubcommandIdentifiers || {});
|
|
12
12
|
|
|
13
13
|
export { SubcommandCommandPreConditions, SubcommandIdentifiers };
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=Enums.mjs.map
|
|
15
15
|
//# sourceMappingURL=Enums.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/types/Enums.ts"],"names":["SubcommandCommandPreConditions","SubcommandIdentifiers"],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/types/Enums.ts"],"names":["SubcommandCommandPreConditions","SubcommandIdentifiers"],"mappings":";;;AAIY,IAAA,8BAAA,qBAAAA,+BAAL,KAAA;AACN,EAAAA,gCAAA,0BAA2B,CAAA,GAAA,0BAAA,CAAA;AADhB,EAAAA,OAAAA,+BAAAA,CAAAA;AAAA,CAAA,EAAA,8BAAA,IAAA,EAAA,EAAA;AAQA,IAAA,qBAAA,qBAAAC,sBAAL,KAAA;AAEN,EAAAA,uBAAA,gCAAiC,CAAA,GAAA,gCAAA,CAAA;AAFtB,EAAAA,OAAAA,sBAAAA,CAAAA;AAAA,CAAA,EAAA,qBAAA,IAAA,EAAA","file":"Enums.mjs","sourcesContent":["/**\n * The available command pre-conditions.\n * @since 2.0.0\n */\nexport enum SubcommandCommandPreConditions {\n\tPluginSubcommandCooldown = 'PluginSubcommandCooldown'\n}\n\n/**\n * The available subcommand pre-conditions.\n * @since 5.1.0\n */\nexport enum SubcommandIdentifiers {\n\t/** The identifier for the subcommand cooldown precondition */\n\tSubcommandPreconditionCooldown = 'subcommandPreconditionCooldown'\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '../../chunk-
|
|
1
|
+
import '../../chunk-3IXKS7M5.mjs';
|
|
2
2
|
|
|
3
3
|
// src/lib/types/Events.ts
|
|
4
4
|
var SubcommandPluginEvents = {
|
|
@@ -6,10 +6,12 @@ var SubcommandPluginEvents = {
|
|
|
6
6
|
ChatInputSubcommandRun: "chatInputSubcommandRun",
|
|
7
7
|
ChatInputSubcommandSuccess: "chatInputSubcommandSuccess",
|
|
8
8
|
ChatInputSubcommandError: "chatInputSubcommandError",
|
|
9
|
+
ChatInputSubcommandNoMatch: "chatInputSubcommandNoMatch",
|
|
9
10
|
MessageSubcommandDenied: "messageSubcommandDenied",
|
|
10
11
|
MessageSubcommandRun: "messageSubcommandRun",
|
|
11
12
|
MessageSubcommandSuccess: "messageSubcommandSuccess",
|
|
12
13
|
MessageSubcommandError: "messageSubcommandError",
|
|
14
|
+
MessageSubcommandNoMatch: "messageSubcommandNoMatch",
|
|
13
15
|
SubcommandMappingIsMissingMessageCommandHandler: "subcommandMappingIsMissingMessageCommandHandler",
|
|
14
16
|
SubcommandMappingIsMissingChatInputCommandHandler: "subcommandMappingIsMissingChatInputCommandHandler"
|
|
15
17
|
};
|
|
@@ -21,5 +23,5 @@ var SubcommandPluginIdentifiers = /* @__PURE__ */ ((SubcommandPluginIdentifiers2
|
|
|
21
23
|
})(SubcommandPluginIdentifiers || {});
|
|
22
24
|
|
|
23
25
|
export { SubcommandPluginEvents, SubcommandPluginIdentifiers };
|
|
24
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=Events.mjs.map
|
|
25
27
|
//# sourceMappingURL=Events.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/types/Events.ts"],"names":["SubcommandPluginIdentifiers"],"mappings":";;;AAKO,IAAM,sBAAyB,GAAA;AAAA,EACrC,yBAA2B,EAAA,2BAAA;AAAA,EAC3B,sBAAwB,EAAA,wBAAA;AAAA,EACxB,0BAA4B,EAAA,4BAAA;AAAA,EAC5B,wBAA0B,EAAA,0BAAA;AAAA,EAC1B,0BAA4B,EAAA,4BAAA;AAAA,EAE5B,uBAAyB,EAAA,yBAAA;AAAA,EACzB,oBAAsB,EAAA,sBAAA;AAAA,EACtB,wBAA0B,EAAA,0BAAA;AAAA,EAC1B,sBAAwB,EAAA,wBAAA;AAAA,EACxB,wBAA0B,EAAA,0BAAA;AAAA,EAE1B,+CAAiD,EAAA,iDAAA;AAAA,EACjD,iDAAmD,EAAA,mDAAA;AACpD,EAAA;AAEY,IAAA,2BAAA,qBAAAA,4BAAL,KAAA;AACN,EAAAA,6BAAA,0BAA2B,CAAA,GAAA,0BAAA,CAAA;AAC3B,EAAAA,6BAAA,4BAA6B,CAAA,GAAA,4BAAA,CAAA;AAC7B,EAAAA,6BAAA,oBAAqB,CAAA,GAAA,oBAAA,CAAA;AAHV,EAAAA,OAAAA,4BAAAA,CAAAA;AAAA,CAAA,EAAA,2BAAA,IAAA,EAAA","file":"Events.mjs","sourcesContent":["import type { Args, ChatInputCommand, ChatInputCommandContext, MessageCommand, MessageCommandDeniedPayload, UserError } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport type { Subcommand } from '../Subcommand';\nimport type { ChatInputCommandSubcommandMappingMethod, MessageSubcommandMappingMethod, SubcommandMappingMethod } from './SubcommandMappings';\n\nexport const SubcommandPluginEvents = {\n\tChatInputSubcommandDenied: 'chatInputSubcommandDenied' as const,\n\tChatInputSubcommandRun: 'chatInputSubcommandRun' as const,\n\tChatInputSubcommandSuccess: 'chatInputSubcommandSuccess' as const,\n\tChatInputSubcommandError: 'chatInputSubcommandError' as const,\n\tChatInputSubcommandNoMatch: 'chatInputSubcommandNoMatch' as const,\n\n\tMessageSubcommandDenied: 'messageSubcommandDenied' as const,\n\tMessageSubcommandRun: 'messageSubcommandRun' as const,\n\tMessageSubcommandSuccess: 'messageSubcommandSuccess' as const,\n\tMessageSubcommandError: 'messageSubcommandError' as const,\n\tMessageSubcommandNoMatch: 'messageSubcommandNoMatch' as const,\n\n\tSubcommandMappingIsMissingMessageCommandHandler: 'subcommandMappingIsMissingMessageCommandHandler' as const,\n\tSubcommandMappingIsMissingChatInputCommandHandler: 'subcommandMappingIsMissingChatInputCommandHandler' as const\n};\n\nexport enum SubcommandPluginIdentifiers {\n\tMessageSubcommandNoMatch = 'messageSubcommandNoMatch',\n\tChatInputSubcommandNoMatch = 'chatInputSubcommandNoMatch',\n\tSubcommandNotFound = 'subcommandNotFound'\n}\n\nexport interface MessageSubcommandNoMatchContext extends MessageCommand.RunContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.MessageSubcommandNoMatch;\n\tmessage: string;\n\tpossibleSubcommandName: string | null;\n\tpossibleSubcommandGroupOrName: string | null;\n}\n\nexport interface ChatInputSubcommandNoMatchContext extends ChatInputCommandContext {\n\tcommand: Subcommand;\n\tidentifier: SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch;\n\tmessage: string;\n}\n\nexport interface IMessageSubcommandPayload {\n\tmessage: Message;\n\tcommand: Subcommand;\n}\n\nexport interface MessageSubcommandDeniedPayload\n\textends Omit<MessageCommandDeniedPayload, 'parameters' | 'command'>,\n\t\tMessageSubcommandAcceptedPayload {\n\tparameters?: string;\n}\n\nexport interface MessageSubcommandAcceptedPayload extends IMessageSubcommandPayload {\n\tcontext: MessageCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface MessageSubcommandRunPayload extends MessageSubcommandAcceptedPayload {}\n\nexport interface MessageSubcommandErrorPayload extends MessageSubcommandRunPayload {}\n\nexport interface MessageSubcommandSuccessPayload extends MessageSubcommandRunPayload {\n\tresult: unknown;\n}\n\nexport interface IChatInputSubcommandPayload {\n\tinteraction: ChatInputCommand.Interaction;\n\tcommand: Subcommand;\n}\n\nexport interface ChatInputSubcommandAcceptedPayload extends IChatInputSubcommandPayload {\n\tcontext: ChatInputCommand.RunContext;\n\tmatchedSubcommandMapping: SubcommandMappingMethod;\n}\n\nexport interface ChatInputSubcommandDeniedPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandRunPayload extends ChatInputSubcommandAcceptedPayload {}\n\nexport interface ChatInputSubcommandErrorPayload extends ChatInputSubcommandRunPayload {}\n\nexport interface ChatInputSubcommandSuccessPayload extends ChatInputSubcommandRunPayload {\n\tresult: unknown;\n}\n\ndeclare module 'discord.js' {\n\tinterface ClientEvents {\n\t\t[SubcommandPluginEvents.ChatInputSubcommandDenied]: [error: UserError, payload: ChatInputSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandRun]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandSuccess]: [\n\t\t\tinteraction: ChatInputCommand.Interaction,\n\t\t\tsubcommand: ChatInputCommandSubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandError]: [error: unknown, payload: ChatInputSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.ChatInputSubcommandNoMatch]: [interaction: ChatInputCommand.Interaction, context: ChatInputSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.MessageSubcommandDenied]: [error: UserError, payload: MessageSubcommandDeniedPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandRun]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandRunPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandSuccess]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: MessageSubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandSuccessPayload\n\t\t];\n\t\t[SubcommandPluginEvents.MessageSubcommandError]: [error: unknown, payload: MessageSubcommandErrorPayload];\n\t\t[SubcommandPluginEvents.MessageSubcommandNoMatch]: [message: Message, args: Args, context: MessageSubcommandNoMatchContext];\n\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler]: [\n\t\t\tmessage: Message,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: MessageSubcommandAcceptedPayload\n\t\t];\n\t\t[SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler]: [\n\t\t\tmessage: ChatInputCommand.Interaction,\n\t\t\tsubcommand: SubcommandMappingMethod,\n\t\t\tpayload: ChatInputSubcommandAcceptedPayload\n\t\t];\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"SubcommandMappings.mjs"}
|
|
@@ -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=PluginChatInputSubcommandError.mjs.map
|
|
19
19
|
//# sourceMappingURL=PluginChatInputSubcommandError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginChatInputSubcommandError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginChatInputSubcommandError.ts"],"names":[],"mappings":";;;;AAGO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAiE,CAAA;AAAA,EAC7F,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,0BAA0B,CAAA,CAAA;AAAA,GAC1E;AAAA,EAEgB,GAAA,CAAI,OAAgB,OAA0C,EAAA;AAC7E,IAAA,MAAM,EAAE,IAAA,EAAM,QAAS,EAAA,GAAI,OAAQ,CAAA,OAAA,CAAA;AACnC,IAAK,IAAA,CAAA,SAAA,CAAU,OAAO,KAAM,CAAA,CAAA,4CAAA,EAA+C,IAAI,CAAc,WAAA,EAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA,CAAA;AAAA,GACrH;AACD,CAAA,CAAA;AATqG,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAA9F,IAAM,cAAN,GAAA","file":"PluginChatInputSubcommandError.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport { SubcommandPluginEvents, type ChatInputSubcommandErrorPayload } from '../lib/types/Events';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandError> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.ChatInputSubcommandError });\n\t}\n\n\tpublic override run(error: unknown, context: ChatInputSubcommandErrorPayload) {\n\t\tconst { name, location } = context.command;\n\t\tthis.container.logger.error(`Encountered error on chat input subcommand \"${name}\" at path \"${location.full}\"`, error);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __name } from '../chunk-3IXKS7M5.mjs';
|
|
2
|
+
import { Listener } from '@sapphire/framework';
|
|
3
|
+
import { SubcommandPluginEvents } from '../lib/types/Events.mjs';
|
|
4
|
+
|
|
5
|
+
var _PluginListener = class _PluginListener extends Listener {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
super(context, { event: SubcommandPluginEvents.ChatInputSubcommandNoMatch });
|
|
8
|
+
}
|
|
9
|
+
run(_interaction, context) {
|
|
10
|
+
this.container.logger.error(context.message);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
__name(_PluginListener, "PluginListener");
|
|
14
|
+
var PluginListener = _PluginListener;
|
|
15
|
+
|
|
16
|
+
export { PluginListener };
|
|
17
|
+
//# sourceMappingURL=PluginChatInputSubcommandNoMatch.mjs.map
|
|
18
|
+
//# sourceMappingURL=PluginChatInputSubcommandNoMatch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginChatInputSubcommandNoMatch.ts"],"names":[],"mappings":";;;;AAGO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAmE,CAAA;AAAA,EAC/F,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,4BAA4B,CAAA,CAAA;AAAA,GAC5E;AAAA,EAEgB,GAAA,CAAI,cAA4C,OAA4C,EAAA;AAC3G,IAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,GAC5C;AACD,CAAA,CAAA;AARuG,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAhG,IAAM,cAAN,GAAA","file":"PluginChatInputSubcommandNoMatch.mjs","sourcesContent":["import { Listener, type ChatInputCommand } from '@sapphire/framework';\nimport { SubcommandPluginEvents, type ChatInputSubcommandNoMatchContext } from '../lib/types/Events';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandNoMatch> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.ChatInputSubcommandNoMatch });\n\t}\n\n\tpublic override run(_interaction: ChatInputCommand.Interaction, context: ChatInputSubcommandNoMatchContext) {\n\t\tthis.container.logger.error(context.message);\n\t}\n}\n"]}
|
|
@@ -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=PluginMessageSubcommandError.mjs.map
|
|
19
19
|
//# sourceMappingURL=PluginMessageSubcommandError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginMessageSubcommandError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginMessageSubcommandError.ts"],"names":[],"mappings":";;;;AAGO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAA+D,CAAA;AAAA,EAC3F,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,wBAAwB,CAAA,CAAA;AAAA,GACxE;AAAA,EAEgB,GAAA,CAAI,OAAgB,OAAwC,EAAA;AAC3E,IAAA,MAAM,EAAE,IAAA,EAAM,QAAS,EAAA,GAAI,OAAQ,CAAA,OAAA,CAAA;AACnC,IAAK,IAAA,CAAA,SAAA,CAAU,OAAO,KAAM,CAAA,CAAA,yCAAA,EAA4C,IAAI,CAAc,WAAA,EAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA,CAAA;AAAA,GAClH;AACD,CAAA,CAAA;AATmG,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAA5F,IAAM,cAAN,GAAA","file":"PluginMessageSubcommandError.mjs","sourcesContent":["import { Listener } from '@sapphire/framework';\nimport { SubcommandPluginEvents, type MessageSubcommandErrorPayload } from '../lib/types/Events';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.MessageSubcommandError> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.MessageSubcommandError });\n\t}\n\n\tpublic override run(error: unknown, context: MessageSubcommandErrorPayload) {\n\t\tconst { name, location } = context.command;\n\t\tthis.container.logger.error(`Encountered error on message subcommand \"${name}\" at path \"${location.full}\"`, error);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __name } from '../chunk-3IXKS7M5.mjs';
|
|
2
|
+
import { Listener } from '@sapphire/framework';
|
|
3
|
+
import { SubcommandPluginEvents } from '../lib/types/Events.mjs';
|
|
4
|
+
|
|
5
|
+
var _PluginListener = class _PluginListener extends Listener {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
super(context, { event: SubcommandPluginEvents.MessageSubcommandNoMatch });
|
|
8
|
+
}
|
|
9
|
+
run(_message, _args, context) {
|
|
10
|
+
this.container.logger.error(context.message);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
__name(_PluginListener, "PluginListener");
|
|
14
|
+
var PluginListener = _PluginListener;
|
|
15
|
+
|
|
16
|
+
export { PluginListener };
|
|
17
|
+
//# sourceMappingURL=PluginMessageSubcommandNoMatch.mjs.map
|
|
18
|
+
//# sourceMappingURL=PluginMessageSubcommandNoMatch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginMessageSubcommandNoMatch.ts"],"names":[],"mappings":";;;;AAIO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAAiE,CAAA;AAAA,EAC7F,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,0BAA0B,CAAA,CAAA;AAAA,GAC1E;AAAA,EAEgB,GAAA,CAAI,QAAmB,EAAA,KAAA,EAAa,OAA0C,EAAA;AAC7F,IAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,GAC5C;AACD,CAAA,CAAA;AARqG,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAA9F,IAAM,cAAN,GAAA","file":"PluginMessageSubcommandNoMatch.mjs","sourcesContent":["import { Args, Listener } from '@sapphire/framework';\nimport type { Message } from 'discord.js';\nimport { SubcommandPluginEvents, type MessageSubcommandNoMatchContext } from '../lib/types/Events';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.MessageSubcommandNoMatch> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.MessageSubcommandNoMatch });\n\t}\n\n\tpublic override run(_message: Message, _args: Args, context: MessageSubcommandNoMatchContext) {\n\t\tthis.container.logger.error(context.message);\n\t}\n}\n"]}
|
|
@@ -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=PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs.map
|
|
19
19
|
//# sourceMappingURL=PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.ts"],"names":[],"mappings":";;;;AAIO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,QAA0F,CAAA;AAAA,EACtH,YAAY,OAAiC,EAAA;AACnD,IAAA,KAAA,CAAM,OAAS,EAAA,EAAE,KAAO,EAAA,sBAAA,CAAuB,mDAAmD,CAAA,CAAA;AAAA,GACnG;AAAA,EAEgB,GAAA,CAAI,CAAiC,EAAA,UAAA,EAAqC,OAA0C,EAAA;AACnI,IAAA,MAAM,EAAE,IAAA,EAAM,QAAS,EAAA,GAAI,OAAQ,CAAA,OAAA,CAAA;AACnC,IAAK,IAAA,CAAA,SAAA,CAAU,OAAO,KAAM,CAAA,CAAA,wDAAA,EAA2D,IAAI,CAAS,MAAA,EAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA,EAAK,UAAU,CAAA,CAAA;AAAA,GACjI;AACD,CAAA,CAAA;AAT8H,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,CAAA;AAAvH,IAAM,cAAN,GAAA","file":"PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs","sourcesContent":["import { Listener, type ChatInputCommand } from '@sapphire/framework';\nimport { SubcommandPluginEvents, type ChatInputSubcommandErrorPayload } from '../lib/types/Events';\nimport type { SubcommandMappingMethod } from '../lib/types/SubcommandMappings';\n\nexport class PluginListener extends Listener<typeof SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler> {\n\tpublic constructor(context: Listener.LoaderContext) {\n\t\tsuper(context, { event: SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler });\n\t}\n\n\tpublic override run(_: ChatInputCommand.Interaction, subcommand: SubcommandMappingMethod, context: ChatInputSubcommandErrorPayload) {\n\t\tconst { name, location } = context.command;\n\t\tthis.container.logger.error(`Encountered a missing mapping on chat input subcommand \"${name}\" at \"${location.full}\"`, subcommand);\n\t}\n}\n"]}
|