reciple 1.0.3 → 1.0.6
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.
|
@@ -31,4 +31,5 @@ export declare class RecipleClient extends Client {
|
|
|
31
31
|
addCommandListeners(): RecipleClient;
|
|
32
32
|
messageCommandExecute(message: Message): Promise<RecipleClient>;
|
|
33
33
|
interactionCommandExecute(interaction: Interaction): Promise<RecipleClient>;
|
|
34
|
+
private _commandExecuteError;
|
|
34
35
|
}
|
|
@@ -17,6 +17,7 @@ const logger_1 = require("../logger");
|
|
|
17
17
|
const modules_1 = require("../modules");
|
|
18
18
|
const version_1 = require("../version");
|
|
19
19
|
const commandPermissions_1 = require("../commandPermissions");
|
|
20
|
+
const isIgnoredChannel_1 = require("../isIgnoredChannel");
|
|
20
21
|
class RecipleClient extends discord_js_1.Client {
|
|
21
22
|
constructor(options) {
|
|
22
23
|
super(options);
|
|
@@ -75,18 +76,18 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
75
76
|
return this;
|
|
76
77
|
}
|
|
77
78
|
messageCommandExecute(message) {
|
|
78
|
-
var _a, _b, _c, _d, _e;
|
|
79
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
79
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
if (!message.content)
|
|
81
|
+
if (!message.content || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled))
|
|
81
82
|
return this;
|
|
82
|
-
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, ((
|
|
83
|
+
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) || ' ');
|
|
83
84
|
if (parseCommand && parseCommand.command) {
|
|
84
85
|
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
|
|
85
|
-
if (command && (0, commandPermissions_1.commandPermissions)(command.name, ((
|
|
86
|
-
if (!command.allowExecuteInDM && message.channel.type === 'DM' || !command.allowExecuteByBots && (message.author.bot || message.author.system))
|
|
86
|
+
if (command && (0, commandPermissions_1.commandPermissions)(command.name, ((_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions) || null, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands)) {
|
|
87
|
+
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))
|
|
87
88
|
return this;
|
|
88
89
|
if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
|
|
89
|
-
yield message.reply(((
|
|
90
|
+
yield message.reply(((_g = this.config) === null || _g === void 0 ? void 0 : _g.messages.notEnoughArguments) || 'Not enough arguments.').catch((err) => this.logger.error(err));
|
|
90
91
|
return this;
|
|
91
92
|
}
|
|
92
93
|
const options = {
|
|
@@ -95,7 +96,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
95
96
|
builder: command,
|
|
96
97
|
client: this
|
|
97
98
|
};
|
|
98
|
-
yield Promise.resolve(command.execute(options)).catch(err =>
|
|
99
|
+
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
99
100
|
this.emit('recipleMessageCommandCreate', options);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -103,13 +104,13 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
interactionCommandExecute(interaction) {
|
|
106
|
-
var _a;
|
|
107
|
+
var _a, _b, _c;
|
|
107
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
if (!interaction || !interaction.isCommand())
|
|
109
|
+
if (!interaction || !interaction.isCommand() || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.enabled))
|
|
109
110
|
return this;
|
|
110
111
|
const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
|
|
111
|
-
if (command && (0, commandPermissions_1.commandPermissions)(command.name, interaction.memberPermissions, (
|
|
112
|
-
if (!command.allowExecuteInDM && interaction.member === null)
|
|
112
|
+
if (command && (0, commandPermissions_1.commandPermissions)(command.name, interaction.memberPermissions, (_b = this.config) === null || _b === void 0 ? void 0 : _b.permissions.interactionCommands)) {
|
|
113
|
+
if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (_c = this.config) === null || _c === void 0 ? void 0 : _c.ignoredChannels))
|
|
113
114
|
return this;
|
|
114
115
|
const options = {
|
|
115
116
|
interaction: interaction,
|
|
@@ -117,11 +118,35 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
117
118
|
builder: command,
|
|
118
119
|
client: this
|
|
119
120
|
};
|
|
120
|
-
yield Promise.resolve(command.execute(options)).catch(err =>
|
|
121
|
+
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
121
122
|
this.emit('recipleInteractionCommandCreate', options);
|
|
122
123
|
}
|
|
123
124
|
return this;
|
|
124
125
|
});
|
|
125
126
|
}
|
|
127
|
+
_commandExecuteError(err, command) {
|
|
128
|
+
var _a, _b, _c, _d, _e;
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
this.logger.error(`An error occured executing ${command.builder.type == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
|
|
131
|
+
this.logger.error(err);
|
|
132
|
+
if (!err || !command)
|
|
133
|
+
return;
|
|
134
|
+
if (command === null || command === void 0 ? void 0 : command.message) {
|
|
135
|
+
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.replyOnError))
|
|
136
|
+
return;
|
|
137
|
+
yield command.message.reply(((_b = this.config) === null || _b === void 0 ? void 0 : _b.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
138
|
+
}
|
|
139
|
+
else if (command === null || command === void 0 ? void 0 : command.interaction) {
|
|
140
|
+
if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
|
|
141
|
+
return;
|
|
142
|
+
if (!(command === null || command === void 0 ? void 0 : command.interaction.deferred)) {
|
|
143
|
+
yield command.interaction.reply(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
yield command.interaction.editReply(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
126
151
|
}
|
|
127
152
|
exports.RecipleClient = RecipleClient;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { ClientOptions, MessageOptions, PermissionResolvable } from 'discord.js';
|
|
1
|
+
import { ClientOptions, InteractionReplyOptions, MessageOptions, PermissionResolvable } from 'discord.js';
|
|
2
2
|
export interface Config {
|
|
3
3
|
token: string;
|
|
4
4
|
prefix: string;
|
|
5
5
|
commands: {
|
|
6
6
|
messageCommand: {
|
|
7
7
|
enabled: boolean;
|
|
8
|
+
replyOnError: boolean;
|
|
8
9
|
commandArgumentSeparator: string;
|
|
9
10
|
};
|
|
10
11
|
interactionCommand: {
|
|
11
12
|
enabled: boolean;
|
|
13
|
+
replyOnError: boolean;
|
|
12
14
|
registerCommands: boolean;
|
|
13
15
|
guilds: string[] | string;
|
|
14
16
|
};
|
|
@@ -40,7 +42,7 @@ export interface Config {
|
|
|
40
42
|
};
|
|
41
43
|
client: ClientOptions;
|
|
42
44
|
messages: {
|
|
43
|
-
[key: string]: MessageOptions | string;
|
|
45
|
+
[key: string]: MessageOptions | InteractionReplyOptions | string;
|
|
44
46
|
};
|
|
45
47
|
modulesFolder: string;
|
|
46
48
|
version?: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIgnoredChannel = void 0;
|
|
4
|
+
function isIgnoredChannel(channelId, ignoredChannelsConfig) {
|
|
5
|
+
if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
|
|
6
|
+
return false;
|
|
7
|
+
if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
|
|
8
|
+
return false;
|
|
9
|
+
if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
|
|
10
|
+
return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
exports.isIgnoredChannel = isIgnoredChannel;
|
package/package.json
CHANGED
package/resource/reciple.yml
CHANGED
|
@@ -4,9 +4,11 @@ prefix: '!'
|
|
|
4
4
|
commands:
|
|
5
5
|
messageCommand:
|
|
6
6
|
enabled: true
|
|
7
|
+
replyOnError: false
|
|
7
8
|
commandArgumentSeparator: ' '
|
|
8
9
|
interactionCommand:
|
|
9
10
|
enabled: true
|
|
11
|
+
replyOnError: false
|
|
10
12
|
registerCommands: true
|
|
11
13
|
guilds: []
|
|
12
14
|
|
|
@@ -42,8 +44,13 @@ client:
|
|
|
42
44
|
- 'GUILD_MESSAGE_REACTIONS'
|
|
43
45
|
|
|
44
46
|
messages:
|
|
45
|
-
noPermission: 'You do not have permission to use this command.'
|
|
46
47
|
notEnoughArguments: 'Not enough arguments.'
|
|
48
|
+
noPermission:
|
|
49
|
+
content: 'You do not have permission to use this command.'
|
|
50
|
+
ephemeral: true
|
|
51
|
+
error:
|
|
52
|
+
content: 'An error occurred.'
|
|
53
|
+
ephemeral: true
|
|
47
54
|
|
|
48
55
|
modulesFolder: 'modules'
|
|
49
56
|
|