reciple 3.0.3 → 3.1.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/README.md +15 -5
- package/bin/index.d.ts +3 -3
- package/bin/index.js +3 -3
- package/bin/reciple/classes/CommandCooldownManager.d.ts +15 -1
- package/bin/reciple/classes/CommandCooldownManager.js +12 -1
- package/bin/reciple/classes/MessageCommandOptionManager.d.ts +10 -0
- package/bin/reciple/classes/MessageCommandOptionManager.js +6 -0
- package/bin/reciple/classes/RecipleClient.d.ts +47 -13
- package/bin/reciple/classes/RecipleClient.js +58 -16
- package/bin/reciple/classes/RecipleConfig.d.ts +14 -1
- package/bin/reciple/classes/RecipleConfig.js +8 -0
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +16 -5
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +11 -3
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +31 -7
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +58 -35
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +7 -0
- package/bin/reciple/classes/builders/MessageCommandOptionBuilder.js +7 -0
- package/bin/reciple/logger.d.ts +11 -0
- package/bin/reciple/logger.js +18 -2
- package/bin/reciple/modules.d.ts +11 -3
- package/bin/reciple/modules.js +2 -0
- package/bin/reciple/permissions.d.ts +8 -3
- package/bin/reciple/permissions.js +12 -8
- package/bin/reciple/registerInteractionCommands.d.ts +4 -3
- package/bin/reciple/registerInteractionCommands.js +7 -5
- package/bin/reciple/types/builders.d.ts +13 -4
- package/bin/reciple/types/builders.js +3 -0
- package/bin/reciple/types/commands.d.ts +19 -13
- package/bin/reciple/types/commands.js +3 -0
- package/bin/reciple/types/paramOptions.d.ts +13 -6
- package/bin/reciple/version.d.ts +6 -5
- package/bin/reciple/version.js +5 -3
- package/package.json +26 -21
- package/resource/reciple.yml +20 -17
|
@@ -3,38 +3,49 @@ import { RecipleHaltedCommandData } from '../../types/commands';
|
|
|
3
3
|
import { RecipleClient } from '../RecipleClient';
|
|
4
4
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
5
5
|
import { Awaitable, ChatInputCommandInteraction, PermissionResolvable } from 'discord.js';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Execute data for interaction command
|
|
8
|
+
*/
|
|
9
|
+
export interface InteractionCommandExecuteData {
|
|
7
10
|
interaction: ChatInputCommandInteraction;
|
|
8
11
|
builder: InteractionCommandBuilder;
|
|
9
12
|
client: RecipleClient<true>;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Reciple builder for interaction/slash command
|
|
16
|
+
*/
|
|
11
17
|
export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
12
18
|
readonly builder = RecipleCommandBuilderType.InteractionCommand;
|
|
13
19
|
cooldown: number;
|
|
14
20
|
requiredBotPermissions: PermissionResolvable[];
|
|
15
|
-
|
|
21
|
+
requiredMemberPermissions: PermissionResolvable[];
|
|
16
22
|
allowExecuteInDM: boolean;
|
|
17
23
|
halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>;
|
|
18
|
-
execute: (executeData:
|
|
24
|
+
execute: (executeData: InteractionCommandExecuteData) => Awaitable<void>;
|
|
19
25
|
/**
|
|
20
26
|
* Sets the execute cooldown for this command.
|
|
21
27
|
* - `0` means no cooldown
|
|
28
|
+
* @param cooldown Command cooldown in milliseconds
|
|
22
29
|
*/
|
|
23
30
|
setCooldown(cooldown: number): InteractionCommandBuilder;
|
|
24
31
|
/**
|
|
25
32
|
* Set required bot permissions to execute the command
|
|
33
|
+
* @param permissions Bot's required permissions
|
|
26
34
|
*/
|
|
27
35
|
setRequiredBotPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
|
|
28
36
|
/**
|
|
29
37
|
* Set required permissions to execute the command
|
|
38
|
+
* @param permissions User's return permissions
|
|
30
39
|
*/
|
|
31
40
|
setRequiredMemberPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
|
|
32
41
|
/**
|
|
33
|
-
* Function when the command is interupted
|
|
42
|
+
* Function when the command is interupted
|
|
43
|
+
* @param halt Function to execute when command is halted
|
|
34
44
|
*/
|
|
35
45
|
setHalt(halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>): InteractionCommandBuilder;
|
|
36
46
|
/**
|
|
37
47
|
* Function when the command is executed
|
|
48
|
+
* @param execute Function to execute when the command is called
|
|
38
49
|
*/
|
|
39
|
-
setExecute(execute: (executeData:
|
|
50
|
+
setExecute(execute: (executeData: InteractionCommandExecuteData) => void): InteractionCommandBuilder;
|
|
40
51
|
}
|
|
@@ -3,19 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InteractionCommandBuilder = void 0;
|
|
4
4
|
const builders_1 = require("../../types/builders");
|
|
5
5
|
const builders_2 = require("@discordjs/builders");
|
|
6
|
+
/**
|
|
7
|
+
* Reciple builder for interaction/slash command
|
|
8
|
+
*/
|
|
6
9
|
class InteractionCommandBuilder extends builders_2.SlashCommandBuilder {
|
|
7
10
|
constructor() {
|
|
8
11
|
super(...arguments);
|
|
9
12
|
this.builder = builders_1.RecipleCommandBuilderType.InteractionCommand;
|
|
10
13
|
this.cooldown = 0;
|
|
11
14
|
this.requiredBotPermissions = [];
|
|
12
|
-
this.
|
|
15
|
+
this.requiredMemberPermissions = [];
|
|
13
16
|
this.allowExecuteInDM = true;
|
|
14
17
|
this.execute = () => { };
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Sets the execute cooldown for this command.
|
|
18
21
|
* - `0` means no cooldown
|
|
22
|
+
* @param cooldown Command cooldown in milliseconds
|
|
19
23
|
*/
|
|
20
24
|
setCooldown(cooldown) {
|
|
21
25
|
this.cooldown = cooldown;
|
|
@@ -23,6 +27,7 @@ class InteractionCommandBuilder extends builders_2.SlashCommandBuilder {
|
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Set required bot permissions to execute the command
|
|
30
|
+
* @param permissions Bot's required permissions
|
|
26
31
|
*/
|
|
27
32
|
setRequiredBotPermissions(...permissions) {
|
|
28
33
|
this.requiredBotPermissions = permissions;
|
|
@@ -30,13 +35,15 @@ class InteractionCommandBuilder extends builders_2.SlashCommandBuilder {
|
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Set required permissions to execute the command
|
|
38
|
+
* @param permissions User's return permissions
|
|
33
39
|
*/
|
|
34
40
|
setRequiredMemberPermissions(...permissions) {
|
|
35
|
-
this.
|
|
41
|
+
this.requiredMemberPermissions = permissions;
|
|
36
42
|
return this;
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
|
-
* Function when the command is interupted
|
|
45
|
+
* Function when the command is interupted
|
|
46
|
+
* @param halt Function to execute when command is halted
|
|
40
47
|
*/
|
|
41
48
|
setHalt(halt) {
|
|
42
49
|
this.halt = halt ? halt : undefined;
|
|
@@ -44,6 +51,7 @@ class InteractionCommandBuilder extends builders_2.SlashCommandBuilder {
|
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
53
|
* Function when the command is executed
|
|
54
|
+
* @param execute Function to execute when the command is called
|
|
47
55
|
*/
|
|
48
56
|
setExecute(execute) {
|
|
49
57
|
if (!execute || typeof execute !== 'function')
|
|
@@ -5,13 +5,19 @@ import { RecipleClient } from '../RecipleClient';
|
|
|
5
5
|
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
6
6
|
import { Awaitable, Message, PermissionResolvable } from 'discord.js';
|
|
7
7
|
import { Command as CommandMessage } from 'fallout-utility';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Execute data for message command
|
|
10
|
+
*/
|
|
11
|
+
export interface MessageCommandExecuteData {
|
|
9
12
|
message: Message;
|
|
10
13
|
options: MessageCommandOptionManager;
|
|
11
14
|
command: CommandMessage;
|
|
12
15
|
builder: MessageCommandBuilder;
|
|
13
16
|
client: RecipleClient<true>;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Validated message command option
|
|
20
|
+
*/
|
|
15
21
|
export interface MessageCommandValidatedOption {
|
|
16
22
|
name: string;
|
|
17
23
|
value: string | undefined;
|
|
@@ -19,6 +25,9 @@ export interface MessageCommandValidatedOption {
|
|
|
19
25
|
invalid: boolean;
|
|
20
26
|
missing: boolean;
|
|
21
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Reciple builder for message command
|
|
30
|
+
*/
|
|
22
31
|
export declare class MessageCommandBuilder {
|
|
23
32
|
readonly builder = RecipleCommandBuilderType.MessageCommand;
|
|
24
33
|
name: string;
|
|
@@ -28,62 +37,77 @@ export declare class MessageCommandBuilder {
|
|
|
28
37
|
options: MessageCommandOptionBuilder[];
|
|
29
38
|
validateOptions: boolean;
|
|
30
39
|
requiredBotPermissions: PermissionResolvable[];
|
|
31
|
-
|
|
40
|
+
requiredMemberPermissions: PermissionResolvable[];
|
|
32
41
|
allowExecuteInDM: boolean;
|
|
33
42
|
allowExecuteByBots: boolean;
|
|
34
43
|
halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
|
|
35
|
-
execute: (executeData:
|
|
44
|
+
execute: (executeData: MessageCommandExecuteData) => void;
|
|
36
45
|
/**
|
|
37
46
|
* Sets the command name
|
|
47
|
+
* @param name Command name
|
|
38
48
|
*/
|
|
39
49
|
setName(name: string): MessageCommandBuilder;
|
|
40
50
|
/**
|
|
41
51
|
* Sets the command description
|
|
52
|
+
* @param description Command description
|
|
42
53
|
*/
|
|
43
54
|
setDescription(description: string): MessageCommandBuilder;
|
|
44
55
|
/**
|
|
45
56
|
* Sets the execute cooldown for this command.
|
|
46
57
|
* - `0` means no cooldown
|
|
58
|
+
* @param cooldown Command cooldown in milliseconds
|
|
47
59
|
*/
|
|
48
60
|
setCooldown(cooldown: number): MessageCommandBuilder;
|
|
49
61
|
/**
|
|
50
62
|
* Add aliases to the command
|
|
63
|
+
* @param aliases Command aliases
|
|
51
64
|
*/
|
|
52
65
|
addAliases(...aliases: string[]): MessageCommandBuilder;
|
|
53
66
|
/**
|
|
54
67
|
* Set required bot permissions to execute the command
|
|
68
|
+
* @param permissions Bot's required permissions
|
|
55
69
|
*/
|
|
56
70
|
setRequiredBotPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
|
|
57
71
|
/**
|
|
58
|
-
* Set required
|
|
72
|
+
* Set required permissions to execute the command
|
|
73
|
+
* @param permissions User's return permissions
|
|
59
74
|
*/
|
|
60
75
|
setRequiredMemberPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
|
|
61
76
|
/**
|
|
62
77
|
* Set if command can be executed in dms
|
|
78
|
+
* @param allowExecuteInDM `true` if the command can execute in DMs
|
|
63
79
|
*/
|
|
64
80
|
setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
|
|
65
81
|
/**
|
|
66
82
|
* Allow command to be executed by bots
|
|
83
|
+
* @param allowExecuteByBots `true` if the command can be executed by bots
|
|
67
84
|
*/
|
|
68
85
|
setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
|
|
69
86
|
/**
|
|
70
|
-
* Function when the command is interupted
|
|
87
|
+
* Function when the command is interupted
|
|
88
|
+
* @param halt Function to execute when command is halted
|
|
71
89
|
*/
|
|
72
90
|
setHalt(halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
|
|
73
91
|
/**
|
|
74
92
|
* Function when the command is executed
|
|
93
|
+
* @param execute Function to execute when the command is called
|
|
75
94
|
*/
|
|
76
|
-
setExecute(execute: (executeData:
|
|
95
|
+
setExecute(execute: (executeData: MessageCommandExecuteData) => void): MessageCommandBuilder;
|
|
77
96
|
/**
|
|
78
97
|
* Add option to the command
|
|
98
|
+
* @param option Message option builder
|
|
79
99
|
*/
|
|
80
100
|
addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
|
|
81
101
|
/**
|
|
82
102
|
* Validate options before executing
|
|
103
|
+
* @param validateOptions `true` if the command options needs to be validated before executing
|
|
83
104
|
*/
|
|
84
105
|
setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
|
|
85
106
|
/**
|
|
86
107
|
* validate given command options
|
|
108
|
+
* @deprecated use `validateMessageCommandOptions()` instead
|
|
109
|
+
* @param options Parsed message command data
|
|
87
110
|
*/
|
|
88
|
-
getCommandOptionValues(options: CommandMessage):
|
|
111
|
+
getCommandOptionValues(options: CommandMessage): MessageCommandOptionManager;
|
|
89
112
|
}
|
|
113
|
+
export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): MessageCommandOptionManager;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageCommandBuilder = void 0;
|
|
3
|
+
exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
|
|
4
4
|
const builders_1 = require("../../types/builders");
|
|
5
|
+
const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
|
|
5
6
|
const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
7
|
+
/**
|
|
8
|
+
* Reciple builder for message command
|
|
9
|
+
*/
|
|
6
10
|
class MessageCommandBuilder {
|
|
7
11
|
constructor() {
|
|
8
12
|
this.builder = builders_1.RecipleCommandBuilderType.MessageCommand;
|
|
@@ -13,13 +17,14 @@ class MessageCommandBuilder {
|
|
|
13
17
|
this.options = [];
|
|
14
18
|
this.validateOptions = false;
|
|
15
19
|
this.requiredBotPermissions = [];
|
|
16
|
-
this.
|
|
20
|
+
this.requiredMemberPermissions = [];
|
|
17
21
|
this.allowExecuteInDM = true;
|
|
18
22
|
this.allowExecuteByBots = false;
|
|
19
23
|
this.execute = () => { };
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Sets the command name
|
|
27
|
+
* @param name Command name
|
|
23
28
|
*/
|
|
24
29
|
setName(name) {
|
|
25
30
|
if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
@@ -29,6 +34,7 @@ class MessageCommandBuilder {
|
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Sets the command description
|
|
37
|
+
* @param description Command description
|
|
32
38
|
*/
|
|
33
39
|
setDescription(description) {
|
|
34
40
|
if (!description || typeof description !== 'string')
|
|
@@ -39,6 +45,7 @@ class MessageCommandBuilder {
|
|
|
39
45
|
/**
|
|
40
46
|
* Sets the execute cooldown for this command.
|
|
41
47
|
* - `0` means no cooldown
|
|
48
|
+
* @param cooldown Command cooldown in milliseconds
|
|
42
49
|
*/
|
|
43
50
|
setCooldown(cooldown) {
|
|
44
51
|
this.cooldown = cooldown;
|
|
@@ -46,6 +53,7 @@ class MessageCommandBuilder {
|
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
48
55
|
* Add aliases to the command
|
|
56
|
+
* @param aliases Command aliases
|
|
49
57
|
*/
|
|
50
58
|
addAliases(...aliases) {
|
|
51
59
|
if (!aliases.length)
|
|
@@ -59,20 +67,23 @@ class MessageCommandBuilder {
|
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* Set required bot permissions to execute the command
|
|
70
|
+
* @param permissions Bot's required permissions
|
|
62
71
|
*/
|
|
63
72
|
setRequiredBotPermissions(...permissions) {
|
|
64
73
|
this.requiredBotPermissions = permissions;
|
|
65
74
|
return this;
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
68
|
-
* Set required
|
|
77
|
+
* Set required permissions to execute the command
|
|
78
|
+
* @param permissions User's return permissions
|
|
69
79
|
*/
|
|
70
80
|
setRequiredMemberPermissions(...permissions) {
|
|
71
|
-
this.
|
|
81
|
+
this.requiredMemberPermissions = permissions;
|
|
72
82
|
return this;
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
75
85
|
* Set if command can be executed in dms
|
|
86
|
+
* @param allowExecuteInDM `true` if the command can execute in DMs
|
|
76
87
|
*/
|
|
77
88
|
setAllowExecuteInDM(allowExecuteInDM) {
|
|
78
89
|
if (typeof allowExecuteInDM !== 'boolean')
|
|
@@ -82,6 +93,7 @@ class MessageCommandBuilder {
|
|
|
82
93
|
}
|
|
83
94
|
/**
|
|
84
95
|
* Allow command to be executed by bots
|
|
96
|
+
* @param allowExecuteByBots `true` if the command can be executed by bots
|
|
85
97
|
*/
|
|
86
98
|
setAllowExecuteByBots(allowExecuteByBots) {
|
|
87
99
|
if (typeof allowExecuteByBots !== 'boolean')
|
|
@@ -90,7 +102,8 @@ class MessageCommandBuilder {
|
|
|
90
102
|
return this;
|
|
91
103
|
}
|
|
92
104
|
/**
|
|
93
|
-
* Function when the command is interupted
|
|
105
|
+
* Function when the command is interupted
|
|
106
|
+
* @param halt Function to execute when command is halted
|
|
94
107
|
*/
|
|
95
108
|
setHalt(halt) {
|
|
96
109
|
this.halt = halt ? halt : undefined;
|
|
@@ -98,6 +111,7 @@ class MessageCommandBuilder {
|
|
|
98
111
|
}
|
|
99
112
|
/**
|
|
100
113
|
* Function when the command is executed
|
|
114
|
+
* @param execute Function to execute when the command is called
|
|
101
115
|
*/
|
|
102
116
|
setExecute(execute) {
|
|
103
117
|
if (!execute || typeof execute !== 'function')
|
|
@@ -107,6 +121,7 @@ class MessageCommandBuilder {
|
|
|
107
121
|
}
|
|
108
122
|
/**
|
|
109
123
|
* Add option to the command
|
|
124
|
+
* @param option Message option builder
|
|
110
125
|
*/
|
|
111
126
|
addOption(option) {
|
|
112
127
|
if (!option)
|
|
@@ -121,6 +136,7 @@ class MessageCommandBuilder {
|
|
|
121
136
|
}
|
|
122
137
|
/**
|
|
123
138
|
* Validate options before executing
|
|
139
|
+
* @param validateOptions `true` if the command options needs to be validated before executing
|
|
124
140
|
*/
|
|
125
141
|
setValidateOptions(validateOptions) {
|
|
126
142
|
if (typeof validateOptions !== 'boolean')
|
|
@@ -130,39 +146,46 @@ class MessageCommandBuilder {
|
|
|
130
146
|
}
|
|
131
147
|
/**
|
|
132
148
|
* validate given command options
|
|
149
|
+
* @deprecated use `validateMessageCommandOptions()` instead
|
|
150
|
+
* @param options Parsed message command data
|
|
133
151
|
*/
|
|
152
|
+
// TODO: Remove this on the next major update
|
|
134
153
|
getCommandOptionValues(options) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const validate = option.validator ? option.validator(arg) : true;
|
|
160
|
-
if (!validate)
|
|
161
|
-
value.invalid = true;
|
|
154
|
+
return validateMessageCommandOptions(this, options);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.MessageCommandBuilder = MessageCommandBuilder;
|
|
158
|
+
function validateMessageCommandOptions(builder, options) {
|
|
159
|
+
const args = options.args || [];
|
|
160
|
+
const required = builder.options.filter(o => o.required);
|
|
161
|
+
const optional = builder.options.filter(o => !o.required);
|
|
162
|
+
const allOptions = [...required, ...optional];
|
|
163
|
+
const result = [];
|
|
164
|
+
let i = 0;
|
|
165
|
+
for (const option of allOptions) {
|
|
166
|
+
const arg = args[i];
|
|
167
|
+
const value = {
|
|
168
|
+
name: option.name,
|
|
169
|
+
value: arg !== null && arg !== void 0 ? arg : undefined,
|
|
170
|
+
required: option.required,
|
|
171
|
+
invalid: false,
|
|
172
|
+
missing: false
|
|
173
|
+
};
|
|
174
|
+
if (arg == undefined && option.required) {
|
|
175
|
+
value.missing = true;
|
|
162
176
|
result.push(value);
|
|
163
|
-
|
|
177
|
+
continue;
|
|
164
178
|
}
|
|
165
|
-
|
|
179
|
+
if (arg == undefined && !option.required) {
|
|
180
|
+
result.push(value);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const validate = option.validator ? option.validator(arg) : true;
|
|
184
|
+
if (!validate)
|
|
185
|
+
value.invalid = true;
|
|
186
|
+
result.push(value);
|
|
187
|
+
i++;
|
|
166
188
|
}
|
|
189
|
+
return new MessageCommandOptionManager_1.MessageCommandOptionManager(result);
|
|
167
190
|
}
|
|
168
|
-
exports.
|
|
191
|
+
exports.validateMessageCommandOptions = validateMessageCommandOptions;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Option builder for MessageCommandBuilder
|
|
3
|
+
*/
|
|
1
4
|
export declare class MessageCommandOptionBuilder {
|
|
2
5
|
name: string;
|
|
3
6
|
description: string;
|
|
@@ -5,18 +8,22 @@ export declare class MessageCommandOptionBuilder {
|
|
|
5
8
|
validator: (value: string) => boolean;
|
|
6
9
|
/**
|
|
7
10
|
* Set command option name
|
|
11
|
+
* @param name Option name
|
|
8
12
|
*/
|
|
9
13
|
setName(name: string): MessageCommandOptionBuilder;
|
|
10
14
|
/**
|
|
11
15
|
* Set command option description
|
|
16
|
+
* @param description Option description
|
|
12
17
|
*/
|
|
13
18
|
setDescription(description: string): MessageCommandOptionBuilder;
|
|
14
19
|
/**
|
|
15
20
|
* Set if this option is required
|
|
21
|
+
* @param required `true` if this option is required
|
|
16
22
|
*/
|
|
17
23
|
setRequired(required: boolean): MessageCommandOptionBuilder;
|
|
18
24
|
/**
|
|
19
25
|
* Set your custom function to validate given value for this option
|
|
26
|
+
* @param validator Custom function to validate value given for this option
|
|
20
27
|
*/
|
|
21
28
|
setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
|
|
22
29
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MessageCommandOptionBuilder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Option builder for MessageCommandBuilder
|
|
6
|
+
*/
|
|
4
7
|
class MessageCommandOptionBuilder {
|
|
5
8
|
constructor() {
|
|
6
9
|
this.name = '';
|
|
@@ -10,6 +13,7 @@ class MessageCommandOptionBuilder {
|
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* Set command option name
|
|
16
|
+
* @param name Option name
|
|
13
17
|
*/
|
|
14
18
|
setName(name) {
|
|
15
19
|
if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
|
|
@@ -19,6 +23,7 @@ class MessageCommandOptionBuilder {
|
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* Set command option description
|
|
26
|
+
* @param description Option description
|
|
22
27
|
*/
|
|
23
28
|
setDescription(description) {
|
|
24
29
|
if (!description || typeof description !== 'string')
|
|
@@ -28,6 +33,7 @@ class MessageCommandOptionBuilder {
|
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Set if this option is required
|
|
36
|
+
* @param required `true` if this option is required
|
|
31
37
|
*/
|
|
32
38
|
setRequired(required) {
|
|
33
39
|
if (typeof required !== 'boolean')
|
|
@@ -37,6 +43,7 @@ class MessageCommandOptionBuilder {
|
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
45
|
* Set your custom function to validate given value for this option
|
|
46
|
+
* @param validator Custom function to validate value given for this option
|
|
40
47
|
*/
|
|
41
48
|
setValidator(validator) {
|
|
42
49
|
if (!validator || typeof validator !== 'function')
|
package/bin/reciple/logger.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { Logger } from 'fallout-utility';
|
|
2
2
|
/**
|
|
3
3
|
* Create new logger
|
|
4
|
+
* @param stringifyJSON stringify json objects in console
|
|
5
|
+
* @param debugmode display debug messages
|
|
6
|
+
* @param colorizeMessage add logger colours to messages
|
|
7
|
+
*/
|
|
8
|
+
export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
|
|
9
|
+
/**
|
|
10
|
+
* Create new logger
|
|
11
|
+
* @deprecated Use `createLogger` instead
|
|
12
|
+
* @param stringifyJSON stringify json objects in console
|
|
13
|
+
* @param debugmode display debug messages
|
|
14
|
+
* @param colorizeMessage add logger colours to messages
|
|
4
15
|
*/
|
|
5
16
|
export declare function logger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
|
package/bin/reciple/logger.js
CHANGED
|
@@ -3,14 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logger = void 0;
|
|
6
|
+
exports.logger = exports.createLogger = void 0;
|
|
7
7
|
const flags_1 = require("./flags");
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const fallout_utility_1 = require("fallout-utility");
|
|
10
10
|
/**
|
|
11
11
|
* Create new logger
|
|
12
|
+
* @param stringifyJSON stringify json objects in console
|
|
13
|
+
* @param debugmode display debug messages
|
|
14
|
+
* @param colorizeMessage add logger colours to messages
|
|
12
15
|
*/
|
|
13
|
-
function
|
|
16
|
+
function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
14
17
|
var _a;
|
|
15
18
|
return new fallout_utility_1.Logger({
|
|
16
19
|
stringifyJSON: stringifyJSON,
|
|
@@ -30,4 +33,17 @@ function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
|
30
33
|
}
|
|
31
34
|
});
|
|
32
35
|
}
|
|
36
|
+
exports.createLogger = createLogger;
|
|
37
|
+
/**
|
|
38
|
+
* Create new logger
|
|
39
|
+
* @deprecated Use `createLogger` instead
|
|
40
|
+
* @param stringifyJSON stringify json objects in console
|
|
41
|
+
* @param debugmode display debug messages
|
|
42
|
+
* @param colorizeMessage add logger colours to messages
|
|
43
|
+
*/
|
|
44
|
+
// TODO: Remove this on next major release
|
|
45
|
+
function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
46
|
+
process.emitWarning('logger() is deprecated use createLogger() instead', 'DeprecationWarning');
|
|
47
|
+
return createLogger(stringifyJSON, debugmode, colorizeMessage);
|
|
48
|
+
}
|
|
33
49
|
exports.logger = logger;
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { RecipleClient } from './classes/RecipleClient';
|
|
2
|
-
import {
|
|
2
|
+
import { RecipleCommandBuilder } from './types/builders';
|
|
3
3
|
export declare type LoadedModules = {
|
|
4
|
-
commands:
|
|
4
|
+
commands: RecipleCommandBuilder[];
|
|
5
5
|
modules: RecipleModule[];
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Reciple script object interface
|
|
9
|
+
*/
|
|
7
10
|
export declare class RecipleScript {
|
|
8
11
|
versions: string | string[];
|
|
9
|
-
commands?:
|
|
12
|
+
commands?: RecipleCommandBuilder[];
|
|
10
13
|
onLoad?(reciple: RecipleClient): void | Promise<void>;
|
|
11
14
|
onStart(reciple: RecipleClient): boolean | Promise<boolean>;
|
|
12
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Reciple module object interface
|
|
18
|
+
*/
|
|
13
19
|
export interface RecipleModule {
|
|
14
20
|
script: RecipleScript;
|
|
15
21
|
info: {
|
|
@@ -20,5 +26,7 @@ export interface RecipleModule {
|
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Load modules from folder
|
|
29
|
+
* @param client Reciple client
|
|
30
|
+
* @param folder Modules folder
|
|
23
31
|
*/
|
|
24
32
|
export declare function loadModules(client: RecipleClient, folder?: string): Promise<LoadedModules>;
|
package/bin/reciple/modules.js
CHANGED
|
@@ -20,6 +20,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
20
20
|
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
21
21
|
/**
|
|
22
22
|
* Load modules from folder
|
|
23
|
+
* @param client Reciple client
|
|
24
|
+
* @param folder Modules folder
|
|
23
25
|
*/
|
|
24
26
|
function loadModules(client, folder) {
|
|
25
27
|
var _a, _b;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { Config } from './classes/RecipleConfig';
|
|
2
|
-
import {
|
|
3
|
-
import { Guild, PermissionResolvable
|
|
2
|
+
import { RecipleUserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
3
|
+
import { Guild, PermissionResolvable } from 'discord.js';
|
|
4
4
|
/**
|
|
5
5
|
* Check if the user has permissions to execute the given command name
|
|
6
|
+
* @param options options
|
|
6
7
|
*/
|
|
7
|
-
export declare function userHasCommandPermissions(
|
|
8
|
+
export declare function userHasCommandPermissions(options: RecipleUserHasCommandPermissionsOptions): boolean;
|
|
8
9
|
/**
|
|
9
10
|
* Check if the bot has the required permissions in a guild
|
|
11
|
+
* @param guild Guild
|
|
12
|
+
* @param requiredPermissions Required guild bot permissions
|
|
10
13
|
*/
|
|
11
14
|
export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
12
15
|
/**
|
|
13
16
|
* Check if the channel id is ignored in config file
|
|
17
|
+
* @param channelId Check if channel id is in ignore list
|
|
18
|
+
* @param ignoredChannelsConfig Ignored channels config
|
|
14
19
|
*/
|
|
15
20
|
export declare function isIgnoredChannel(channelId: string, ignoredChannelsConfig?: Config["ignoredChannels"]): boolean;
|
|
@@ -3,29 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isIgnoredChannel = exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Check if the user has permissions to execute the given command name
|
|
6
|
+
* @param options options
|
|
6
7
|
*/
|
|
7
|
-
function userHasCommandPermissions(
|
|
8
|
-
var _a, _b;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function userHasCommandPermissions(options) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const command = (_c = (((_a = options.commandPermissions) === null || _a === void 0 ? void 0 : _a.enabled)
|
|
11
|
+
? (_b = options.commandPermissions) === null || _b === void 0 ? void 0 : _b.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase())
|
|
12
|
+
: null)) !== null && _c !== void 0 ? _c : { permissions: options.builder.requiredMemberPermissions };
|
|
12
13
|
if (!command.permissions.length)
|
|
13
14
|
return true;
|
|
14
|
-
return memberPermissions ? memberPermissions.has(command.permissions) : false;
|
|
15
|
+
return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
|
|
15
16
|
}
|
|
16
17
|
exports.userHasCommandPermissions = userHasCommandPermissions;
|
|
17
18
|
/**
|
|
18
19
|
* Check if the bot has the required permissions in a guild
|
|
20
|
+
* @param guild Guild
|
|
21
|
+
* @param requiredPermissions Required guild bot permissions
|
|
19
22
|
*/
|
|
20
23
|
function botHasExecutePermissions(guild, requiredPermissions) {
|
|
21
|
-
var _a;
|
|
22
24
|
if (!(requiredPermissions === null || requiredPermissions === void 0 ? void 0 : requiredPermissions.length))
|
|
23
25
|
return true;
|
|
24
|
-
return (guild === null || guild === void 0 ? void 0 : guild.members.me) ?
|
|
26
|
+
return (guild === null || guild === void 0 ? void 0 : guild.members.me) ? guild.members.me.permissions.has(requiredPermissions) : false;
|
|
25
27
|
}
|
|
26
28
|
exports.botHasExecutePermissions = botHasExecutePermissions;
|
|
27
29
|
/**
|
|
28
30
|
* Check if the channel id is ignored in config file
|
|
31
|
+
* @param channelId Check if channel id is in ignore list
|
|
32
|
+
* @param ignoredChannelsConfig Ignored channels config
|
|
29
33
|
*/
|
|
30
34
|
function isIgnoredChannel(channelId, ignoredChannelsConfig) {
|
|
31
35
|
if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
|