reciple 1.0.3 → 1.0.4

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, ((_a = this.config) === null || _a === void 0 ? void 0 : _a.prefix) || '!', ((_b = this.config) === null || _b === void 0 ? void 0 : _b.commands.messageCommand.commandArgumentSeparator) || ' ');
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, ((_c = message.member) === null || _c === void 0 ? void 0 : _c.permissions) || null, (_d = this.config) === null || _d === void 0 ? void 0 : _d.permissions.messageCommands)) {
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(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.notEnoughArguments) || 'Not enough arguments.').catch((err) => this.logger.error(err));
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 => { this.logger.error(`An error occured executing "${command.name}"`); this.logger.error(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, (_a = this.config) === null || _a === void 0 ? void 0 : _a.permissions.interactionCommands)) {
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,31 @@ 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 => { this.logger.error(`An error occured executing "${command.name}"`); this.logger.error(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;
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
+ yield command.message.reply(((_a = this.config) === null || _a === void 0 ? void 0 : _a.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
136
+ }
137
+ else if (command === null || command === void 0 ? void 0 : command.interaction) {
138
+ if (!(command === null || command === void 0 ? void 0 : command.interaction.deferred)) {
139
+ yield command.interaction.reply(((_b = this.config) === null || _b === void 0 ? void 0 : _b.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
140
+ }
141
+ else {
142
+ yield command.interaction.editReply(((_c = this.config) === null || _c === void 0 ? void 0 : _c.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
143
+ }
144
+ }
145
+ });
146
+ }
126
147
  }
127
148
  exports.RecipleClient = RecipleClient;
@@ -0,0 +1,2 @@
1
+ import { Config } from './classes/Config';
2
+ export declare function isIgnoredChannel(channelId: string, ignoredChannelsConfig?: Config["ignoredChannels"]): boolean;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A Discord.js bot",
5
5
  "author": "FalloutStudios",
6
6
  "license": "GPL-3.0",