reciple 1.4.2 → 1.5.2

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 CHANGED
@@ -5,7 +5,7 @@ export * from './reciple/classes/Config';
5
5
  export * from './reciple/classes/builders/InteractionCommandBuilder';
6
6
  export * from './reciple/classes/builders/MessageCommandBuilder';
7
7
  export * from './reciple/classes/builders/MessageCommandOptionBuilder';
8
- export * from './reciple/commandPermissions';
8
+ export * from './reciple/hasPermissions';
9
9
  export * from './reciple/flags';
10
10
  export * from './reciple/isIgnoredChannel';
11
11
  export * from './reciple/logger';
package/bin/index.js CHANGED
@@ -25,7 +25,7 @@ __exportStar(require("./reciple/classes/Config"), exports);
25
25
  __exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
26
26
  __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
27
27
  __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
28
- __exportStar(require("./reciple/commandPermissions"), exports);
28
+ __exportStar(require("./reciple/hasPermissions"), exports);
29
29
  __exportStar(require("./reciple/flags"), exports);
30
30
  __exportStar(require("./reciple/isIgnoredChannel"), exports);
31
31
  __exportStar(require("./reciple/logger"), exports);
@@ -1,7 +1,7 @@
1
1
  import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './builders/InteractionCommandBuilder';
2
2
  import { interactionCommandBuilders } from '../registerInteractionCommands';
3
3
  import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
4
- import { Logger as LoggerConstructor } from 'fallout-utility';
4
+ import { Logger as ILogger } from 'fallout-utility';
5
5
  import { Config } from './Config';
6
6
  import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
7
7
  import { recipleCommandBuilders, RecipleScript } from '../modules';
@@ -33,11 +33,11 @@ export interface RecipleClient extends Client {
33
33
  removeAllListeners(event?: string | symbol): this;
34
34
  }
35
35
  export declare class RecipleClient extends Client {
36
- config?: Config;
36
+ config: Config;
37
37
  commands: RecipleClientCommands;
38
38
  otherApplicationCommandData: (interactionCommandBuilders | ApplicationCommandDataResolvable)[];
39
39
  modules: RecipleScript[];
40
- logger: LoggerConstructor;
40
+ logger: ILogger;
41
41
  version: string;
42
42
  constructor(options: RecipleClientOptions);
43
43
  startModules(): Promise<RecipleClient>;
@@ -45,7 +45,8 @@ export declare class RecipleClient extends Client {
45
45
  addModule(script: RecipleScript, registerCommands?: boolean): Promise<void>;
46
46
  addCommand(command: recipleCommandBuilders): RecipleClient;
47
47
  addCommandListeners(): RecipleClient;
48
- messageCommandExecute(message: Message): Promise<RecipleClient>;
49
- interactionCommandExecute(interaction: Interaction): Promise<RecipleClient>;
48
+ messageCommandExecute(message: Message): Promise<void>;
49
+ interactionCommandExecute(interaction: Interaction): Promise<void>;
50
+ getMessage<T = any>(messageKey: string, defaultMessage?: T): T;
50
51
  private _commandExecuteError;
51
52
  }
@@ -18,8 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.RecipleClient = void 0;
19
19
  const registerInteractionCommands_1 = require("../registerInteractionCommands");
20
20
  const fallout_utility_1 = require("fallout-utility");
21
- const commandPermissions_1 = require("../commandPermissions");
22
21
  const isIgnoredChannel_1 = require("../isIgnoredChannel");
22
+ const hasPermissions_1 = require("../hasPermissions");
23
23
  const version_1 = require("../version");
24
24
  const logger_1 = require("../logger");
25
25
  const discord_js_1 = require("discord.js");
@@ -57,21 +57,20 @@ class RecipleClient extends discord_js_1.Client {
57
57
  });
58
58
  }
59
59
  loadModules() {
60
- var _a;
61
60
  return __awaiter(this, void 0, void 0, function* () {
62
61
  for (const module_ of this.modules) {
63
62
  if (typeof (module_ === null || module_ === void 0 ? void 0 : module_.onLoad) === 'function')
64
63
  yield Promise.resolve(module_.onLoad(this));
65
64
  }
66
65
  this.logger.info(`${this.modules.length} modules loaded.`);
67
- if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands))
66
+ if (!this.config.commands.interactionCommand.registerCommands)
68
67
  return this;
69
68
  yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
70
69
  return this;
71
70
  });
72
71
  }
