reciple 6.0.0-dev.23 → 6.0.0-dev.25
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/LICENSE +674 -674
- package/README.md +183 -183
- package/dist/lib/bin.mjs +66 -65
- package/dist/lib/esm.mjs +1 -1
- package/dist/lib/index.js +33 -35
- package/dist/lib/reciple/classes/RecipleClient.js +296 -296
- package/dist/lib/reciple/classes/RecipleConfig.js +106 -106
- package/dist/lib/reciple/classes/RecipleModule.js +94 -94
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +309 -325
- package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +126 -107
- package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +246 -246
- package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +178 -178
- package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +99 -100
- package/dist/lib/reciple/classes/managers/CommandManager.js +59 -59
- package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
- package/dist/lib/reciple/classes/managers/ModuleManager.js +176 -179
- package/dist/lib/reciple/flags.js +31 -31
- package/dist/lib/reciple/permissions.js +30 -30
- package/dist/lib/reciple/types/builders.js +11 -11
- package/dist/lib/reciple/types/commands.js +15 -15
- package/dist/lib/reciple/types/paramOptions.js +2 -2
- package/dist/lib/reciple/util.js +69 -68
- package/dist/lib/reciple/version.js +47 -47
- package/dist/types/bin.d.mts +2 -2
- package/dist/types/esm.d.mts +1 -1
- package/dist/types/index.d.ts +17 -19
- package/dist/types/reciple/classes/RecipleClient.d.ts +104 -103
- package/dist/types/reciple/classes/RecipleConfig.d.ts +100 -100
- package/dist/types/reciple/classes/RecipleModule.d.ts +56 -56
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +189 -184
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +53 -51
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +98 -98
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +53 -53
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +70 -70
- package/dist/types/reciple/classes/managers/CommandManager.d.ts +34 -36
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +22 -22
- package/dist/types/reciple/classes/managers/ModuleManager.d.ts +49 -49
- package/dist/types/reciple/flags.d.ts +17 -17
- package/dist/types/reciple/permissions.d.ts +15 -19
- package/dist/types/reciple/types/builders.d.ts +205 -197
- package/dist/types/reciple/types/commands.d.ts +81 -81
- package/dist/types/reciple/types/paramOptions.d.ts +101 -101
- package/dist/types/reciple/util.d.ts +26 -23
- package/dist/types/reciple/version.d.ts +25 -25
- package/package.json +21 -20
- package/resource/reciple.yml +120 -120
|
@@ -1,107 +1,126 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageCommandOptionBuilder = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
/**
|
|
6
|
-
* Option builder for MessageCommandBuilder
|
|
7
|
-
*/
|
|
8
|
-
class MessageCommandOptionBuilder {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
this._name = '';
|
|
11
|
-
this._description = '';
|
|
12
|
-
this._required = false;
|
|
13
|
-
if (data?.name !== undefined)
|
|
14
|
-
this.setName(data.name);
|
|
15
|
-
if (data?.description !== undefined)
|
|
16
|
-
this.setDescription(data.description);
|
|
17
|
-
if (data?.required !== undefined)
|
|
18
|
-
this.setRequired(data.required);
|
|
19
|
-
if (data?.validator !== undefined)
|
|
20
|
-
this.setValidator(data.validator);
|
|
21
|
-
}
|
|
22
|
-
get name() {
|
|
23
|
-
return this._name;
|
|
24
|
-
}
|
|
25
|
-
get description() {
|
|
26
|
-
return this._description;
|
|
27
|
-
}
|
|
28
|
-
get required() {
|
|
29
|
-
return this._required;
|
|
30
|
-
}
|
|
31
|
-
get validator() {
|
|
32
|
-
return this._validator;
|
|
33
|
-
}
|
|
34
|
-
set name(name) {
|
|
35
|
-
this.setName(name);
|
|
36
|
-
}
|
|
37
|
-
set description(description) {
|
|
38
|
-
this.setDescription(description);
|
|
39
|
-
}
|
|
40
|
-
set required(required) {
|
|
41
|
-
this.setRequired(required);
|
|
42
|
-
}
|
|
43
|
-
set validator(validator) {
|
|
44
|
-
this.setValidator(validator);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Set command option name
|
|
48
|
-
* @param name Option name
|
|
49
|
-
*/
|
|
50
|
-
setName(name) {
|
|
51
|
-
if ((0, discord_js_1.isValidationEnabled)() && (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
|
|
52
|
-
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
|
|
53
|
-
this._name = name;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Set command option description
|
|
58
|
-
* @param description Option description
|
|
59
|
-
*/
|
|
60
|
-
setDescription(description) {
|
|
61
|
-
if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
|
|
62
|
-
throw new TypeError('description must be a string.');
|
|
63
|
-
this._description = description;
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Set if this option is required
|
|
68
|
-
* @param required `true` if this option is required
|
|
69
|
-
*/
|
|
70
|
-
setRequired(required) {
|
|
71
|
-
this._required = !!required;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Set your custom function to validate given value for this option
|
|
76
|
-
* @param validator Custom function to validate value given for this option
|
|
77
|
-
*/
|
|
78
|
-
setValidator(validator) {
|
|
79
|
-
if ((0, discord_js_1.isValidationEnabled)() && validator !== undefined && typeof validator !== 'function')
|
|
80
|
-
throw new TypeError('validator must be a function.');
|
|
81
|
-
this._validator = validator;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
toJSON() {
|
|
85
|
-
return {
|
|
86
|
-
name: this.name,
|
|
87
|
-
description: this.description,
|
|
88
|
-
required: this.required,
|
|
89
|
-
validator: this.validator,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Resolves message command option data/builder
|
|
94
|
-
* @param option Option data to resolve
|
|
95
|
-
*/
|
|
96
|
-
static resolveMessageCommandOption(option) {
|
|
97
|
-
return this.isMessageCommandOption(option) ? option : new MessageCommandOptionBuilder(option);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Is a Message command option builder
|
|
101
|
-
* @param builder data to check
|
|
102
|
-
*/
|
|
103
|
-
static isMessageCommandOption(builder) {
|
|
104
|
-
return builder instanceof MessageCommandOptionBuilder;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommandOptionBuilder = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
/**
|
|
6
|
+
* Option builder for MessageCommandBuilder
|
|
7
|
+
*/
|
|
8
|
+
class MessageCommandOptionBuilder {
|
|
9
|
+
constructor(data) {
|
|
10
|
+
this._name = '';
|
|
11
|
+
this._description = '';
|
|
12
|
+
this._required = false;
|
|
13
|
+
if (data?.name !== undefined)
|
|
14
|
+
this.setName(data.name);
|
|
15
|
+
if (data?.description !== undefined)
|
|
16
|
+
this.setDescription(data.description);
|
|
17
|
+
if (data?.required !== undefined)
|
|
18
|
+
this.setRequired(data.required);
|
|
19
|
+
if (data?.validator !== undefined)
|
|
20
|
+
this.setValidator(data.validator);
|
|
21
|
+
}
|
|
22
|
+
get name() {
|
|
23
|
+
return this._name;
|
|
24
|
+
}
|
|
25
|
+
get description() {
|
|
26
|
+
return this._description;
|
|
27
|
+
}
|
|
28
|
+
get required() {
|
|
29
|
+
return this._required;
|
|
30
|
+
}
|
|
31
|
+
get validator() {
|
|
32
|
+
return this._validator;
|
|
33
|
+
}
|
|
34
|
+
set name(name) {
|
|
35
|
+
this.setName(name);
|
|
36
|
+
}
|
|
37
|
+
set description(description) {
|
|
38
|
+
this.setDescription(description);
|
|
39
|
+
}
|
|
40
|
+
set required(required) {
|
|
41
|
+
this.setRequired(required);
|
|
42
|
+
}
|
|
43
|
+
set validator(validator) {
|
|
44
|
+
this.setValidator(validator);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set command option name
|
|
48
|
+
* @param name Option name
|
|
49
|
+
*/
|
|
50
|
+
setName(name) {
|
|
51
|
+
if ((0, discord_js_1.isValidationEnabled)() && (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/)))
|
|
52
|
+
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
|
|
53
|
+
this._name = name;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Set command option description
|
|
58
|
+
* @param description Option description
|
|
59
|
+
*/
|
|
60
|
+
setDescription(description) {
|
|
61
|
+
if ((0, discord_js_1.isValidationEnabled)() && (!description || typeof description !== 'string'))
|
|
62
|
+
throw new TypeError('description must be a string.');
|
|
63
|
+
this._description = description;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set if this option is required
|
|
68
|
+
* @param required `true` if this option is required
|
|
69
|
+
*/
|
|
70
|
+
setRequired(required) {
|
|
71
|
+
this._required = !!required;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Set your custom function to validate given value for this option
|
|
76
|
+
* @param validator Custom function to validate value given for this option
|
|
77
|
+
*/
|
|
78
|
+
setValidator(validator) {
|
|
79
|
+
if ((0, discord_js_1.isValidationEnabled)() && validator !== undefined && typeof validator !== 'function')
|
|
80
|
+
throw new TypeError('validator must be a function.');
|
|
81
|
+
this._validator = validator;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
toJSON() {
|
|
85
|
+
return {
|
|
86
|
+
name: this.name,
|
|
87
|
+
description: this.description,
|
|
88
|
+
required: this.required,
|
|
89
|
+
validator: this.validator,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolves message command option data/builder
|
|
94
|
+
* @param option Option data to resolve
|
|
95
|
+
*/
|
|
96
|
+
static resolveMessageCommandOption(option) {
|
|
97
|
+
return this.isMessageCommandOption(option) ? option : new MessageCommandOptionBuilder(option);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Is a Message command option builder
|
|
101
|
+
* @param builder data to check
|
|
102
|
+
*/
|
|
103
|
+
static isMessageCommandOption(builder) {
|
|
104
|
+
return builder instanceof MessageCommandOptionBuilder;
|
|
105
|
+
}
|
|
106
|
+
static async validateOption(option, value) {
|
|
107
|
+
const validatedOption = {
|
|
108
|
+
name: option.name,
|
|
109
|
+
value,
|
|
110
|
+
required: !!option.required,
|
|
111
|
+
invalid: false,
|
|
112
|
+
missing: false,
|
|
113
|
+
};
|
|
114
|
+
if (value == undefined && option.required) {
|
|
115
|
+
validatedOption.missing = true;
|
|
116
|
+
return validatedOption;
|
|
117
|
+
}
|
|
118
|
+
if (value == undefined && !option.required)
|
|
119
|
+
return validatedOption;
|
|
120
|
+
const validate = option.validator !== undefined ? await Promise.resolve(option.validator(value ?? '')) : true;
|
|
121
|
+
if (!validate)
|
|
122
|
+
validatedOption.invalid = true;
|
|
123
|
+
return validatedOption;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
|