reciple 5.0.0-pre.2 → 5.0.0-pre.3
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/bin.js +3 -0
- package/bin/reciple/classes/RecipleClient.d.ts +1 -1
- package/bin/reciple/classes/RecipleClient.js +10 -13
- package/bin/reciple/classes/RecipleConfig.d.ts +0 -5
- package/bin/reciple/flags.js +2 -1
- package/bin/reciple/permissions.d.ts +0 -7
- package/bin/reciple/permissions.js +1 -16
- package/package.json +1 -1
- package/resource/reciple.yml +0 -10
package/bin/bin.js
CHANGED
|
@@ -46,6 +46,9 @@ if (config.fileLogging.clientLogs)
|
|
|
46
46
|
var _e;
|
|
47
47
|
if (client.isClientLogsEnabled())
|
|
48
48
|
client.logger.warn(`Logged in as ${((_e = client.user) === null || _e === void 0 ? void 0 : _e.tag) || 'Unknown'}!`);
|
|
49
|
+
client.on('cacheSweep', () => {
|
|
50
|
+
client.cooldowns.clean();
|
|
51
|
+
});
|
|
49
52
|
yield client.loadModules();
|
|
50
53
|
client.addCommandListeners();
|
|
51
54
|
}));
|
|
@@ -53,7 +53,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
53
53
|
config: Config;
|
|
54
54
|
commands: RecipleClientCommands;
|
|
55
55
|
otherApplicationCommandData: (ApplicationCommandBuilder | ApplicationCommandData)[];
|
|
56
|
-
|
|
56
|
+
cooldowns: CommandCooldownManager;
|
|
57
57
|
modules: RecipleModule[];
|
|
58
58
|
logger: ILogger;
|
|
59
59
|
version: string;
|
|
@@ -13,8 +13,8 @@ exports.RecipleClient = void 0;
|
|
|
13
13
|
const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
|
|
14
14
|
const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
|
|
15
15
|
const registerApplicationCommands_1 = require("../registerApplicationCommands");
|
|
16
|
-
const permissions_1 = require("../permissions");
|
|
17
16
|
const builders_1 = require("../types/builders");
|
|
17
|
+
const permissions_1 = require("../permissions");
|
|
18
18
|
const CommandCooldownManager_1 = require("./CommandCooldownManager");
|
|
19
19
|
const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
|
|
20
20
|
const commands_1 = require("../types/commands");
|
|
@@ -34,7 +34,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
34
34
|
this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
|
|
35
35
|
this.commands = { messageCommands: {}, slashCommands: {} };
|
|
36
36
|
this.otherApplicationCommandData = [];
|
|
37
|
-
this.
|
|
37
|
+
this.cooldowns = new CommandCooldownManager_1.CommandCooldownManager();
|
|
38
38
|
this.modules = [];
|
|
39
39
|
this.version = version_1.version;
|
|
40
40
|
this.logger = (0, logger_1.createLogger)(!!((_a = options.config) === null || _a === void 0 ? void 0 : _a.fileLogging.stringifyLoggedJSON), (_b = options.config) === null || _b === void 0 ? void 0 : _b.fileLogging.debugmode);
|
|
@@ -185,10 +185,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
185
185
|
memberPermissions: (_a = message.member) === null || _a === void 0 ? void 0 : _a.permissions,
|
|
186
186
|
commandPermissions: this.config.commands.messageCommand.permissions
|
|
187
187
|
})) {
|
|
188
|
-
if (!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM
|
|
189
|
-
|| !command.allowExecuteByBots
|
|
190
|
-
&& (message.author.bot || message.author.system)
|
|
191
|
-
|| (0, permissions_1.isIgnoredChannel)(message.channelId, this.config.ignoredChannels))
|
|
188
|
+
if (!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM || !command.allowExecuteByBots && (message.author.bot || message.author.system))
|
|
192
189
|
return;
|
|
193
190
|
if (command.validateOptions) {
|
|
194
191
|
if (commandOptions.some(o => o.invalid)) {
|
|
@@ -217,11 +214,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
217
214
|
guild: message.guild,
|
|
218
215
|
type: builders_1.CommandBuilderType.MessageCommand
|
|
219
216
|
};
|
|
220
|
-
if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.
|
|
221
|
-
this.
|
|
217
|
+
if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
|
|
218
|
+
this.cooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
|
|
222
219
|
}
|
|
223
220
|
else if (this.config.commands.messageCommand.enableCooldown && command.cooldown) {
|
|
224
|
-
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.CommandHaltReason.Cooldown }, this.
|
|
221
|
+
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.CommandHaltReason.Cooldown }, this.cooldowns.get(userCooldown))))) {
|
|
225
222
|
yield message.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
|
|
226
223
|
}
|
|
227
224
|
return;
|
|
@@ -265,7 +262,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
265
262
|
memberPermissions: (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined,
|
|
266
263
|
commandPermissions: this.config.commands.slashCommand.permissions
|
|
267
264
|
})) {
|
|
268
|
-
if (!command
|
|
265
|
+
if (!command)
|
|
269
266
|
return;
|
|
270
267
|
if (interaction.guild && !(0, permissions_1.botHasExecutePermissions)(interaction.guild, command.requiredBotPermissions)) {
|
|
271
268
|
if (!(yield this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingBotPermissions }))) {
|
|
@@ -280,11 +277,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
280
277
|
guild: interaction.guild,
|
|
281
278
|
type: builders_1.CommandBuilderType.SlashCommand
|
|
282
279
|
};
|
|
283
|
-
if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.
|
|
284
|
-
this.
|
|
280
|
+
if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
|
|
281
|
+
this.cooldowns.add(Object.assign(Object.assign({}, userCooldown), { expireTime: Date.now() + command.cooldown }));
|
|
285
282
|
}
|
|
286
283
|
else if (this.config.commands.slashCommand.enableCooldown && command.cooldown) {
|
|
287
|
-
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.CommandHaltReason.Cooldown }, this.
|
|
284
|
+
if (!(yield this._haltCommand(command, Object.assign({ executeData, reason: commands_1.CommandHaltReason.Cooldown }, this.cooldowns.get(userCooldown))))) {
|
|
288
285
|
yield interaction.reply(this.getMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
|
|
289
286
|
}
|
|
290
287
|
return;
|
package/bin/reciple/flags.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.token = exports.flags = void 0;
|
|
4
|
+
const version_1 = require("./version");
|
|
4
5
|
const commander_1 = require("commander");
|
|
5
6
|
/**
|
|
6
7
|
* Used flags
|
|
@@ -8,7 +9,7 @@ const commander_1 = require("commander");
|
|
|
8
9
|
exports.flags = new commander_1.Command()
|
|
9
10
|
.name('reciple')
|
|
10
11
|
.description('Reciple.js - Discord.js handler cli')
|
|
11
|
-
.version(`v${
|
|
12
|
+
.version(`v${version_1.rawVersion}`, '-v, --version')
|
|
12
13
|
.option('-t, --token <token>', 'Replace used bot token')
|
|
13
14
|
.option('-c, --config <config>', 'Change path to config file')
|
|
14
15
|
.option('-D, --debugmode', 'Enabled debug mode')
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
2
2
|
import { Guild, PermissionResolvable } from 'discord.js';
|
|
3
|
-
import { Config } from './classes/RecipleConfig';
|
|
4
3
|
/**
|
|
5
4
|
* Check if the user has permissions to execute the given command name
|
|
6
5
|
* @param options options
|
|
@@ -12,9 +11,3 @@ export declare function userHasCommandPermissions(options: UserHasCommandPermiss
|
|
|
12
11
|
* @param requiredPermissions Required guild bot permissions
|
|
13
12
|
*/
|
|
14
13
|
export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
15
|
-
/**
|
|
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
|
|
19
|
-
*/
|
|
20
|
-
export declare function isIgnoredChannel(channelId: string, ignoredChannelsConfig?: Config["ignoredChannels"]): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Check if the user has permissions to execute the given command name
|
|
6
6
|
* @param options options
|
|
@@ -26,18 +26,3 @@ function botHasExecutePermissions(guild, requiredPermissions) {
|
|
|
26
26
|
return (guild === null || guild === void 0 ? void 0 : guild.members.me) ? guild.members.me.permissions.has(requiredPermissions) : false;
|
|
27
27
|
}
|
|
28
28
|
exports.botHasExecutePermissions = botHasExecutePermissions;
|
|
29
|
-
/**
|
|
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
|
|
33
|
-
*/
|
|
34
|
-
function isIgnoredChannel(channelId, ignoredChannelsConfig) {
|
|
35
|
-
if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
|
|
36
|
-
return false;
|
|
37
|
-
if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
|
|
38
|
-
return true;
|
|
39
|
-
if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
|
|
40
|
-
return true;
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
exports.isIgnoredChannel = isIgnoredChannel;
|
package/package.json
CHANGED
package/resource/reciple.yml
CHANGED
|
@@ -49,16 +49,6 @@ commands:
|
|
|
49
49
|
permissions: ['Administrator']
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
# Ignored channel IDs
|
|
53
|
-
ignoredChannels:
|
|
54
|
-
# enable ignored channels
|
|
55
|
-
enabled: false
|
|
56
|
-
# convert to only allowed channels
|
|
57
|
-
convertToAllowList: false
|
|
58
|
-
# channel IDs
|
|
59
|
-
channels: []
|
|
60
|
-
|
|
61
|
-
|
|
62
52
|
# Logger options
|
|
63
53
|
fileLogging:
|
|
64
54
|
# enable console output to file
|