73
72
  addModule(script, registerCommands = true) {
74
- var _a, _b;
73
+ var _a;
75
74
  return __awaiter(this, void 0, void 0, function* () {
76
75
  this.modules.push(script);
77
76
  if (typeof (script === null || script === void 0 ? void 0 : script.onLoad) === 'function')
@@ -82,7 +81,7 @@ class RecipleClient extends discord_js_1.Client {
82
81
  continue;
83
82
  this.addCommand(command);
84
83
  }
85
- if (!registerCommands || !((_b = this.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.registerCommands))
84
+ if (!registerCommands || !this.config.commands.interactionCommand.registerCommands)
86
85
  return;
87
86
  yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
88
87
  });
@@ -101,33 +100,43 @@ class RecipleClient extends discord_js_1.Client {
101
100
  return this;
102
101
  }
103
102
  addCommandListeners() {
104
- var _a, _b;
105
- if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled)
103
+ if (this.config.commands.messageCommand.enabled)
106
104
  this.on('messageCreate', (message) => { this.messageCommandExecute(message); });
107
- if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.enabled)
105
+ if (this.config.commands.interactionCommand.enabled)
108
106
  this.on('interactionCreate', (interaction) => { this.interactionCommandExecute(interaction); });
109
107
  return this;
110
108
  }
111
109
  messageCommandExecute(message) {
112
- var _a, _b, _c, _d, _e, _f, _g, _h;
110
+ var _a;
113
111
  return __awaiter(this, void 0, void 0, function* () {
114
- if (!message.content || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled))
115
- return this;
116
- 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) || ' ');
112
+ if (!message.content || !this.config.commands.messageCommand.enabled)
113
+ return;
114
+ const parseCommand = (0, fallout_utility_1.getCommand)(message.content, this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
117
115
  if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command) || !parseCommand)
118
- return this;
116
+ return;
119
117
  const command = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()];
120
118
  if (!command)
121
- return this;
122
- 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)) {
123
- 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))
124
- return this;
125
- if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
126
- yield message.reply(((_g = this.config) === null || _g === void 0 ? void 0 : _g.messages.notEnoughArguments) || 'Not enough arguments.').catch((err) => this.logger.error(err));
127
- return this;
119
+ return;
120
+ if ((0, hasPermissions_1.hasPermissions)(command.name, (_a = message.member) === null || _a === void 0 ? void 0 : _a.permissions, this.config.permissions.messageCommands, command)) {
121
+ if (!command.allowExecuteInDM && message.channel.type === 'DM'
122
+ || !command.allowExecuteByBots
123
+ && (message.author.bot || message.author.system)
124
+ || (0, isIgnoredChannel_1.isIgnoredChannel)(message.channelId, this.config.ignoredChannels))
125
+ return;
126
+ const commandOptions = command.getCommandOptionValues(parseCommand);
127
+ if (command.validateOptions) {
128
+ if (commandOptions.some(o => o.invalid)) {
129
+ yield message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.'));
130
+ return;
131
+ }
132
+ if (commandOptions.some(o => o.missing)) {
133
+ yield message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.'));
134
+ return;
135
+ }
128
136
  }
129
137
  const options = {
130
138
  message: message,
139
+ options: commandOptions,
131
140
  command: parseCommand,
132
141
  builder: command,
133
142
  client: this
@@ -136,24 +145,23 @@ class RecipleClient extends discord_js_1.Client {
136
145
  this.emit('recipleMessageCommandCreate', options);
137
146
  }
138
147
  else {
139
- 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));
148
+ yield message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch((err) => this.logger.error(err));
140
149
  }
141
- return this;
142
150
  });
143
151
  }
