reciple 3.0.0 → 3.0.1
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/index.d.ts +2 -1
- package/bin/index.js +2 -1
- package/bin/reciple/classes/RecipleClient.js +3 -4
- package/bin/reciple/permissions.d.ts +7 -0
- package/bin/reciple/permissions.js +17 -1
- package/bin/reciple/registerInteractionCommands.js +2 -2
- package/package.json +1 -1
- package/bin/reciple/isIgnoredChannel.d.ts +0 -5
- package/bin/reciple/isIgnoredChannel.js +0 -16
package/bin/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export * from './reciple/classes/RecipleClient';
|
|
2
2
|
export * from './reciple/classes/RecipleConfig';
|
|
3
|
+
export * from './reciple/classes/CommandCooldownManager';
|
|
3
4
|
export * from './reciple/classes/MessageCommandOptionManager';
|
|
4
5
|
export * from './reciple/classes/builders/InteractionCommandBuilder';
|
|
5
6
|
export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
6
7
|
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
7
8
|
export * from './reciple/types/builders';
|
|
8
9
|
export * from './reciple/types/commands';
|
|
10
|
+
export * from './reciple/types/paramOptions';
|
|
9
11
|
export * from './reciple/permissions';
|
|
10
12
|
export * from './reciple/flags';
|
|
11
|
-
export * from './reciple/isIgnoredChannel';
|
|
12
13
|
export * from './reciple/logger';
|
|
13
14
|
export * from './reciple/modules';
|
|
14
15
|
export * from './reciple/registerInteractionCommands';
|
package/bin/index.js
CHANGED
|
@@ -16,15 +16,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./reciple/classes/RecipleClient"), exports);
|
|
18
18
|
__exportStar(require("./reciple/classes/RecipleConfig"), exports);
|
|
19
|
+
__exportStar(require("./reciple/classes/CommandCooldownManager"), exports);
|
|
19
20
|
__exportStar(require("./reciple/classes/MessageCommandOptionManager"), exports);
|
|
20
21
|
__exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
|
|
21
22
|
__exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
|
|
22
23
|
__exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
|
|
23
24
|
__exportStar(require("./reciple/types/builders"), exports);
|
|
24
25
|
__exportStar(require("./reciple/types/commands"), exports);
|
|
26
|
+
__exportStar(require("./reciple/types/paramOptions"), exports);
|
|
25
27
|
__exportStar(require("./reciple/permissions"), exports);
|
|
26
28
|
__exportStar(require("./reciple/flags"), exports);
|
|
27
|
-
__exportStar(require("./reciple/isIgnoredChannel"), exports);
|
|
28
29
|
__exportStar(require("./reciple/logger"), exports);
|
|
29
30
|
__exportStar(require("./reciple/modules"), exports);
|
|
30
31
|
__exportStar(require("./reciple/registerInteractionCommands"), exports);
|
|
@@ -12,15 +12,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.RecipleClient = void 0;
|
|
14
14
|
const builders_1 = require("../types/builders");
|
|
15
|
-
const registerInteractionCommands_1 = require("../registerInteractionCommands");
|
|
16
15
|
const permissions_1 = require("../permissions");
|
|
16
|
+
const registerInteractionCommands_1 = require("../registerInteractionCommands");
|
|
17
17
|
const CommandCooldownManager_1 = require("./CommandCooldownManager");
|
|
18
18
|
const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
|
|
19
19
|
const fallout_utility_1 = require("fallout-utility");
|
|
20
20
|
const commands_1 = require("../types/commands");
|
|
21
21
|
const modules_1 = require("../modules");
|
|
22
22
|
const RecipleConfig_1 = require("./RecipleConfig");
|
|
23
|
-
const isIgnoredChannel_1 = require("../isIgnoredChannel");
|
|
24
23
|
const version_1 = require("../version");
|
|
25
24
|
const logger_1 = require("../logger");
|
|
26
25
|
const discord_js_1 = require("discord.js");
|
|
@@ -176,7 +175,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
176
175
|
if (!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM
|
|
177
176
|
|| !command.allowExecuteByBots
|
|
178
177
|
&& (message.author.bot || message.author.system)
|
|
179
|
-
|| (0,
|
|
178
|
+
|| (0, permissions_1.isIgnoredChannel)(message.channelId, this.config.ignoredChannels))
|
|
180
179
|
return;
|
|
181
180
|
if (command.validateOptions) {
|
|
182
181
|
if (commandOptions.some(o => o.invalid)) {
|
|
@@ -248,7 +247,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
248
247
|
client: this
|
|
249
248
|
};
|
|
250
249
|
if ((0, permissions_1.userHasCommandPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.commands.interactionCommand.permissions, command)) {
|
|
251
|
-
if (!command || (0,
|
|
250
|
+
if (!command || (0, permissions_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
|
|
252
251
|
return;
|
|
253
252
|
if (interaction.guild && !(0, permissions_1.botHasExecutePermissions)(interaction.guild, command.requiredBotPermissions)) {
|
|
254
253
|
if (!command.halt || !(yield command.halt({ executeData, reason: commands_1.RecipleHaltedCommandReason.MissingBotPermissions }))) {
|
|
@@ -5,4 +5,11 @@ import { Config } from './classes/RecipleConfig';
|
|
|
5
5
|
* Check if the user has permissions to execute the given command name
|
|
6
6
|
*/
|
|
7
7
|
export declare function userHasCommandPermissions(commandName: string, memberPermissions?: PermissionsBitField, configConmmandPermissions?: Config['commands']['messageCommand']['permissions'] | Config['commands']['interactionCommand']['permissions'], builder?: RecipleCommandBuilders): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the bot has the required permissions in a guild
|
|
10
|
+
*/
|
|
8
11
|
export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if the channel id is ignored in config file
|
|
14
|
+
*/
|
|
15
|
+
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.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
|
|
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
6
|
*/
|
|
@@ -14,6 +14,9 @@ function userHasCommandPermissions(commandName, memberPermissions, configConmman
|
|
|
14
14
|
return memberPermissions ? memberPermissions.has(command.permissions) : false;
|
|
15
15
|
}
|
|
16
16
|
exports.userHasCommandPermissions = userHasCommandPermissions;
|
|
17
|
+
/**
|
|
18
|
+
* Check if the bot has the required permissions in a guild
|
|
19
|
+
*/
|
|
17
20
|
function botHasExecutePermissions(guild, requiredPermissions) {
|
|
18
21
|
var _a;
|
|
19
22
|
if (!(requiredPermissions === null || requiredPermissions === void 0 ? void 0 : requiredPermissions.length))
|
|
@@ -21,3 +24,16 @@ function botHasExecutePermissions(guild, requiredPermissions) {
|
|
|
21
24
|
return (guild === null || guild === void 0 ? void 0 : guild.members.me) ? (_a = guild.members.me) === null || _a === void 0 ? void 0 : _a.permissions.has(requiredPermissions) : false;
|
|
22
25
|
}
|
|
23
26
|
exports.botHasExecutePermissions = botHasExecutePermissions;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the channel id is ignored in config file
|
|
29
|
+
*/
|
|
30
|
+
function isIgnoredChannel(channelId, ignoredChannelsConfig) {
|
|
31
|
+
if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
|
|
32
|
+
return false;
|
|
33
|
+
if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
|
|
34
|
+
return true;
|
|
35
|
+
if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
|
|
36
|
+
return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
exports.isIgnoredChannel = isIgnoredChannel;
|
|
@@ -17,8 +17,8 @@ const InteractionCommandBuilder_1 = require("./classes/builders/InteractionComma
|
|
|
17
17
|
function registerInteractionCommands(options) {
|
|
18
18
|
var _a, _b, _c, _d;
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
guilds = typeof guilds == 'string' ? [guilds] : guilds;
|
|
20
|
+
const client = options.client;
|
|
21
|
+
const guilds = typeof options.guilds == 'string' ? [options.guilds] : options.guilds;
|
|
22
22
|
const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.interactionCommands).map(cmd => {
|
|
23
23
|
var _a, _b;
|
|
24
24
|
if (typeof (cmd === null || cmd === void 0 ? void 0 : cmd.toJSON) == 'undefined')
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIgnoredChannel = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Check if the channel id is ignored in config file
|
|
6
|
-
*/
|
|
7
|
-
function isIgnoredChannel(channelId, ignoredChannelsConfig) {
|
|
8
|
-
if (!(ignoredChannelsConfig === null || ignoredChannelsConfig === void 0 ? void 0 : ignoredChannelsConfig.enabled))
|
|
9
|
-
return false;
|
|
10
|
-
if (ignoredChannelsConfig.channels.includes(channelId) && !ignoredChannelsConfig.convertToAllowList)
|
|
11
|
-
return true;
|
|
12
|
-
if (!ignoredChannelsConfig.channels.includes(channelId) && ignoredChannelsConfig.convertToAllowList)
|
|
13
|
-
return true;
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
exports.isIgnoredChannel = isIgnoredChannel;
|