@sapphire/plugin-subcommands 6.0.4-next.73f41bb.0 → 6.0.4-next.7909d16.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 +26 -22
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +5 -1
- package/dist/cjs/lib/Subcommand.cjs +18 -18
- package/dist/cjs/lib/precondition-resolvers/subcommandCooldown.cjs +3 -3
- package/dist/cjs/listeners/PluginChatInputSubcommandError.cjs +2 -2
- package/dist/cjs/listeners/PluginMessageSubcommandError.cjs +2 -2
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingChatInputCommandHandler.cjs +2 -2
- package/dist/cjs/listeners/PluginSubcommandMappingIsMissingMessageCommandHandler.cjs +2 -2
- package/dist/cjs/listeners/_load.cjs +8 -8
- package/dist/cjs/preconditions/PluginSubcommandCooldown.cjs +3 -3
- package/dist/cjs/preconditions/_load.cjs +2 -2
- package/dist/cjs/register.cjs +3 -3
- package/dist/esm/index.d.mts +5 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
3
|
+
var PluginSubcommandCooldown_mjs = require('./preconditions/PluginSubcommandCooldown.mjs');
|
|
4
|
+
var Subcommand_mjs = require('./lib/Subcommand.mjs');
|
|
5
|
+
var subcommandCooldown_mjs = require('./lib/precondition-resolvers/subcommandCooldown.mjs');
|
|
6
|
+
var Enums_mjs = require('./lib/types/Enums.mjs');
|
|
7
|
+
var Events_mjs = require('./lib/types/Events.mjs');
|
|
8
|
+
var SubcommandMappings_mjs = require('./lib/types/SubcommandMappings.mjs');
|
|
9
|
+
var _load_mjs = require('./listeners/_load.mjs');
|
|
10
|
+
var _load_mjs$1 = require('./preconditions/_load.mjs');
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
13
13
|
if (e && e.__esModule) return e;
|
|
@@ -27,47 +27,51 @@ function _interopNamespace(e) {
|
|
|
27
27
|
return Object.freeze(n);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var subcommandCooldown_mjs__namespace = /*#__PURE__*/_interopNamespace(subcommandCooldown_mjs);
|
|
31
31
|
|
|
32
32
|
// src/index.ts
|
|
33
33
|
var SubcommandPreconditions = {
|
|
34
|
-
PluginSubcommandCooldown:
|
|
34
|
+
PluginSubcommandCooldown: PluginSubcommandCooldown_mjs.PluginPrecondition
|
|
35
35
|
};
|
|
36
|
-
var version = "6.0.4-next.
|
|
36
|
+
var version = "6.0.4-next.7909d16.0";
|
|
37
37
|
|
|
38
|
-
exports
|
|
38
|
+
Object.defineProperty(exports, "PluginSubcommandCooldownPrecondition", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return PluginSubcommandCooldown_mjs.PluginPrecondition; }
|
|
41
|
+
});
|
|
42
|
+
exports.SubcommandPreconditionResolvers = subcommandCooldown_mjs__namespace;
|
|
39
43
|
Object.defineProperty(exports, "loadListeners", {
|
|
40
44
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
45
|
+
get: function () { return _load_mjs.loadListeners; }
|
|
42
46
|
});
|
|
43
47
|
Object.defineProperty(exports, "loadPreconditions", {
|
|
44
48
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
49
|
+
get: function () { return _load_mjs$1.loadPreconditions; }
|
|
46
50
|
});
|
|
47
51
|
exports.SubcommandPreconditions = SubcommandPreconditions;
|
|
48
52
|
exports.version = version;
|
|
49
|
-
Object.keys(
|
|
53
|
+
Object.keys(Subcommand_mjs).forEach(function (k) {
|
|
50
54
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
51
55
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
56
|
+
get: function () { return Subcommand_mjs[k]; }
|
|
53
57
|
});
|
|
54
58
|
});
|
|
55
|
-
Object.keys(
|
|
59
|
+
Object.keys(Enums_mjs).forEach(function (k) {
|
|
56
60
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
57
61
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
62
|
+
get: function () { return Enums_mjs[k]; }
|
|
59
63
|
});
|
|
60
64
|
});
|
|
61
|
-
Object.keys(
|
|
65
|
+
Object.keys(Events_mjs).forEach(function (k) {
|
|
62
66
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
63
67
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
68
|
+
get: function () { return Events_mjs[k]; }
|
|
65
69
|
});
|
|
66
70
|
});
|
|
67
|
-
Object.keys(
|
|
71
|
+
Object.keys(SubcommandMappings_mjs).forEach(function (k) {
|
|
68
72
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
69
73
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
74
|
+
get: function () { return SubcommandMappings_mjs[k]; }
|
|
71
75
|
});
|
|
72
76
|
});
|
|
73
77
|
//# sourceMappingURL=out.js.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";AACA;AAAA,EACC,sBAAsB;AAAA,OAEhB;AAEP,cAAc;AACd,YAAY,qCAAqC;AACjD,cAAc;AACd,cAAc;AACd,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";AACA;AAAA,EACC,sBAAsB;AAAA,OAEhB;AAEP,cAAc;AACd,YAAY,qCAAqC;AACjD,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACuB;AAAA,OAEhB;AAEP,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAmC3B,IAAM,0BAA0B;AAAA,EACtC;AACD;AAoBO,IAAM,UAAkB","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '6.0.4-next.7909d16.0';\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -372,6 +372,8 @@ declare module '@sapphire/framework' {
|
|
|
372
372
|
/**
|
|
373
373
|
* The preconditions specific to subcommands
|
|
374
374
|
* @since 5.1.0
|
|
375
|
+
* @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}
|
|
376
|
+
* in the next major version as opposed to a namespaced export.
|
|
375
377
|
*/
|
|
376
378
|
declare const SubcommandPreconditions: {
|
|
377
379
|
PluginSubcommandCooldown: typeof PluginPrecondition;
|
|
@@ -379,6 +381,8 @@ declare const SubcommandPreconditions: {
|
|
|
379
381
|
/**
|
|
380
382
|
* The preconditions specific to subcommands
|
|
381
383
|
* @since 5.1.0
|
|
384
|
+
* @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}
|
|
385
|
+
* in the next major version as opposed to a namespaced export.
|
|
382
386
|
*/
|
|
383
387
|
declare namespace SubcommandPreconditions {
|
|
384
388
|
/** The context for the subcommand cooldown precondition */
|
|
@@ -392,4 +396,4 @@ declare namespace SubcommandPreconditions {
|
|
|
392
396
|
*/
|
|
393
397
|
declare const version: string;
|
|
394
398
|
|
|
395
|
-
export { type ChatInputCommandSubcommandMappingMethod, type ChatInputSubcommandAcceptedPayload, type ChatInputSubcommandDeniedPayload, type ChatInputSubcommandErrorPayload, type ChatInputSubcommandRunPayload, type ChatInputSubcommandSuccessPayload, type IChatInputSubcommandPayload, type IMessageSubcommandPayload, type MessageSubcommandAcceptedPayload, type MessageSubcommandDeniedPayload, type MessageSubcommandErrorPayload, type MessageSubcommandMappingMethod, type MessageSubcommandNoMatchContext, type MessageSubcommandRunPayload, type MessageSubcommandSuccessPayload, Subcommand, SubcommandCommandPreConditions, SubcommandIdentifiers, type SubcommandMapping, type SubcommandMappingArray, type SubcommandMappingGroup, type SubcommandMappingMethod, type SubcommandOptions, SubcommandPluginEvents, SubcommandPluginIdentifiers, subcommandCooldown as SubcommandPreconditionResolvers, SubcommandPreconditions, loadListeners, loadPreconditions, version };
|
|
399
|
+
export { type ChatInputCommandSubcommandMappingMethod, type ChatInputSubcommandAcceptedPayload, type ChatInputSubcommandDeniedPayload, type ChatInputSubcommandErrorPayload, type ChatInputSubcommandRunPayload, type ChatInputSubcommandSuccessPayload, type IChatInputSubcommandPayload, type IMessageSubcommandPayload, type MessageSubcommandAcceptedPayload, type MessageSubcommandDeniedPayload, type MessageSubcommandErrorPayload, type MessageSubcommandMappingMethod, type MessageSubcommandNoMatchContext, type MessageSubcommandRunPayload, type MessageSubcommandSuccessPayload, PluginPrecondition as PluginSubcommandCooldownPrecondition, type PluginSubcommandCooldownPreconditionContext, Subcommand, SubcommandCommandPreConditions, SubcommandIdentifiers, type SubcommandMapping, type SubcommandMappingArray, type SubcommandMappingGroup, type SubcommandMappingMethod, type SubcommandOptions, SubcommandPluginEvents, SubcommandPluginIdentifiers, subcommandCooldown as SubcommandPreconditionResolvers, SubcommandPreconditions, loadListeners, loadPreconditions, version };
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
4
|
var utilities = require('@sapphire/utilities');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var index_mjs = require('../index.mjs');
|
|
6
|
+
var Events_mjs = require('./types/Events.mjs');
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -119,7 +119,7 @@ var _Subcommand = class _Subcommand extends framework.Command {
|
|
|
119
119
|
subcommand.requiredUserPermissions,
|
|
120
120
|
preconditionContainerArray
|
|
121
121
|
);
|
|
122
|
-
|
|
122
|
+
index_mjs.SubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({
|
|
123
123
|
subcommand: this,
|
|
124
124
|
cooldownDelay: subcommand.cooldownDelay,
|
|
125
125
|
cooldownFilteredUsers: subcommand.cooldownFilteredUsers,
|
|
@@ -147,7 +147,7 @@ var _Subcommand = class _Subcommand extends framework.Command {
|
|
|
147
147
|
groupedSubcommand.requiredUserPermissions,
|
|
148
148
|
preconditionContainerArray
|
|
149
149
|
);
|
|
150
|
-
|
|
150
|
+
index_mjs.SubcommandPreconditionResolvers.parseSubcommandConstructorPreConditionsCooldown({
|
|
151
151
|
subcommand: this,
|
|
152
152
|
cooldownDelay: groupedSubcommand.cooldownDelay,
|
|
153
153
|
cooldownFilteredUsers: groupedSubcommand.cooldownFilteredUsers,
|
|
@@ -245,7 +245,7 @@ var _Subcommand = class _Subcommand extends framework.Command {
|
|
|
245
245
|
return __privateMethod(this, _handleMessageRun, handleMessageRun_fn).call(this, message, args, context, defaultCommand, subcommandGroupName);
|
|
246
246
|
}
|
|
247
247
|
throw new framework.UserError({
|
|
248
|
-
identifier:
|
|
248
|
+
identifier: Events_mjs.SubcommandPluginIdentifiers.MessageSubcommandNoMatch,
|
|
249
249
|
message: "No subcommand was matched with the provided arguments.",
|
|
250
250
|
context: {
|
|
251
251
|
...context,
|
|
@@ -280,7 +280,7 @@ var _Subcommand = class _Subcommand extends framework.Command {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
throw new framework.UserError({
|
|
283
|
-
identifier:
|
|
283
|
+
identifier: Events_mjs.SubcommandPluginIdentifiers.ChatInputSubcommandNoMatch,
|
|
284
284
|
message: "No subcommand was matched with the provided command.",
|
|
285
285
|
context
|
|
286
286
|
});
|
|
@@ -313,20 +313,20 @@ handleMessageRun_fn = /* @__PURE__ */ __name(async function(message, args, conte
|
|
|
313
313
|
const preconditionPayload = { ...messageParametersAsString, ...payload };
|
|
314
314
|
const localSubcommandResult = await preconditionsForSubcommand.messageRun(message, this, preconditionPayload);
|
|
315
315
|
if (localSubcommandResult.isErr()) {
|
|
316
|
-
this.container.client.emit(
|
|
316
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.MessageSubcommandDenied, localSubcommandResult.unwrapErr(), preconditionPayload);
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
const result = await framework.Result.fromAsync(async () => {
|
|
321
321
|
if (subcommand.messageRun) {
|
|
322
322
|
const casted = subcommand;
|
|
323
|
-
this.container.client.emit(
|
|
323
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.MessageSubcommandRun, message, casted, payload);
|
|
324
324
|
let result2;
|
|
325
325
|
if (typeof subcommand.messageRun === "string") {
|
|
326
326
|
const method = Reflect.get(this, subcommand.messageRun);
|
|
327
327
|
if (!method) {
|
|
328
328
|
throw new framework.UserError({
|
|
329
|
-
identifier:
|
|
329
|
+
identifier: Events_mjs.SubcommandPluginIdentifiers.SubcommandNotFound,
|
|
330
330
|
message: `The method configured at "messageRun" for the subcommand ${subcommand.name} was not implemented in the class.`,
|
|
331
331
|
context: { ...payload }
|
|
332
332
|
});
|
|
@@ -335,12 +335,12 @@ handleMessageRun_fn = /* @__PURE__ */ __name(async function(message, args, conte
|
|
|
335
335
|
} else {
|
|
336
336
|
result2 = await subcommand.messageRun(message, args, context);
|
|
337
337
|
}
|
|
338
|
-
this.container.client.emit(
|
|
338
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.MessageSubcommandSuccess, message, casted, { ...payload, result: result2 });
|
|
339
339
|
} else {
|
|
340
|
-
this.container.client.emit(
|
|
340
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler, message, subcommand, payload);
|
|
341
341
|
}
|
|
342
342
|
});
|
|
343
|
-
result.inspectErr((error) => this.container.client.emit(
|
|
343
|
+
result.inspectErr((error) => this.container.client.emit(Events_mjs.SubcommandPluginEvents.MessageSubcommandError, error, payload));
|
|
344
344
|
}, "#handleMessageRun");
|
|
345
345
|
_handleChatInputInteractionRun = new WeakSet();
|
|
346
346
|
handleChatInputInteractionRun_fn = /* @__PURE__ */ __name(async function(interaction, context, subcommand, subcommandGroupName) {
|
|
@@ -356,20 +356,20 @@ handleChatInputInteractionRun_fn = /* @__PURE__ */ __name(async function(interac
|
|
|
356
356
|
if (preconditionsForSubcommand) {
|
|
357
357
|
const localSubcommandResult = await preconditionsForSubcommand.chatInputRun(interaction, this, payload);
|
|
358
358
|
if (localSubcommandResult.isErr()) {
|
|
359
|
-
this.container.client.emit(
|
|
359
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.ChatInputSubcommandDenied, localSubcommandResult.unwrapErr(), payload);
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
const result = await framework.Result.fromAsync(async () => {
|
|
364
364
|
if (subcommand.chatInputRun) {
|
|
365
365
|
const casted = subcommand;
|
|
366
|
-
this.container.client.emit(
|
|
366
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.ChatInputSubcommandRun, interaction, casted, payload);
|
|
367
367
|
let result2;
|
|
368
368
|
if (typeof subcommand.chatInputRun === "string") {
|
|
369
369
|
const method = Reflect.get(this, subcommand.chatInputRun);
|
|
370
370
|
if (!method) {
|
|
371
371
|
throw new framework.UserError({
|
|
372
|
-
identifier:
|
|
372
|
+
identifier: Events_mjs.SubcommandPluginIdentifiers.SubcommandNotFound,
|
|
373
373
|
message: `The method configured at "chatInputRun" for the subcommand ${subcommand.name} was not implemented in the class.`,
|
|
374
374
|
context: { ...payload }
|
|
375
375
|
});
|
|
@@ -378,17 +378,17 @@ handleChatInputInteractionRun_fn = /* @__PURE__ */ __name(async function(interac
|
|
|
378
378
|
} else {
|
|
379
379
|
result2 = await subcommand.chatInputRun(interaction, context);
|
|
380
380
|
}
|
|
381
|
-
this.container.client.emit(
|
|
381
|
+
this.container.client.emit(Events_mjs.SubcommandPluginEvents.ChatInputSubcommandSuccess, interaction, casted, { ...payload, result: result2 });
|
|
382
382
|
} else {
|
|
383
383
|
this.container.client.emit(
|
|
384
|
-
|
|
384
|
+
Events_mjs.SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler,
|
|
385
385
|
interaction,
|
|
386
386
|
subcommand,
|
|
387
387
|
payload
|
|
388
388
|
);
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
|
-
result.inspectErr((error) => this.container.client.emit(
|
|
391
|
+
result.inspectErr((error) => this.container.client.emit(Events_mjs.SubcommandPluginEvents.ChatInputSubcommandError, error, payload));
|
|
392
392
|
}, "#handleChatInputInteractionRun");
|
|
393
393
|
_findSubcommand = new WeakSet();
|
|
394
394
|
findSubcommand_fn = /* @__PURE__ */ __name(function(mappings, expectedName) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
4
|
var pieces = require('@sapphire/pieces');
|
|
5
|
-
require('../Subcommand.
|
|
6
|
-
var
|
|
5
|
+
require('../Subcommand.mjs');
|
|
6
|
+
var Enums_mjs = require('../types/Enums.mjs');
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -27,7 +27,7 @@ function parseSubcommandConstructorPreConditionsCooldown({
|
|
|
27
27
|
const scope = cooldownScope ?? subcommandDefaultCooldown?.scope ?? framework.BucketScope.User;
|
|
28
28
|
const filteredUsers = cooldownFilteredUsers ?? subcommandDefaultCooldown?.filteredUsers;
|
|
29
29
|
preconditionContainerArray.append({
|
|
30
|
-
name:
|
|
30
|
+
name: Enums_mjs.SubcommandCommandPreConditions.PluginSubcommandCooldown,
|
|
31
31
|
context: { scope, limit, delay, filteredUsers, subcommandGroupName, subcommandMethodName }
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
|
-
var
|
|
4
|
+
var Events_mjs = require('../lib/types/Events.mjs');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var _PluginListener = class _PluginListener extends framework.Listener {
|
|
9
9
|
constructor(context) {
|
|
10
|
-
super(context, { event:
|
|
10
|
+
super(context, { event: Events_mjs.SubcommandPluginEvents.ChatInputSubcommandError });
|
|
11
11
|
}
|
|
12
12
|
run(error, context) {
|
|
13
13
|
const { name, location } = context.command;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
|
-
var
|
|
4
|
+
var Events_mjs = require('../lib/types/Events.mjs');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var _PluginListener = class _PluginListener extends framework.Listener {
|
|
9
9
|
constructor(context) {
|
|
10
|
-
super(context, { event:
|
|
10
|
+
super(context, { event: Events_mjs.SubcommandPluginEvents.MessageSubcommandError });
|
|
11
11
|
}
|
|
12
12
|
run(error, context) {
|
|
13
13
|
const { name, location } = context.command;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
|
-
var
|
|
4
|
+
var Events_mjs = require('../lib/types/Events.mjs');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var _PluginListener = class _PluginListener extends framework.Listener {
|
|
9
9
|
constructor(context) {
|
|
10
|
-
super(context, { event:
|
|
10
|
+
super(context, { event: Events_mjs.SubcommandPluginEvents.SubcommandMappingIsMissingChatInputCommandHandler });
|
|
11
11
|
}
|
|
12
12
|
run(_, subcommand, context) {
|
|
13
13
|
const { name, location } = context.command;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
|
-
var
|
|
4
|
+
var Events_mjs = require('../lib/types/Events.mjs');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var _PluginListener = class _PluginListener extends framework.Listener {
|
|
9
9
|
constructor(context) {
|
|
10
|
-
super(context, { event:
|
|
10
|
+
super(context, { event: Events_mjs.SubcommandPluginEvents.SubcommandMappingIsMissingMessageCommandHandler });
|
|
11
11
|
}
|
|
12
12
|
run(_, subcommand, context) {
|
|
13
13
|
const { name, location } = context.command;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pieces = require('@sapphire/pieces');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
4
|
+
var PluginChatInputSubcommandError_mjs = require('./PluginChatInputSubcommandError.mjs');
|
|
5
|
+
var PluginMessageSubcommandError_mjs = require('./PluginMessageSubcommandError.mjs');
|
|
6
|
+
var PluginSubcommandMappingIsMissingChatInputCommandHandler_mjs = require('./PluginSubcommandMappingIsMissingChatInputCommandHandler.mjs');
|
|
7
|
+
var PluginSubcommandMappingIsMissingMessageCommandHandler_mjs = require('./PluginSubcommandMappingIsMissingMessageCommandHandler.mjs');
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
11
|
function loadListeners() {
|
|
12
12
|
const store = "listeners";
|
|
13
|
-
void pieces.container.stores.loadPiece({ name: "PluginChatInputSubcommandError", piece:
|
|
14
|
-
void pieces.container.stores.loadPiece({ name: "PluginMessageSubcommandError", piece:
|
|
13
|
+
void pieces.container.stores.loadPiece({ name: "PluginChatInputSubcommandError", piece: PluginChatInputSubcommandError_mjs.PluginListener, store });
|
|
14
|
+
void pieces.container.stores.loadPiece({ name: "PluginMessageSubcommandError", piece: PluginMessageSubcommandError_mjs.PluginListener, store });
|
|
15
15
|
void pieces.container.stores.loadPiece({
|
|
16
16
|
name: "PluginSubcommandMappingIsMissingChatInputCommandHandler",
|
|
17
|
-
piece:
|
|
17
|
+
piece: PluginSubcommandMappingIsMissingChatInputCommandHandler_mjs.PluginListener,
|
|
18
18
|
store
|
|
19
19
|
});
|
|
20
20
|
void pieces.container.stores.loadPiece({
|
|
21
21
|
name: "PluginSubcommandMappingIsMissingMessageCommandHandler",
|
|
22
|
-
piece:
|
|
22
|
+
piece: PluginSubcommandMappingIsMissingMessageCommandHandler_mjs.PluginListener,
|
|
23
23
|
store
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var framework = require('@sapphire/framework');
|
|
4
4
|
var ratelimits = require('@sapphire/ratelimits');
|
|
5
5
|
var discord_js = require('discord.js');
|
|
6
|
-
require('../lib/Subcommand.
|
|
7
|
-
var
|
|
6
|
+
require('../lib/Subcommand.mjs');
|
|
7
|
+
var Enums_mjs = require('../lib/types/Enums.mjs');
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -42,7 +42,7 @@ var _PluginPrecondition = class _PluginPrecondition extends framework.AllFlowsPr
|
|
|
42
42
|
const remaining = rateLimit.remainingTime;
|
|
43
43
|
const nextAvailable = discord_js.time(Math.floor(rateLimit.expires / 1e3), discord_js.TimestampStyles.RelativeTime);
|
|
44
44
|
return this.error({
|
|
45
|
-
identifier:
|
|
45
|
+
identifier: Enums_mjs.SubcommandIdentifiers.SubcommandPreconditionCooldown,
|
|
46
46
|
message: `There is a cooldown in effect for this ${commandType} subcommand. It'll be available ${nextAvailable}.`,
|
|
47
47
|
context: { remaining }
|
|
48
48
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pieces = require('@sapphire/pieces');
|
|
4
|
-
var
|
|
4
|
+
var PluginSubcommandCooldown_mjs = require('./PluginSubcommandCooldown.mjs');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
function loadPreconditions() {
|
|
9
9
|
const store = "preconditions";
|
|
10
|
-
void pieces.container.stores.loadPiece({ name: "PluginSubcommandCooldown", piece:
|
|
10
|
+
void pieces.container.stores.loadPiece({ name: "PluginSubcommandCooldown", piece: PluginSubcommandCooldown_mjs.PluginPrecondition, store });
|
|
11
11
|
}
|
|
12
12
|
__name(loadPreconditions, "loadPreconditions");
|
|
13
13
|
|
package/dist/cjs/register.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var index_mjs = require('./index.mjs');
|
|
4
4
|
var framework = require('@sapphire/framework');
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
@@ -10,9 +10,9 @@ var _SubcommandsPlugin = class _SubcommandsPlugin extends framework.Plugin {
|
|
|
10
10
|
* @since 3.1.2
|
|
11
11
|
*/
|
|
12
12
|
static [framework.postInitialization](options) {
|
|
13
|
-
|
|
13
|
+
index_mjs.loadPreconditions();
|
|
14
14
|
if (options.loadSubcommandErrorListeners !== false) {
|
|
15
|
-
|
|
15
|
+
index_mjs.loadListeners();
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -372,6 +372,8 @@ declare module '@sapphire/framework' {
|
|
|
372
372
|
/**
|
|
373
373
|
* The preconditions specific to subcommands
|
|
374
374
|
* @since 5.1.0
|
|
375
|
+
* @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}
|
|
376
|
+
* in the next major version as opposed to a namespaced export.
|
|
375
377
|
*/
|
|
376
378
|
declare const SubcommandPreconditions: {
|
|
377
379
|
PluginSubcommandCooldown: typeof PluginPrecondition;
|
|
@@ -379,6 +381,8 @@ declare const SubcommandPreconditions: {
|
|
|
379
381
|
/**
|
|
380
382
|
* The preconditions specific to subcommands
|
|
381
383
|
* @since 5.1.0
|
|
384
|
+
* @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}
|
|
385
|
+
* in the next major version as opposed to a namespaced export.
|
|
382
386
|
*/
|
|
383
387
|
declare namespace SubcommandPreconditions {
|
|
384
388
|
/** The context for the subcommand cooldown precondition */
|
|
@@ -392,4 +396,4 @@ declare namespace SubcommandPreconditions {
|
|
|
392
396
|
*/
|
|
393
397
|
declare const version: string;
|
|
394
398
|
|
|
395
|
-
export { type ChatInputCommandSubcommandMappingMethod, type ChatInputSubcommandAcceptedPayload, type ChatInputSubcommandDeniedPayload, type ChatInputSubcommandErrorPayload, type ChatInputSubcommandRunPayload, type ChatInputSubcommandSuccessPayload, type IChatInputSubcommandPayload, type IMessageSubcommandPayload, type MessageSubcommandAcceptedPayload, type MessageSubcommandDeniedPayload, type MessageSubcommandErrorPayload, type MessageSubcommandMappingMethod, type MessageSubcommandNoMatchContext, type MessageSubcommandRunPayload, type MessageSubcommandSuccessPayload, Subcommand, SubcommandCommandPreConditions, SubcommandIdentifiers, type SubcommandMapping, type SubcommandMappingArray, type SubcommandMappingGroup, type SubcommandMappingMethod, type SubcommandOptions, SubcommandPluginEvents, SubcommandPluginIdentifiers, subcommandCooldown as SubcommandPreconditionResolvers, SubcommandPreconditions, loadListeners, loadPreconditions, version };
|
|
399
|
+
export { type ChatInputCommandSubcommandMappingMethod, type ChatInputSubcommandAcceptedPayload, type ChatInputSubcommandDeniedPayload, type ChatInputSubcommandErrorPayload, type ChatInputSubcommandRunPayload, type ChatInputSubcommandSuccessPayload, type IChatInputSubcommandPayload, type IMessageSubcommandPayload, type MessageSubcommandAcceptedPayload, type MessageSubcommandDeniedPayload, type MessageSubcommandErrorPayload, type MessageSubcommandMappingMethod, type MessageSubcommandNoMatchContext, type MessageSubcommandRunPayload, type MessageSubcommandSuccessPayload, PluginPrecondition as PluginSubcommandCooldownPrecondition, type PluginSubcommandCooldownPreconditionContext, Subcommand, SubcommandCommandPreConditions, SubcommandIdentifiers, type SubcommandMapping, type SubcommandMappingArray, type SubcommandMappingGroup, type SubcommandMappingMethod, type SubcommandOptions, SubcommandPluginEvents, SubcommandPluginIdentifiers, subcommandCooldown as SubcommandPreconditionResolvers, SubcommandPreconditions, loadListeners, loadPreconditions, version };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './chunk-K3DKV2RO.mjs';
|
|
2
2
|
import { PluginPrecondition } from './preconditions/PluginSubcommandCooldown.mjs';
|
|
3
|
+
export { PluginPrecondition as PluginSubcommandCooldownPrecondition } from './preconditions/PluginSubcommandCooldown.mjs';
|
|
3
4
|
export * from './lib/Subcommand.mjs';
|
|
4
5
|
import * as subcommandCooldown_mjs from './lib/precondition-resolvers/subcommandCooldown.mjs';
|
|
5
6
|
export { subcommandCooldown_mjs as SubcommandPreconditionResolvers };
|
|
@@ -12,7 +13,7 @@ export { loadPreconditions } from './preconditions/_load.mjs';
|
|
|
12
13
|
var SubcommandPreconditions = {
|
|
13
14
|
PluginSubcommandCooldown: PluginPrecondition
|
|
14
15
|
};
|
|
15
|
-
var version = "6.0.4-next.
|
|
16
|
+
var version = "6.0.4-next.7909d16.0";
|
|
16
17
|
|
|
17
18
|
export { SubcommandPreconditions, version };
|
|
18
19
|
//# sourceMappingURL=out.js.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA;AAAA,EACC,sBAAsB;AAAA,OAEhB;AAEP,cAAc;AACd,YAAY,qCAAqC;AACjD,cAAc;AACd,cAAc;AACd,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA;AAAA,EACC,sBAAsB;AAAA,OAEhB;AAEP,cAAc;AACd,YAAY,qCAAqC;AACjD,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACuB;AAAA,OAEhB;AAEP,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAmC3B,IAAM,0BAA0B;AAAA,EACtC;AACD;AAoBO,IAAM,UAAkB","sourcesContent":["import type { CooldownOptions } from '@sapphire/framework';\nimport {\n\tPluginPrecondition as PluginSubcommandCooldown,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport * from './lib/Subcommand';\nexport * as SubcommandPreconditionResolvers from './lib/precondition-resolvers/subcommandCooldown';\nexport * from './lib/types/Enums';\nexport * from './lib/types/Events';\nexport * from './lib/types/SubcommandMappings';\nexport {\n\tPluginPrecondition as PluginSubcommandCooldownPrecondition,\n\ttype PluginSubcommandCooldownPreconditionContext\n} from './preconditions/PluginSubcommandCooldown';\n\nexport { loadListeners } from './listeners/_load';\nexport { loadPreconditions } from './preconditions/_load';\n\ndeclare module 'discord.js' {\n\tinterface ClientOptions {\n\t\t/**\n\t\t * If Plugin-subcommand to load pre-included subcommand error event listeners that log any encountered errors to the {@link SapphireClient.logger} instance\n\t\t * @since 3.1.2\n\t\t * @default true\n\t\t */\n\t\tloadSubcommandErrorListeners?: boolean;\n\t\t/**\n\t\t * Sets the default cooldown time for all subcommands.\n\t\t * @remark This is separate from {@link ClientOptions.defaultCooldown} as it is only used for subcommands\n\t\t * @remark Note that for the `filteredCommands` option you have to provide it as\n\t\t * - For a subcommand without a group: `commandName.subcommandName` (e.g. `config.show`).\n\t\t * - For a subcommand with a group: `commandName.groupName.subcommandName` (e.g. `config.set.prefix`).\n\t\t * @since 5.1.0\n\t\t * @default \"No cooldown options\"\n\t\t */\n\t\tsubcommandDefaultCooldown?: CooldownOptions;\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\tinterface Preconditions {\n\t\tPluginSubcommandCooldown: SubcommandPreconditions.PluginSubcommandCooldownContext;\n\t}\n}\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldown}\n * in the next major version as opposed to a namespaced export.\n */\nexport const SubcommandPreconditions = {\n\tPluginSubcommandCooldown\n};\n\n/**\n * The preconditions specific to subcommands\n * @since 5.1.0\n * @deprecated - This will be replaced with a regular top level export of {@link PluginSubcommandCooldownPreconditionContext}\n * in the next major version as opposed to a namespaced export.\n */\nexport namespace SubcommandPreconditions {\n\t/** The context for the subcommand cooldown precondition */\n\texport type PluginSubcommandCooldownContext = PluginSubcommandCooldownPreconditionContext;\n}\n\n/**\n * The [@sapphire/plugin-subcommands](https://github.com/sapphiredev/plugins/blob/main/packages/subcommands) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '6.0.4-next.7909d16.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-subcommands",
|
|
3
|
-
"version": "6.0.4-next.
|
|
3
|
+
"version": "6.0.4-next.7909d16.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework that adds support for subcommands.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@favware/cliff-jumper": "^3.0.
|
|
84
|
+
"@favware/cliff-jumper": "^3.0.3",
|
|
85
85
|
"@favware/rollup-type-bundler": "^3.3.0",
|
|
86
86
|
"concurrently": "^8.2.2",
|
|
87
87
|
"tsup": "^8.0.2",
|
|
88
|
-
"tsx": "^4.
|
|
89
|
-
"typedoc": "^0.25.
|
|
90
|
-
"typedoc-json-parser": "^
|
|
91
|
-
"typescript": "^5.4.
|
|
88
|
+
"tsx": "^4.10.5",
|
|
89
|
+
"typedoc": "^0.25.13",
|
|
90
|
+
"typedoc-json-parser": "^10.0.0",
|
|
91
|
+
"typescript": "^5.4.5"
|
|
92
92
|
}
|
|
93
93
|
}
|