144
152
  interactionCommandExecute(interaction) {
145
- var _a, _b, _c, _d, _e;
153
+ var _a;
146
154
  return __awaiter(this, void 0, void 0, function* () {
147
- if (!interaction || !interaction.isCommand() || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.enabled))
148
- return this;
155
+ if (!interaction || !interaction.isCommand() || !this.config.commands.interactionCommand.enabled)
156
+ return;
149
157
  const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
150
158
  if (!command)
151
- return this;
152
- 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)) {
153
- if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (_d = this.config) === null || _d === void 0 ? void 0 : _d.ignoredChannels))
154
- return this;
159
+ return;
160
+ if ((0, hasPermissions_1.hasPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.permissions.interactionCommands, command)) {
161
+ if (!command.allowExecuteInDM && !interaction.inCachedGuild() || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
162
+ return;
155
163
  if (!command)
156
- return this;
164
+ return;
157
165
  const options = {
158
166
  interaction: interaction,
159
167
  command: command,
@@ -164,27 +172,29 @@ class RecipleClient extends discord_js_1.Client {
164
172
  this.emit('recipleInteractionCommandCreate', options);
165
173
  }
166
174
  else {
167
- yield interaction.reply(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
175
+ yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch((err) => this.logger.error(err));
168
176
  }
169
- return this;
170
177
  });
171
178
  }
179
+ getMessage(messageKey, defaultMessage) {
180
+ var _a, _b;
181
+ return (_b = (_a = this.config.messages[messageKey]) !== null && _a !== void 0 ? _a : defaultMessage) !== null && _b !== void 0 ? _b : messageKey;
182
+ }
172
183
  _commandExecuteError(err, command) {
173
- var _a, _b, _c, _d;
174
184
  return __awaiter(this, void 0, void 0, function* () {
175
185
  this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
176
186
  this.logger.error(err);
177
187
  if (!err || !command)
178
188
  return;
179
189
  if (command === null || command === void 0 ? void 0 : command.message) {
180
- if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.replyOnError))
190
+ if (!this.config.commands.messageCommand.replyOnError)
181
191
  return;
182
- 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));
192
+ yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch((e) => this.logger.error(e));
183
193
  }
184
194
  else if (command === null || command === void 0 ? void 0 : command.interaction) {
185
- if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
195
+ if (!this.config.commands.interactionCommand.replyOnError)
186
196
  return;
187
- yield command.interaction.followUp(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
197
+ yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch((e) => this.logger.error(e));
188
198
  }
189
199
  });
190
200
  }
@@ -1,4 +1,8 @@
1
1
  import { ClientOptions, PermissionFlags, PermissionString } from 'discord.js';
