reciple 1.1.6 → 1.2.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/CHANGELOG.md +21 -1
- package/bin/reciple/classes/Client.js +23 -21
- package/bin/reciple/classes/Config.d.ts +4 -3
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +3 -3
- package/bin/reciple/registerInteractionCommands.js +14 -2
- package/package.json +1 -1
- package/resource/reciple.yml +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
#### 1.
|
|
1
|
+
#### 1.2.0 (2022-05-21)
|
|
2
|
+
|
|
3
|
+
##### New Features
|
|
4
|
+
|
|
5
|
+
* **permissions:** you can now set required permissions for interaction command (3a80154f)
|
|
6
|
+
|
|
7
|
+
##### Refactors
|
|
8
|
+
|
|
9
|
+
* **permissions:** some changes to message command required permissions (22a01ae3)
|
|
10
|
+
|
|
11
|
+
#### 1.2.0 (2022-05-21)
|
|
12
|
+
|
|
13
|
+
##### New Features
|
|
14
|
+
|
|
15
|
+
* **permissions:** you can now set required permissions for interaction command (3a80154f)
|
|
16
|
+
|
|
17
|
+
##### Refactors
|
|
18
|
+
|
|
19
|
+
* **permissions:** some changes to message command required permissions (22a01ae3)
|
|
20
|
+
|
|
21
|
+
#### 1.1.6 (2022-05-21)
|
|
2
22
|
|
|
3
23
|
##### Bug Fixes
|
|
4
24
|
|
|
@@ -88,29 +88,29 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
88
88
|
if (!message.content || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled))
|
|
89
89
|
return this;
|
|
90
90
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, ((_b = this.config) === null || _b === void 0 ? void 0 : _b.prefix) || '!', ((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.messageCommand.commandArgumentSeparator) || ' ');
|
|
91
|
-
if (parseCommand
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command) || !parseCommand)
|
|
92
|
+
return this;
|
|
93
|
+
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
|
|
94
|
+
if (!command)
|
|
95
|
+
return this;
|
|
96
|
+
if ((0, commandPermissions_1.commandPermissions)(command.name, (_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands, command)) {
|
|
97
|
+
if (!command.allowExecuteInDM && message.channel.type === 'DM' || !command.allowExecuteByBots && (message.author.bot || message.author.system) || (0, isIgnoredChannel_1.isIgnoredChannel)(message.channelId, (_f = this.config) === null || _f === void 0 ? void 0 : _f.ignoredChannels))
|
|
98
|
+
return this;
|
|
99
|
+
if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
|
|
100
|
+
yield message.reply(((_g = this.config) === null || _g === void 0 ? void 0 : _g.messages.notEnoughArguments) || 'Not enough arguments.').catch((err) => this.logger.error(err));
|
|
94
101
|
return this;
|
|
95
|
-
if ((0, commandPermissions_1.commandPermissions)(command.name, (_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands, command)) {
|
|
96
|
-
if (!command.allowExecuteInDM && message.channel.type === 'DM' || !command.allowExecuteByBots && (message.author.bot || message.author.system) || (0, isIgnoredChannel_1.isIgnoredChannel)(message.channelId, (_f = this.config) === null || _f === void 0 ? void 0 : _f.ignoredChannels))
|
|
97
|
-
return this;
|
|
98
|
-
if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
|
|
99
|
-
yield message.reply(((_g = this.config) === null || _g === void 0 ? void 0 : _g.messages.notEnoughArguments) || 'Not enough arguments.').catch((err) => this.logger.error(err));
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
const options = {
|
|
103
|
-
message: message,
|
|
104
|
-
command: parseCommand,
|
|
105
|
-
builder: command,
|
|
106
|
-
client: this
|
|
107
|
-
};
|
|
108
|
-
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
109
|
-
this.emit('recipleMessageCommandCreate', options);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
yield message.reply(((_h = this.config) === null || _h === void 0 ? void 0 : _h.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
|
|
113
102
|
}
|
|
103
|
+
const options = {
|
|
104
|
+
message: message,
|
|
105
|
+
command: parseCommand,
|
|
106
|
+
builder: command,
|
|
107
|
+
client: this
|
|
108
|
+
};
|
|
109
|
+
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
110
|
+
this.emit('recipleMessageCommandCreate', options);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
yield message.reply(((_h = this.config) === null || _h === void 0 ? void 0 : _h.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
|
|
114
114
|
}
|
|
115
115
|
return this;
|
|
116
116
|
});
|
|
@@ -121,6 +121,8 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
121
121
|
if (!interaction || !interaction.isCommand() || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.enabled))
|
|
122
122
|
return this;
|
|
123
123
|
const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
|
|
124
|
+
if (!command)
|
|
125
|
+
return this;
|
|
124
126
|
if ((0, commandPermissions_1.commandPermissions)(command.name, (_b = interaction.memberPermissions) !== null && _b !== void 0 ? _b : undefined, (_c = this.config) === null || _c === void 0 ? void 0 : _c.permissions.interactionCommands, command)) {
|
|
125
127
|
if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (_d = this.config) === null || _d === void 0 ? void 0 : _d.ignoredChannels))
|
|
126
128
|
return this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientOptions,
|
|
1
|
+
import { ClientOptions, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
2
|
export interface Config {
|
|
3
3
|
token: string;
|
|
4
4
|
prefix: string;
|
|
@@ -12,6 +12,7 @@ export interface Config {
|
|
|
12
12
|
enabled: boolean;
|
|
13
13
|
replyOnError: boolean;
|
|
14
14
|
registerCommands: boolean;
|
|
15
|
+
setRequiredPermissions: boolean;
|
|
15
16
|
guilds: string[] | string;
|
|
16
17
|
};
|
|
17
18
|
};
|
|
@@ -20,14 +21,14 @@ export interface Config {
|
|
|
20
21
|
enabled: boolean;
|
|
21
22
|
commands: {
|
|
22
23
|
command: string;
|
|
23
|
-
permissions:
|
|
24
|
+
permissions: (PermissionFlags | PermissionString)[];
|
|
24
25
|
}[];
|
|
25
26
|
};
|
|
26
27
|
interactionCommands: {
|
|
27
28
|
enabled: boolean;
|
|
28
29
|
commands: {
|
|
29
30
|
command: string;
|
|
30
|
-
permissions:
|
|
31
|
+
permissions: (PermissionFlags | PermissionString)[];
|
|
31
32
|
}[];
|
|
32
33
|
};
|
|
33
34
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, PermissionFlags } from 'discord.js';
|
|
1
|
+
import { Message, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
2
|
import { Command } from 'fallout-utility';
|
|
3
3
|
import { RecipleClient } from '../Client';
|
|
4
4
|
export declare type CommandMessage = Command;
|
|
@@ -29,12 +29,12 @@ export declare class MessageCommandBuilder {
|
|
|
29
29
|
description: string;
|
|
30
30
|
options: MessageOption[];
|
|
31
31
|
validateOptions: boolean;
|
|
32
|
-
requiredPermissions: (
|
|
32
|
+
requiredPermissions: (PermissionFlags | PermissionString)[];
|
|
33
33
|
allowExecuteInDM: boolean;
|
|
34
34
|
allowExecuteByBots: boolean;
|
|
35
35
|
execute: (options: RecipleMessageCommandExecute) => void;
|
|
36
36
|
setName(name: string): MessageCommandBuilder;
|
|
37
|
-
setRequiredPermissions(permissions: (
|
|
37
|
+
setRequiredPermissions(permissions: (PermissionFlags | PermissionString)[]): MessageCommandBuilder;
|
|
38
38
|
setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
|
|
39
39
|
setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
|
|
40
40
|
setDescription(description: string): MessageCommandBuilder;
|
|
@@ -13,9 +13,21 @@ exports.registerInteractionCommands = void 0;
|
|
|
13
13
|
function registerInteractionCommands(client, cmds, overwriteGuilds) {
|
|
14
14
|
var _a, _b, _c, _d, _e, _f;
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
if (typeof c.toJSON !== 'undefined') {
|
|
19
|
+
const cmd = c;
|
|
20
|
+
if ((cmd === null || cmd === void 0 ? void 0 : cmd.builder) === 'INTERACTION_COMMAND' && ((_a = client.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.setRequiredPermissions)) {
|
|
21
|
+
const permissions = (_g = (((_c = (_b = client.config) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.interactionCommands.enabled) ?
|
|
22
|
+
(_f = (_e = (_d = client.config) === null || _d === void 0 ? void 0 : _d.permissions) === null || _e === void 0 ? void 0 : _e.interactionCommands.commands.find(c => c.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
|
|
23
|
+
undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
|
|
24
|
+
cmd.setRequiredPermissions(permissions);
|
|
25
|
+
client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
|
|
26
|
+
client.logger.debug(`Set required permissions for ${cmd.name} to ${permissions.join(', ')}`);
|
|
27
|
+
return cmd.toJSON();
|
|
28
|
+
}
|
|
18
29
|
return c.toJSON();
|
|
30
|
+
}
|
|
19
31
|
return c;
|
|
20
32
|
})) !== null && _a !== void 0 ? _a : [];
|
|
21
33
|
if (!commands || !commands.length) {
|
package/package.json
CHANGED
package/resource/reciple.yml
CHANGED
|
@@ -22,6 +22,8 @@ commands:
|
|
|
22
22
|
replyOnError: false
|
|
23
23
|
# register interaction commands on bot ready
|
|
24
24
|
registerCommands: true
|
|
25
|
+
# set required permissions for interaction commands
|
|
26
|
+
setRequiredPermissions: true
|
|
25
27
|
# register commands to specific guild(s) empty to make it global
|
|
26
28
|
guilds: []
|
|
27
29
|
|