reciple 1.6.1 → 1.6.2
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/bin/reciple/classes/Config.d.ts +1 -0
- package/bin/reciple/classes/RecipleClient.js +6 -4
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +7 -1
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +9 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +33 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +47 -6
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +12 -0
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.js +12 -0
- package/bin/reciple/classes/builders/MessageCommandOptions.d.ts +6 -0
- package/package.json +1 -1
- package/resource/reciple.yml +2 -0
|
@@ -123,17 +123,19 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
123
123
|
return this;
|
|
124
124
|
}
|
|
125
125
|
messageCommandExecute(message, prefix) {
|
|
126
|
-
var _a;
|
|
126
|
+
var _a, _b;
|
|
127
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
128
|
if (!message.content || !this.isReady())
|
|
129
129
|
return;
|
|
130
130
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
131
|
-
if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command)
|
|
131
|
+
if (!parseCommand || !(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command))
|
|
132
132
|
return;
|
|
133
|
-
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()]
|
|
133
|
+
const command = (_a = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
|
|
134
|
+
? Object.values(this.commands.MESSAGE_COMMANDS).find(c => c.aliases.some(a => { var _a; return a == ((_a = parseCommand.command) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }))
|
|
135
|
+
: undefined);
|
|
134
136
|
if (!command)
|
|
135
137
|
return;
|
|
136
|
-
if ((0, hasPermissions_1.hasPermissions)(command.name, (
|
|
138
|
+
if ((0, hasPermissions_1.hasPermissions)(command.name, (_b = message.member) === null || _b === void 0 ? void 0 : _b.permissions, this.config.permissions.messageCommands, command)) {
|
|
137
139
|
if (!command.allowExecuteInDM && message.channel.type === 'DM'
|
|
138
140
|
|| !command.allowExecuteByBots
|
|
139
141
|
&& (message.author.bot || message.author.system)
|
|
@@ -12,11 +12,17 @@ export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
|
12
12
|
requiredPermissions: (PermissionFlags | PermissionString)[];
|
|
13
13
|
allowExecuteInDM: boolean;
|
|
14
14
|
execute: (options: RecipleInteractionCommandExecute) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Set required permissions before executing the command
|
|
17
|
+
*/
|
|
15
18
|
setRequiredPermissions(requiredPermissions: (keyof PermissionFlags)[]): InteractionCommandBuilder;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Set if command can be executed in dms
|
|
18
21
|
* @deprecated use `InteractionCommandBuilder.setDMPermission()` instead
|
|
19
22
|
*/
|
|
20
23
|
setAllowExecuteInDM(allowExecuteInDM: boolean): InteractionCommandBuilder;
|
|
24
|
+
/**
|
|
25
|
+
* Function when the command is executed
|
|
26
|
+
*/
|
|
21
27
|
setExecute(execute: (options: RecipleInteractionCommandExecute) => void): InteractionCommandBuilder;
|
|
22
28
|
}
|
|
@@ -10,6 +10,9 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
|
|
|
10
10
|
this.allowExecuteInDM = true;
|
|
11
11
|
this.execute = () => { };
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Set required permissions before executing the command
|
|
15
|
+
*/
|
|
13
16
|
setRequiredPermissions(requiredPermissions) {
|
|
14
17
|
if (!requiredPermissions || !Array.isArray(requiredPermissions))
|
|
15
18
|
throw new Error('requiredPermissions must be an array.');
|
|
@@ -17,15 +20,20 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
|
|
|
17
20
|
return this;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* Set if command can be executed in dms
|
|
21
24
|
* @deprecated use `InteractionCommandBuilder.setDMPermission()` instead
|
|
22
25
|
*/
|
|
23
26
|
setAllowExecuteInDM(allowExecuteInDM) {
|
|
27
|
+
// TODO: Deprecated this
|
|
24
28
|
if (typeof allowExecuteInDM !== 'boolean')
|
|
25
29
|
throw new Error('allowExecuteInDM must be a boolean.');
|
|
26
30
|
this.allowExecuteInDM = allowExecuteInDM;
|
|
31
|
+
process.emitWarning('InteractionCommandBuilder#setAllowExecuteInDM() method is deprecated in favor of setting SlashCommandBuilder#setDMPermission()', 'Deprecation Warning');
|
|
27
32
|
return this;
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Function when the command is executed
|
|
36
|
+
*/
|
|
29
37
|
setExecute(execute) {
|
|
30
38
|
if (!execute || typeof execute !== 'function')
|
|
31
39
|
throw new Error('execute must be a function.');
|
|
@@ -22,19 +22,51 @@ export declare class MessageCommandBuilder {
|
|
|
22
22
|
readonly builder = "MESSAGE_COMMAND";
|
|
23
23
|
name: string;
|
|
24
24
|
description: string;
|
|
25
|
+
aliases: string[];
|
|
25
26
|
options: MessageCommandOptionBuilder[];
|
|
26
27
|
validateOptions: boolean;
|
|
27
28
|
requiredPermissions: (PermissionFlags | PermissionString)[];
|
|
28
29
|
allowExecuteInDM: boolean;
|
|
29
30
|
allowExecuteByBots: boolean;
|
|
30
31
|
execute: (options: RecipleMessageCommandExecute) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the command name
|
|
34
|
+
*/
|
|
31
35
|
setName(name: string): MessageCommandBuilder;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the command description
|
|
38
|
+
*/
|
|
39
|
+
setDescription(description: string): MessageCommandBuilder;
|
|
40
|
+
/**
|
|
41
|
+
* Add aliases to the command
|
|
42
|
+
*/
|
|
43
|
+
addAliases(...aliases: string[]): MessageCommandBuilder;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the default required permissions to execute this command
|
|
46
|
+
*/
|
|
32
47
|
setRequiredPermissions(permissions: (PermissionFlags | PermissionString)[]): MessageCommandBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Set if command can be executed in dms
|
|
50
|
+
*/
|
|
33
51
|
setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
|
|
52
|
+
/**
|
|
53
|
+
* Allow command to be executed by bots
|
|
54
|
+
*/
|
|
34
55
|
setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
|
|
35
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Function when the command is executed
|
|
58
|
+
*/
|
|
36
59
|
setExecute(execute: (options: RecipleMessageCommandExecute) => void): MessageCommandBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Add option to the command
|
|
62
|
+
*/
|
|
37
63
|
addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Validate options before executing
|
|
66
|
+
*/
|
|
38
67
|
setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
|
|
68
|
+
/**
|
|
69
|
+
* validate given command options
|
|
70
|
+
*/
|
|
39
71
|
getCommandOptionValues(options: CommandMessage): MessageCommandValidatedOption[];
|
|
40
72
|
}
|
|
@@ -7,6 +7,7 @@ class MessageCommandBuilder {
|
|
|
7
7
|
this.builder = 'MESSAGE_COMMAND';
|
|
8
8
|
this.name = '';
|
|
9
9
|
this.description = '';
|
|
10
|
+
this.aliases = [];
|
|
10
11
|
this.options = [];
|
|
11
12
|
this.validateOptions = false;
|
|
12
13
|
this.requiredPermissions = [];
|
|
@@ -14,42 +15,76 @@ class MessageCommandBuilder {
|
|
|
14
15
|
this.allowExecuteByBots = false;
|
|
15
16
|
this.execute = () => { };
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets the command name
|
|
20
|
+
*/
|
|
17
21
|
setName(name) {
|
|
18
22
|
if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
19
23
|
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
|
|
20
24
|
this.name = name;
|
|
21
25
|
return this;
|
|
22
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Sets the command description
|
|
29
|
+
*/
|
|
30
|
+
setDescription(description) {
|
|
31
|
+
if (!description || typeof description !== 'string')
|
|
32
|
+
throw new TypeError('description must be a string.');
|
|
33
|
+
this.description = description;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Add aliases to the command
|
|
38
|
+
*/
|
|
39
|
+
addAliases(...aliases) {
|
|
40
|
+
if (!aliases.length)
|
|
41
|
+
throw new TypeError('Provide atleast one alias');
|
|
42
|
+
if (aliases.some(a => !a || typeof a !== 'string' || !a.match(/^[\w-]{1,32}$/)))
|
|
43
|
+
throw new TypeError('aliases must be strings and match the regex /^[\\w-]{1,32}$/');
|
|
44
|
+
if (this.name && aliases.some(a => a == this.name))
|
|
45
|
+
throw new TypeError('alias cannot have same name to its real command name');
|
|
46
|
+
this.aliases = [...new Set(aliases)];
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the default required permissions to execute this command
|
|
51
|
+
*/
|
|
23
52
|
setRequiredPermissions(permissions) {
|
|
24
53
|
if (!permissions || !Array.isArray(permissions))
|
|
25
54
|
throw new TypeError('permissions must be an array.');
|
|
26
55
|
this.requiredPermissions = permissions;
|
|
27
56
|
return this;
|
|
28
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Set if command can be executed in dms
|
|
60
|
+
*/
|
|
29
61
|
setAllowExecuteInDM(allowExecuteInDM) {
|
|
30
62
|
if (typeof allowExecuteInDM !== 'boolean')
|
|
31
63
|
throw new TypeError('allowExecuteInDM must be a boolean.');
|
|
32
64
|
this.allowExecuteInDM = allowExecuteInDM;
|
|
33
65
|
return this;
|
|
34
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Allow command to be executed by bots
|
|
69
|
+
*/
|
|
35
70
|
setAllowExecuteByBots(allowExecuteByBots) {
|
|
36
71
|
if (typeof allowExecuteByBots !== 'boolean')
|
|
37
72
|
throw new TypeError('allowExecuteByBots must be a boolean.');
|
|
38
73
|
this.allowExecuteByBots = allowExecuteByBots;
|
|
39
74
|
return this;
|
|
40
75
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.description = description;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
76
|
+
/**
|
|
77
|
+
* Function when the command is executed
|
|
78
|
+
*/
|
|
47
79
|
setExecute(execute) {
|
|
48
80
|
if (!execute || typeof execute !== 'function')
|
|
49
81
|
throw new TypeError('execute must be a function.');
|
|
50
82
|
this.execute = execute;
|
|
51
83
|
return this;
|
|
52
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Add option to the command
|
|
87
|
+
*/
|
|
53
88
|
addOption(option) {
|
|
54
89
|
if (!option)
|
|
55
90
|
throw new TypeError('option must be a MessageOption.');
|
|
@@ -61,12 +96,18 @@ class MessageCommandBuilder {
|
|
|
61
96
|
this.options = [...this.options, option];
|
|
62
97
|
return this;
|
|
63
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Validate options before executing
|
|
101
|
+
*/
|
|
64
102
|
setValidateOptions(validateOptions) {
|
|
65
103
|
if (typeof validateOptions !== 'boolean')
|
|
66
104
|
throw new TypeError('validateOptions must be a boolean.');
|
|
67
105
|
this.validateOptions = validateOptions;
|
|
68
106
|
return this;
|
|
69
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* validate given command options
|
|
110
|
+
*/
|
|
70
111
|
getCommandOptionValues(options) {
|
|
71
112
|
const args = options.args || [];
|
|
72
113
|
const required = this.options.filter(o => o.required);
|
|
@@ -3,8 +3,20 @@ export declare class MessageCommandOptionBuilder {
|
|
|
3
3
|
description: string;
|
|
4
4
|
required: boolean;
|
|
5
5
|
validator: (value: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Set command option name
|
|
8
|
+
*/
|
|
6
9
|
setName(name: string): MessageCommandOptionBuilder;
|
|
10
|
+
/**
|
|
11
|
+
* Set command option description
|
|
12
|
+
*/
|
|
7
13
|
setDescription(description: string): MessageCommandOptionBuilder;
|
|
14
|
+
/**
|
|
15
|
+
* Set if this option is required
|
|
16
|
+
*/
|
|
8
17
|
setRequired(required: boolean): MessageCommandOptionBuilder;
|
|
18
|
+
/**
|
|
19
|
+
* Set your custom function to validate given value for this option
|
|
20
|
+
*/
|
|
9
21
|
setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
|
|
10
22
|
}
|
|
@@ -8,24 +8,36 @@ class MessageCommandOptionBuilder {
|
|
|
8
8
|
this.required = false;
|
|
9
9
|
this.validator = () => true;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Set command option name
|
|
13
|
+
*/
|
|
11
14
|
setName(name) {
|
|
12
15
|
if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
13
16
|
throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
|
|
14
17
|
this.name = name;
|
|
15
18
|
return this;
|
|
16
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Set command option description
|
|
22
|
+
*/
|
|
17
23
|
setDescription(description) {
|
|
18
24
|
if (!description || typeof description !== 'string')
|
|
19
25
|
throw new TypeError('description must be a string.');
|
|
20
26
|
this.description = description;
|
|
21
27
|
return this;
|
|
22
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Set if this option is required
|
|
31
|
+
*/
|
|
23
32
|
setRequired(required) {
|
|
24
33
|
if (typeof required !== 'boolean')
|
|
25
34
|
throw new TypeError('required must be a boolean.');
|
|
26
35
|
this.required = required;
|
|
27
36
|
return this;
|
|
28
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Set your custom function to validate given value for this option
|
|
40
|
+
*/
|
|
29
41
|
setValidator(validator) {
|
|
30
42
|
if (!validator || typeof validator !== 'function')
|
|
31
43
|
throw new TypeError('validator must be a function.');
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MessageCommandValidatedOption } from './MessageCommandBuilder';
|
|
2
2
|
export declare class MessageCommandOptions extends Array<MessageCommandValidatedOption> {
|
|
3
3
|
constructor(options: MessageCommandValidatedOption[]);
|
|
4
|
+
/**
|
|
5
|
+
* Get the option info
|
|
6
|
+
*/
|
|
4
7
|
get(name: string, requied: true): MessageCommandValidatedOption;
|
|
5
8
|
get(name: string, requied?: boolean): MessageCommandValidatedOption | null;
|
|
9
|
+
/**
|
|
10
|
+
* Get the option value
|
|
11
|
+
*/
|
|
6
12
|
getValue(name: string, requied: true): string;
|
|
7
13
|
getValue(name: string, requied?: boolean): string | null;
|
|
8
14
|
}
|
package/package.json
CHANGED
package/resource/reciple.yml
CHANGED