2
+ export interface ConfigCommandPermissions {
3
+ command: string;
4
+ permissions: (PermissionFlags | PermissionString)[];
5
+ }
2
6
  export interface Config {
3
7
  token: string;
4
8
  prefix: string;
@@ -19,17 +23,11 @@ export interface Config {
19
23
  permissions: {
20
24
  messageCommands: {
21
25
  enabled: boolean;
22
- commands: {
23
- command: string;
24
- permissions: (PermissionFlags | PermissionString)[];
25
- }[];
26
+ commands: ConfigCommandPermissions[];
26
27
  };
27
28
  interactionCommands: {
28
29
  enabled: boolean;
29
- commands: {
30
- command: string;
31
- permissions: (PermissionFlags | PermissionString)[];
32
- }[];
30
+ commands: ConfigCommandPermissions[];
33
31
  };
34
32
  };
35
33
  ignoredChannels: {
@@ -45,7 +43,7 @@ export interface Config {
45
43
  };
46
44
  client: ClientOptions;
47
45
  messages: {
48
- [key: string]: any;
46
+ [messageKey: string]: any;
49
47
  };
50
48
  ignoredFiles: string[];
51
49
  modulesFolder: string;
@@ -5,14 +5,17 @@ import { RecipleClient } from '../Client';
5
5
  export declare type CommandMessage = Command;
6
6
  export interface RecipleMessageCommandExecute {
7
7
  message: Message;
8
+ options: MessageCommandValidatedOption[];
8
9
  command: CommandMessage;
9
10
  builder: MessageCommandBuilder;
10
11
  client: RecipleClient;
11
12
  }
12
13
  export interface MessageCommandValidatedOption {
13
14
  name: string;
14
- value: string;
15
+ value: string | undefined;
15
16
  required: boolean;
17
+ invalid: boolean;
18
+ missing: boolean;
16
19
  }
17
20
  export declare class MessageCommandBuilder {
18
21
  readonly builder: string;
@@ -32,5 +35,5 @@ export declare class MessageCommandBuilder {
32
35
  setExecute(execute: (options: RecipleMessageCommandExecute) => void): MessageCommandBuilder;
33
36
  addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
34
37
  setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
35
- getCommandOptionValues(options: CommandMessage): undefined | MessageCommandValidatedOption[];
38
+ getCommandOptionValues(options: CommandMessage): MessageCommandValidatedOption[];
36
39
  }
@@ -71,17 +71,31 @@ class MessageCommandBuilder {
71
71
  const args = options.args || [];
72
72
  const required = this.options.filter(o => o.required);
73
73
  const optional = this.options.filter(o => !o.required);
74
- if (required.length > args.length)
75
- return;
76
- let i = 0;
74
+ const allOptions = [...required, ...optional];
77
75
  let result = [];
78
- for (const option of [...required, ...optional]) {
76
+ let i = 0;
77
+ for (const option of allOptions) {
79
78
  const arg = args[i];
80
- if (!arg && option.required)
81
- return;
82
- if (typeof arg !== 'undefined' && !option.validate(arg))
83
- return;
84
- result = [...result, { name: option.name, value: arg, required: option.required }];
79
+ const value = {
80
+ name: option.name,
81
+ value: arg !== null && arg !== void 0 ? arg : undefined,
82
+ required: option.required,
83
+ invalid: false,
84
+ missing: false
85
+ };
86
+ if (arg == undefined && option.required) {
87
+ value.missing = true;
88
+ result.push(value);
89
+ continue;
90
+ }
91
+ if (arg == undefined && !option.required) {
92
+ result.push(value);
93
+ continue;
94
+ }
95
+ const validate = option.validator ? option.validator(arg) : true;
96
+ if (!validate)
97
+ value.invalid = true;
98
+ result.push(value);
85
99
  i++;
86
100
  }
87
101
  return result;
@@ -2,7 +2,7 @@ export declare class MessageCommandOptionBuilder {
2
2
  name: string;
3
3
  description: string;
4
4
  required: boolean;
5
- validate: (value: string) => boolean;
5
+ validator: (value: string) => boolean;
6
6
  setName(name: string): MessageCommandOptionBuilder;
7
7
  setDescription(description: string): MessageCommandOptionBuilder;
8
8
  setRequired(required: boolean): MessageCommandOptionBuilder;
@@ -5,8 +5,8 @@ class MessageCommandOptionBuilder {
5
5
  constructor() {
6
6
  this.name = '';
7
7
  this.description = '';
8
- this.required = true;
9
- this.validate = () => true;
8
+ this.required = false;
9
+ this.validator = () => true;
10
10
  }
11
11
  setName(name) {
12
12
  if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
@@ -29,7 +29,7 @@ class MessageCommandOptionBuilder {
29
29
  setValidator(validator) {
30
30
  if (!validator || typeof validator !== 'function')
31
31
  throw new TypeError('validator must be a function.');
32
- this.validate = validator;
32
+ this.validator = validator;
33
33
  return this;
34
34
  }
35
35
  }
@@ -0,0 +1,4 @@
1
+ import { Permissions } from 'discord.js';
2
+ import { recipleCommandBuilders } from './modules';
3
+ import { Config } from './classes/Config';
4
+ export declare function hasPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: recipleCommandBuilders): boolean;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commandPermissions = void 0;
4
- function commandPermissions(commandName, memberPermissions, configConmmandPermissions, builder) {
3
+ exports.hasPermissions = void 0;
4
+ function hasPermissions(commandName, memberPermissions, configConmmandPermissions, builder) {
5
5
  var _a, _b;
6
6
  if (!(configConmmandPermissions === null || configConmmandPermissions === void 0 ? void 0 : configConmmandPermissions.enabled))
7
7
  return true;
@@ -10,4 +10,4 @@ function commandPermissions(commandName, memberPermissions, configConmmandPermis
10
10
  return true;
11
11
  return memberPermissions ? memberPermissions.has(command.permissions) : false;
12
12
  }
13
- exports.commandPermissions = commandPermissions;
13
+ exports.hasPermissions = hasPermissions;
@@ -18,14 +18,14 @@ const version_1 = require("./version");
18
18
  const wildcard_match_1 = __importDefault(require("wildcard-match"));
19
19
  const path_1 = __importDefault(require("path"));
20
20
  function loadModules(client) {
21
- var _a, _b, _c;
21
+ var _a;
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  const response = { commands: [], modules: [] };
24
- const modulesDir = ((_a = client.config) === null || _a === void 0 ? void 0 : _a.modulesFolder) || './modules';
24
+ const modulesDir = client.config.modulesFolder || './modules';
25
25
  const logger = client.logger;
26
26
  if (!(0, fs_1.existsSync)(modulesDir))
27
27
  (0, fs_1.mkdirSync)(modulesDir, { recursive: true });
28
- const ignoredFiles = (((_b = client.config) === null || _b === void 0 ? void 0 : _b.ignoredFiles) || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
28
+ const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
29
29
  const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
30
30
  return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
31
31
  });
@@ -36,7 +36,7 @@ function loadModules(client) {
36
36
  try {
37
37
  const reqMod = require(modulePath);
38
38
  module_ = !!(reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) ? reqMod.default : reqMod;
39
- if (!((_c = module_.versions) === null || _c === void 0 ? void 0 : _c.length))
39
+ if (!((_a = module_.versions) === null || _a === void 0 ? void 0 : _a.length))
40
40
  throw new Error('Module does not have supported versions.');
41
41
  const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
42
42
  if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
@@ -11,17 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerInteractionCommands = void 0;
13
13
  function registerInteractionCommands(client, cmds, overwriteGuilds) {
14
- var _a, _b, _c, _d;
14
+ var _a, _b, _c;
15
15
  return __awaiter(this, void 0, void 0, function* () {
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;
16
+ const commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
17
+ var _a, _b, _c, _d;
18
18
  if (typeof c.toJSON == 'undefined')
19
19
  return c;
20
20
  const cmd = c;
21
- 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)) {
22
- const permissions = (_g = (((_c = (_b = client.config) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.interactionCommands.enabled) ?
23
- (_f = (_e = (_d = client.config) === null || _d === void 0 ? void 0 : _d.permissions) === null || _e === void 0 ? void 0 : _e.interactionCommands.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
24
- undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
21
+ if ((cmd === null || cmd === void 0 ? void 0 : cmd.builder) === 'INTERACTION_COMMAND' && client.config.commands.interactionCommand.setRequiredPermissions) {
22
+ const permissions = (_d = (((_a = client.config.permissions) === null || _a === void 0 ? void 0 : _a.interactionCommands.enabled) ?
23
+ (_c = (_b = client.config.permissions) === null || _b === void 0 ? void 0 : _b.interactionCommands.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _c === void 0 ? void 0 : _c.permissions :
24
+ undefined)) !== null && _d !== void 0 ? _d : cmd.requiredPermissions;
25
25
  cmd.setRequiredPermissions(permissions);
26
26
  client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
27
27
  client.logger.debug(`Set required permissions for ${cmd.name} to ${permissions.join(', ')}`);
@@ -29,24 +29,20 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
29
29
  }
30
30
  return c.toJSON();
31
31
  })) !== null && _a !== void 0 ? _a : [];
32
- if (!commands || !commands.length) {
33
- client.logger.warn('No interaction commands found.');
34
- return;
35
- }
36
- const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : (_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds;
32
+ const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : client.config.commands.interactionCommand.guilds;
37
33
  const guilds = typeof configGuilds === 'object' ? configGuilds : [configGuilds];
38
34
  if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
39
- (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).then(() => {
35
+ (_b = client.application) === null || _b === void 0 ? void 0 : _b.commands.set(commands).then(() => {
40
36
  client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
41
37
  }).catch(e => client.logger.error(e));
42
38
  }
43
39
  else {
44
- client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
40
+ client.logger.warn(`Registering ${commands.length} interaction commands to ${guilds.length} guild(s).`);
45
41
  for (const guild of guilds) {
46
42
  if (!guild)
47
43
  continue;
48
- (_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).then(() => {
49
- client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
44
+ (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands, guild).then(() => {
45
+ client.logger.warn(`Registered ${commands.length} interaction command(s) for ${guild}.`);
50
46
  }).catch(e => client.logger.error(e));
51
47
  }
52
48
  }
@@ -1,5 +1,5 @@
1
1
  export declare const version: string;
2
- export declare function validVersion(ver: string): boolean;
2
+ export declare function isValidVersion(ver: string): boolean;
3
3
  export declare function parseVersion(ver: string): {
4
4
  major: number;
5
5
  minor: number;
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isSupportedVersion = exports.parseVersion = exports.validVersion = exports.version = void 0;
6
+ exports.isSupportedVersion = exports.parseVersion = exports.isValidVersion = exports.version = void 0;
7
7
  const semver_1 = __importDefault(require("semver"));
8
8
  exports.version = require('../../package.json').version;
9
- function validVersion(ver) {
9
+ function isValidVersion(ver) {
10
10
  return semver_1.default.valid(semver_1.default.coerce(ver)) !== null;
11
11
  }
12
- exports.validVersion = validVersion;
12
+ exports.isValidVersion = isValidVersion;
13
13
  function parseVersion(ver) {
14
14
  var _a, _b;
15
- if (!validVersion(ver))
15
+ if (!isValidVersion(ver))
16
16
  throw new TypeError(`Invalid version: ${ver}`);
17
17
  const [major, minor, patch] = (_b = (_a = `${semver_1.default.coerce(ver)}`) === null || _a === void 0 ? void 0 : _a.split('.')) !== null && _b !== void 0 ? _b : [];
18
18
  return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
@@ -20,9 +20,9 @@ function parseVersion(ver) {
20
20
  exports.parseVersion = parseVersion;
21
21
  function isSupportedVersion(versionRange, supportedVersion) {
22
22
  supportedVersion = supportedVersion || exports.version;
23
- if (!validVersion(versionRange))
23
+ if (!isValidVersion(versionRange))
24
24
  throw new TypeError(`Invalid version: ${versionRange}`);
25
- if (!validVersion(supportedVersion))
25
+ if (!isValidVersion(supportedVersion))
26
26
  throw new TypeError(`Invalid supported version: ${supportedVersion}`);
27
27
  return semver_1.default.satisfies(supportedVersion, versionRange);
28
28
  }
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
1
  {
2
- "name": "reciple",
3
- "version": "1.4.2",
4
- "description": "A Discord.js bot",
5
- "author": "FalloutStudios",
6
- "license": "GPL-3.0",
7
- "main": "bin/index.js",
8
- "bin": {
9
- "reciple": "bin/bin.js"
10
- },
11
- "files": [
12
- "bin",
13
- "resource",
14
- "package.json",
15
- "LICENSE",
16
- "README.md"
17
- ],
18
- "scripts": {
19
- "clean": "rimraf bin",
20
- "compile": "yarn clean && npx tsc",
21
- "build": "yarn compile && npm un reciple -g && npm i ./ -g",
22
- "build:publish": "yarn run build && yarn run changelog && yarn publish",
23
- "test": "cd test && npx reciple",
24
- "test:build": "yarn run build && yarn test:run"
25
- },
26
- "dependencies": {
27
- "commander": "^9.3.0",
28
- "discord.js": "^13.8.1",
29
- "dotenv": "^16.0.1",
30
- "fallout-utility": "^1.3.14",
31
- "semver": "^7.3.7",
32
- "wildcard-match": "^5.1.2",
33
- "yaml": "^2.1.1"
34
- },
35
- "devDependencies": {
36
- "@types/node": "^18.0.0",
37
- "@types/semver": "^7.3.10",
38
- "typescript": "^4.7.4"
39
- }
2
+ "name": "reciple",
3
+ "version": "1.5.2",
4
+ "description": "A Discord.js bot",
5
+ "author": "FalloutStudios",
6
+ "license": "GPL-3.0",
7
+ "main": "bin/index.js",
8
+ "bin": {
9
+ "reciple": "bin/bin.js"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "resource",
14
+ "package.json",
15
+ "LICENSE",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "clean": "rimraf bin",
20
+ "compile": "yarn clean && npx tsc",
21
+ "build": "yarn compile && npm un reciple -g && npm i ./ -g",
22
+ "build:publish": "yarn run build && yarn run changelog && yarn publish",
23
+ "test": "cd test && npx reciple",
24
+ "test:build": "yarn run build && yarn test:run"
25
+ },
26
+ "dependencies": {
27
+ "commander": "^9.3.0",
28
+ "discord.js": "^13.8.1",
29
+ "dotenv": "^16.0.1",
30
+ "fallout-utility": "^1.3.14",
31
+ "semver": "^7.3.7",
32
+ "wildcard-match": "^5.1.2",
33
+ "yaml": "^2.1.1"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^18.0.0",
37
+ "@types/semver": "^7.3.10",
38
+ "typescript": "^4.7.4"
39
+ }
40
40
  }
@@ -75,6 +75,7 @@ client:
75
75
  # Bot replies
76
76
  messages:
77
77
  notEnoughArguments: 'Not enough arguments.'
78
+ invalidArguments: 'Invalid argument(s) given.'
78
79
  noPermissions:
79
80
  content: 'You do not have permission to use this command.'
80
81
  ephemeral: true
@@ -1,4 +0,0 @@
1
- import { Permissions } from 'discord.js';
2
- import { recipleCommandBuilders } from './modules';
3
- import { Config } from './classes/Config';
4
- export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: recipleCommandBuilders): boolean;