reciple 6.0.0-dev.1 → 6.0.0-dev.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/dist/cjs/bin.js CHANGED
@@ -30,21 +30,21 @@ catch (err) {
30
30
  }
31
31
  const config = configParser.getConfig();
32
32
  const client = new RecipleClient_1.RecipleClient({ config: config, ...config.client });
33
- if (config.fileLogging.clientLogs)
33
+ if (!client.isClientLogsSilent)
34
34
  client.logger.info('Starting Reciple client v' + version_1.rawVersion);
35
35
  (async () => {
36
36
  client.addCommandListeners();
37
37
  await client.modules.startModulesFromFiles({
38
- files: await client.modules.getModuleFiles()
38
+ files: await client.modules.getModuleFiles(),
39
39
  });
40
40
  client.on('ready', async () => {
41
41
  await client.modules.loadAll(true);
42
- if (client.isClientLogsEnabled())
42
+ if (!client.isClientLogsSilent)
43
43
  client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
44
44
  client.on('cacheSweep', () => client.cooldowns.clean());
45
45
  });
46
46
  client.login(config.token).catch(err => {
47
- if (client.isClientLogsEnabled())
47
+ if (!client.isClientLogsSilent)
48
48
  client.logger.error(err);
49
49
  });
50
50
  })();
package/dist/cjs/index.js CHANGED
@@ -20,6 +20,7 @@ __exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports)
20
20
  __exportStar(require("./reciple/classes/managers/ApplicationCommandManager"), exports);
21
21
  __exportStar(require("./reciple/classes/managers/CommandCooldownManager"), exports);
22
22
  __exportStar(require("./reciple/classes/managers/ClientCommandManager"), exports);
23
+ __exportStar(require("./reciple/classes/managers/ClientModuleManager"), exports);
23
24
  __exportStar(require("./reciple/classes/managers/MessageCommandOptionManager"), exports);
24
25
  __exportStar(require("./reciple/classes/RecipleClient"), exports);
25
26
  __exportStar(require("./reciple/classes/RecipleConfig"), exports);
@@ -28,7 +29,6 @@ __exportStar(require("./reciple/types/commands"), exports);
28
29
  __exportStar(require("./reciple/types/paramOptions"), exports);
29
30
  __exportStar(require("./reciple/flags"), exports);
30
31
  __exportStar(require("./reciple/logger"), exports);
31
- __exportStar(require("./reciple/modules"), exports);
32
32
  __exportStar(require("./reciple/permissions"), exports);
33
33
  __exportStar(require("./reciple/util"), exports);
34
34
  __exportStar(require("./reciple/version"), exports);
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RecipleClient = void 0;
7
7
  const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
8
+ const discord_js_1 = require("discord.js");
8
9
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
9
10
  const commands_1 = require("../types/commands");
10
11
  const CommandCooldownManager_1 = require("./managers/CommandCooldownManager");
@@ -13,14 +14,13 @@ const MessageCommandOptionManager_1 = require("./managers/MessageCommandOptionMa
13
14
  const ApplicationCommandManager_1 = require("./managers/ApplicationCommandManager");
14
15
  const builders_1 = require("../types/builders");
15
16
  const ClientCommandManager_1 = require("./managers/ClientCommandManager");
17
+ const ClientModuleManager_1 = require("./managers/ClientModuleManager");
16
18
  const RecipleConfig_1 = require("./RecipleConfig");
17
19
  const fallout_utility_1 = require("fallout-utility");
18
20
  const logger_1 = require("../logger");
19
21
  const version_1 = require("../version");
20
22
  const flags_1 = require("../flags");
21
23
  const path_1 = __importDefault(require("path"));
22
- const discord_js_1 = require("discord.js");
23
- const ClientModuleManager_1 = require("./managers/ClientModuleManager");
24
24
  class RecipleClient extends discord_js_1.Client {
25
25
  /**
26
26
  * @param options Client options
@@ -28,9 +28,13 @@ class RecipleClient extends discord_js_1.Client {
28
28
  constructor(options) {
29
29
  super(options);
30
30
  this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
31
- this.commands = new ClientCommandManager_1.ClientCommandManager({ client: this });
31
+ this.commands = new ClientCommandManager_1.ClientCommandManager({
32
+ client: this,
33
+ });
32
34
  this.cooldowns = new CommandCooldownManager_1.CommandCooldownManager();
33
- this.modules = new ClientModuleManager_1.ClientModuleManager({ client: this });
35
+ this.modules = new ClientModuleManager_1.ClientModuleManager({
36
+ client: this,
37
+ });
34
38
  this.version = version_1.version;
35
39
  this.logger = (0, logger_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
36
40
  this.config = { ...this.config, ...(options.config ?? {}) };
@@ -38,15 +42,18 @@ class RecipleClient extends discord_js_1.Client {
38
42
  this.logger.logFile(path_1.default.join(flags_1.cwd, this.config.fileLogging.logFilePath ?? 'logs/latest.log'), false);
39
43
  this.applicationCommands = new ApplicationCommandManager_1.ApplicationCommandManager(this);
40
44
  }
45
+ get isClientLogsSilent() {
46
+ return !this.config.fileLogging.clientLogs;
47
+ }
41
48
  /**
42
49
  * Listed to command executions
43
50
  */
44
51
  addCommandListeners() {
45
- this.on('messageCreate', (message) => {
52
+ this.on('messageCreate', message => {
46
53
  if (this.config.commands.messageCommand.enabled)
47
54
  this.messageCommandExecute(message);
48
55
  });
49
- this.on('interactionCreate', (interaction) => {
56
+ this.on('interactionCreate', interaction => {
50
57
  if (this.config.commands.slashCommand.enabled)
51
58
  this.slashCommandExecute(interaction);
52
59
  });
@@ -67,17 +74,20 @@ class RecipleClient extends discord_js_1.Client {
67
74
  const executeData = {
68
75
  interaction,
69
76
  builder: command,
70
- client: this
77
+ client: this,
71
78
  };
72
79
  if ((0, permissions_1.userHasCommandPermissions)({
73
80
  builder: command,
74
81
  memberPermissions: interaction.memberPermissions ?? undefined,
75
- commandPermissions: this.config.commands.slashCommand.permissions
82
+ commandPermissions: this.config.commands.slashCommand.permissions,
76
83
  })) {
77
84
  if (!command)
78
85
  return;
79
86
  if (interaction.inCachedGuild() && !(0, permissions_1.botHasExecutePermissions)(interaction.channel || interaction.guild, command.requiredBotPermissions)) {
80
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingBotPermissions })) {
87
+ if (!(await this._haltCommand(command, {
88
+ executeData,
89
+ reason: commands_1.CommandHaltReason.MissingBotPermissions,
90
+ }))) {
81
91
  await interaction.reply(this.getConfigMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
82
92
  }
83
93
  return;
@@ -87,20 +97,30 @@ class RecipleClient extends discord_js_1.Client {
87
97
  command: command.name,
88
98
  channel: interaction.channel ?? undefined,
89
99
  guild: interaction.guild,
90
- type: builders_1.CommandBuilderType.SlashCommand
100
+ type: builders_1.CommandBuilderType.SlashCommand,
91
101
  };
92
102
  if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
93
- this.cooldowns.add({ ...userCooldown, expireTime: Date.now() + command.cooldown });
103
+ this.cooldowns.add({
104
+ ...userCooldown,
105
+ expireTime: Date.now() + command.cooldown,
106
+ });
94
107
  }
95
108
  else if (this.config.commands.slashCommand.enableCooldown && command.cooldown) {
96
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.Cooldown, ...this.cooldowns.get(userCooldown) })) {
109
+ if (!(await this._haltCommand(command, {
110
+ executeData,
111
+ reason: commands_1.CommandHaltReason.Cooldown,
112
+ ...this.cooldowns.get(userCooldown),
113
+ }))) {
97
114
  await interaction.reply(this.getConfigMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
98
115
  }
99
116
  return;
100
117
  }
101
118
  return this._executeCommand(command, executeData);
102
119
  }
103
- else if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingMemberPermissions })) {
120
+ else if (!(await this._haltCommand(command, {
121
+ executeData,
122
+ reason: commands_1.CommandHaltReason.MissingMemberPermissions,
123
+ }))) {
104
124
  await interaction.reply(this.getConfigMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
105
125
  }
106
126
  }
@@ -124,31 +144,42 @@ class RecipleClient extends discord_js_1.Client {
124
144
  options: commandOptions,
125
145
  command: parseCommand,
126
146
  builder: command,
127
- client: this
147
+ client: this,
128
148
  };
129
149
  if ((0, permissions_1.userHasCommandPermissions)({
130
150
  builder: command,
131
151
  memberPermissions: message.member?.permissions,
132
- commandPermissions: this.config.commands.messageCommand.permissions
152
+ commandPermissions: this.config.commands.messageCommand.permissions,
133
153
  })) {
134
- if (!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM || !command.allowExecuteByBots && (message.author.bot || message.author.system))
154
+ if ((!command.allowExecuteInDM && message.channel.type === discord_js_1.ChannelType.DM) || (!command.allowExecuteByBots && (message.author.bot || message.author.system)))
135
155
  return;
136
156
  if (command.validateOptions) {
137
157
  if (commandOptions.some(o => o.invalid)) {
138
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.invalid)) })) {
158
+ if (!(await this._haltCommand(command, {
159
+ executeData,
160
+ reason: commands_1.CommandHaltReason.InvalidArguments,
161
+ invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.invalid)),
162
+ }))) {
139
163
  message.reply(this.getConfigMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this._replyError(er));
140
164
  }
141
165
  return;
142
166
  }
143
167
  if (commandOptions.some(o => o.missing)) {
144
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.missing)) })) {
168
+ if (!(await this._haltCommand(command, {
169
+ executeData,
170
+ reason: commands_1.CommandHaltReason.MissingArguments,
171
+ missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.missing)),
172
+ }))) {
145
173
  message.reply(this.getConfigMessage('missingArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
146
174
  }
147
175
  return;
148
176
  }
149
177
  }
150
178
  if (message.inGuild() && !(0, permissions_1.botHasExecutePermissions)(message.channel || message.guild, command.requiredBotPermissions)) {
151
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingBotPermissions })) {
179
+ if (!(await this._haltCommand(command, {
180
+ executeData,
181
+ reason: commands_1.CommandHaltReason.MissingBotPermissions,
182
+ }))) {
152
183
  message.reply(this.getConfigMessage('insufficientBotPerms', 'Insufficient bot permissions.')).catch(er => this._replyError(er));
153
184
  }
154
185
  return;
@@ -158,20 +189,30 @@ class RecipleClient extends discord_js_1.Client {
158
189
  command: command.name,
159
190
  channel: message.channel,
160
191
  guild: message.guild,
161
- type: builders_1.CommandBuilderType.MessageCommand
192
+ type: builders_1.CommandBuilderType.MessageCommand,
162
193
  };
163
194
  if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
164
- this.cooldowns.add({ ...userCooldown, expireTime: Date.now() + command.cooldown });
195
+ this.cooldowns.add({
196
+ ...userCooldown,
197
+ expireTime: Date.now() + command.cooldown,
198
+ });
165
199
  }
166
200
  else if (this.config.commands.messageCommand.enableCooldown && command.cooldown) {
167
- if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.Cooldown, ...this.cooldowns.get(userCooldown) })) {
201
+ if (!(await this._haltCommand(command, {
202
+ executeData,
203
+ reason: commands_1.CommandHaltReason.Cooldown,
204
+ ...this.cooldowns.get(userCooldown),
205
+ }))) {
168
206
  await message.reply(this.getConfigMessage('cooldown', 'You cannot execute this command right now due to the cooldown.')).catch(er => this._replyError(er));
169
207
  }
170
208
  return;
171
209
  }
172
210
  return this._executeCommand(command, executeData);
173
211
  }
174
- else if (!await this._haltCommand(command, { executeData, reason: commands_1.CommandHaltReason.MissingMemberPermissions })) {
212
+ else if (!(await this._haltCommand(command, {
213
+ executeData,
214
+ reason: commands_1.CommandHaltReason.MissingMemberPermissions,
215
+ }))) {
175
216
  message.reply(this.getConfigMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this._replyError(er));
176
217
  }
177
218
  }
@@ -183,12 +224,6 @@ class RecipleClient extends discord_js_1.Client {
183
224
  getConfigMessage(messageKey, defaultMessage) {
184
225
  return this.config.messages[messageKey] ?? defaultMessage ?? messageKey;
185
226
  }
186
- /**
187
- * Returns true if client logs is enabled
188
- */
189
- isClientLogsEnabled() {
190
- return !!this.config.fileLogging.clientLogs;
191
- }
192
227
  /**
193
228
  * Emits the {@link RecipleClientEvents["recipleReplyError"]} event
194
229
  * @param error Received Error
@@ -199,15 +234,15 @@ class RecipleClient extends discord_js_1.Client {
199
234
  async _haltCommand(command, haltData) {
200
235
  try {
201
236
  const haltResolved = (command.halt
202
- ? await Promise.resolve(command.type == builders_1.CommandBuilderType.SlashCommand
203
- ? command.halt(haltData)
204
- : command.halt(haltData)).catch(err => { console.log(err); })
237
+ ? await Promise.resolve(command.type == builders_1.CommandBuilderType.SlashCommand ? command.halt(haltData) : command.halt(haltData)).catch(err => {
238
+ console.log(err);
239
+ })
205
240
  : false) || false;
206
241
  this.emit('recipleCommandHalt', haltData);
207
242
  return haltResolved;
208
243
  }
209
244
  catch (err) {
210
- if (this.isClientLogsEnabled()) {
245
+ if (!this.isClientLogsSilent) {
211
246
  this.logger.error(`An error occured executing command halt for "${command.name}"`);
212
247
  this.logger.error(err);
213
248
  }
@@ -216,17 +251,23 @@ class RecipleClient extends discord_js_1.Client {
216
251
  }
217
252
  async _executeCommand(command, executeData) {
218
253
  try {
219
- await Promise.resolve(command.type === builders_1.CommandBuilderType.SlashCommand
220
- ? command.execute(executeData)
221
- : command.execute(executeData))
254
+ await Promise.resolve(command.type === builders_1.CommandBuilderType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
222
255
  .then(() => this.emit('recipleCommandExecute', executeData))
223
- .catch(async (err) => !await this._haltCommand(command, { executeData: executeData, reason: commands_1.CommandHaltReason.Error, error: err })
256
+ .catch(async (err) => !(await this._haltCommand(command, {
257
+ executeData: executeData,
258
+ reason: commands_1.CommandHaltReason.Error,
259
+ error: err,
260
+ }))
224
261
  ? this._commandExecuteError(err, executeData)
225
262
  : void 0);
226
263
  return executeData;
227
264
  }
228
265
  catch (err) {
229
- if (await this._haltCommand(command, { executeData: executeData, reason: commands_1.CommandHaltReason.Error, error: err }))
266
+ if (await this._haltCommand(command, {
267
+ executeData: executeData,
268
+ reason: commands_1.CommandHaltReason.Error,
269
+ error: err,
270
+ }))
230
271
  return;
231
272
  await this._commandExecuteError(err, executeData);
232
273
  }
@@ -237,7 +278,7 @@ class RecipleClient extends discord_js_1.Client {
237
278
  * @param command Slash/Message command execute data
238
279
  */
239
280
  async _commandExecuteError(err, command) {
240
- if (this.isClientLogsEnabled()) {
281
+ if (!this.isClientLogsSilent) {
241
282
  this.logger.error(`An error occured executing ${command.builder.type == builders_1.CommandBuilderType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
242
283
  this.logger.error(err);
243
284
  }
@@ -84,14 +84,21 @@ class RecipleConfig {
84
84
  * Ask for a token
85
85
  */
86
86
  _askToken() {
87
- return flags_1.token || (0, fallout_utility_1.input)({ text: 'Bot Token >>> ', echo: '*', repeatIfEmpty: true, sigint: true }) || null;
87
+ return (flags_1.token ||
88
+ (0, fallout_utility_1.input)({
89
+ text: 'Bot Token >>> ',
90
+ echo: '*',
91
+ repeatIfEmpty: true,
92
+ sigint: true,
93
+ }) ||
94
+ null);
88
95
  }
89
96
  /**
90
97
  * Get default config
91
98
  */
92
99
  static getDefaultConfig() {
93
100
  if (!(0, fs_1.existsSync)(this.defaultConfigPath))
94
- throw new Error("Default config file does not exists.");
101
+ throw new Error('Default config file does not exists.');
95
102
  return yaml_1.default.parse((0, fs_1.readFileSync)(this.defaultConfigPath, 'utf-8'));
96
103
  }
97
104
  }
@@ -21,7 +21,9 @@ class MessageCommandBuilder {
21
21
  this.requiredMemberPermissions = [];
22
22
  this.allowExecuteInDM = true;
23
23
  this.allowExecuteByBots = false;
24
- this.execute = () => { };
24
+ this.execute = () => {
25
+ /* Execute */
26
+ };
25
27
  if (data?.name !== undefined)
26
28
  this.setName(data.name);
27
29
  if (data?.description !== undefined)
@@ -47,7 +49,7 @@ class MessageCommandBuilder {
47
49
  if (data?.validateOptions !== undefined)
48
50
  this.setValidateOptions(true);
49
51
  if (data?.options !== undefined)
50
- this.options = data.options.map(o => o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o));
52
+ this.options = data.options.map(o => (o instanceof MessageCommandOptionBuilder_1.MessageCommandOptionBuilder ? o : new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder(o)));
51
53
  }
52
54
  /**
53
55
  * Sets the command name
@@ -218,7 +220,7 @@ async function validateMessageCommandOptions(builder, options) {
218
220
  value: arg ?? undefined,
219
221
  required: option.required,
220
222
  invalid: false,
221
- missing: false
223
+ missing: false,
222
224
  };
223
225
  if (arg == undefined && option.required) {
224
226
  value.missing = true;
@@ -14,7 +14,9 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
14
14
  this.cooldown = 0;
15
15
  this.requiredBotPermissions = [];
16
16
  this.requiredMemberPermissions = [];
17
- this.execute = () => { };
17
+ this.execute = () => {
18
+ /* Execute */
19
+ };
18
20
  // TODO: WTH
19
21
  if (data?.name !== undefined)
20
22
  this.setName(data.name);
@@ -58,9 +60,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
58
60
  }
59
61
  setRequiredMemberPermissions(...permissions) {
60
62
  this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
61
- this.setDefaultMemberPermissions(this.requiredMemberPermissions.length
62
- ? new discord_js_1.PermissionsBitField(this.requiredMemberPermissions).bitfield
63
- : undefined);
63
+ this.setDefaultMemberPermissions(this.requiredMemberPermissions.length ? new discord_js_1.PermissionsBitField(this.requiredMemberPermissions).bitfield : undefined);
64
64
  return this;
65
65
  }
66
66
  setHalt(halt) {
@@ -135,13 +135,10 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
135
135
  builder = new discord_js_1.SlashCommandBooleanOption();
136
136
  break;
137
137
  case discord_js_1.ApplicationCommandOptionType.Channel:
138
- builder = new discord_js_1.SlashCommandChannelOption()
139
- .addChannelTypes(...(option.channelTypes ?? []));
138
+ builder = new discord_js_1.SlashCommandChannelOption().addChannelTypes(...(option.channelTypes ?? []));
140
139
  break;
141
140
  case discord_js_1.ApplicationCommandOptionType.Integer:
142
- builder = new discord_js_1.SlashCommandIntegerOption()
143
- .addChoices(...(option.choices ?? []))
144
- .setAutocomplete(!!option.autocomplete);
141
+ builder = new discord_js_1.SlashCommandIntegerOption().addChoices(...(option.choices ?? [])).setAutocomplete(!!option.autocomplete);
145
142
  if (option.maxValue)
146
143
  builder.setMaxValue(option.maxValue);
147
144
  if (option.minValue)
@@ -151,9 +148,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
151
148
  builder = new discord_js_1.SlashCommandMentionableOption();
152
149
  break;
153
150
  case discord_js_1.ApplicationCommandOptionType.Number:
154
- builder = new discord_js_1.SlashCommandNumberOption()
155
- .addChoices(...(option.choices ?? []))
156
- .setAutocomplete(!!option.autocomplete);
151
+ builder = new discord_js_1.SlashCommandNumberOption().addChoices(...(option.choices ?? [])).setAutocomplete(!!option.autocomplete);
157
152
  if (option.maxValue)
158
153
  builder.setMaxValue(option.maxValue);
159
154
  if (option.minValue)
@@ -163,9 +158,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
163
158
  builder = new discord_js_1.SlashCommandRoleOption();
164
159
  break;
165
160
  case discord_js_1.ApplicationCommandOptionType.String:
166
- builder = new discord_js_1.SlashCommandStringOption()
167
- .addChoices(...(option.choices ?? []))
168
- .setAutocomplete(!!option.autocomplete);
161
+ builder = new discord_js_1.SlashCommandStringOption().addChoices(...(option.choices ?? [])).setAutocomplete(!!option.autocomplete);
169
162
  if (option.maxLength)
170
163
  builder.setMaxLength(option.maxLength);
171
164
  if (option.minLength)
@@ -183,17 +176,16 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
183
176
  case discord_js_1.ApplicationCommandOptionType.SubcommandGroup:
184
177
  builder = new discord_js_1.SlashCommandSubcommandGroupBuilder();
185
178
  for (const subCommandData of option.options) {
186
- builder.addSubcommand(subCommandData instanceof discord_js_1.SlashCommandSubcommandBuilder
187
- ? subCommandData
188
- : this.resolveOption(subCommandData));
179
+ builder.addSubcommand(subCommandData instanceof discord_js_1.SlashCommandSubcommandBuilder ? subCommandData : this.resolveOption(subCommandData));
189
180
  }
190
181
  break;
191
182
  default:
192
- throw new TypeError("Unknown option data");
183
+ throw new TypeError('Unknown option data');
193
184
  }
194
- if (!(builder instanceof discord_js_1.SlashCommandSubcommandBuilder) && !(builder instanceof discord_js_1.SlashCommandSubcommandGroupBuilder)
195
- &&
196
- option.type !== discord_js_1.ApplicationCommandOptionType.Subcommand && option.type !== discord_js_1.ApplicationCommandOptionType.SubcommandGroup) {
185
+ if (!(builder instanceof discord_js_1.SlashCommandSubcommandBuilder) &&
186
+ !(builder instanceof discord_js_1.SlashCommandSubcommandGroupBuilder) &&
187
+ option.type !== discord_js_1.ApplicationCommandOptionType.Subcommand &&
188
+ option.type !== discord_js_1.ApplicationCommandOptionType.SubcommandGroup) {
197
189
  builder.setRequired(option.required ?? false);
198
190
  }
199
191
  return builder
@@ -7,7 +7,9 @@ class ApplicationCommandManager {
7
7
  constructor(client) {
8
8
  this.client = client;
9
9
  }
10
- get commands() { return this.client.application?.commands; }
10
+ get commands() {
11
+ return this.client.application?.commands;
12
+ }
11
13
  async set(commands, guilds) {
12
14
  if (!this.client.isReady())
13
15
  throw new Error('Client is not ready');
@@ -21,12 +23,12 @@ class ApplicationCommandManager {
21
23
  guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
22
24
  if (!guild) {
23
25
  this.client.application.commands.set(commands);
24
- if (this.client.isClientLogsEnabled())
26
+ if (!this.client.isClientLogsSilent)
25
27
  this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) globally...`);
26
28
  }
27
29
  else {
28
30
  this.client.application.commands.set(commands, guild);
29
- if (this.client.isClientLogsEnabled())
31
+ if (!this.client.isClientLogsSilent)
30
32
  this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) to guild ${guild}...`);
31
33
  }
32
34
  }
@@ -45,12 +47,12 @@ class ApplicationCommandManager {
45
47
  guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
46
48
  if (!guild) {
47
49
  this.client.application.commands.create(command);
48
- if (this.client.isClientLogsEnabled())
50
+ if (!this.client.isClientLogsSilent)
49
51
  this.client.logger.log(`Created application command '${command.name}' globally`);
50
52
  }
51
53
  else {
52
54
  this.client.application.commands.create(command, guild);
53
- if (this.client.isClientLogsEnabled())
55
+ if (!this.client.isClientLogsSilent)
54
56
  this.client.logger.log(`Created application command '${command.name}' to guild ${guild}`);
55
57
  }
56
58
  }
@@ -69,12 +71,12 @@ class ApplicationCommandManager {
69
71
  guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
70
72
  if (!guild) {
71
73
  this.client.application.commands.delete(command);
72
- if (this.client.isClientLogsEnabled())
74
+ if (!this.client.isClientLogsSilent)
73
75
  this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
74
76
  }
75
77
  else {
76
78
  this.client.application.commands.delete(command, guild);
77
- if (this.client.isClientLogsEnabled())
79
+ if (!this.client.isClientLogsSilent)
78
80
  this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
79
81
  }
80
82
  }
@@ -93,12 +95,12 @@ class ApplicationCommandManager {
93
95
  guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
94
96
  if (!guild) {
95
97
  this.client.application.commands.edit(command, newCommand);
96
- if (this.client.isClientLogsEnabled())
98
+ if (!this.client.isClientLogsSilent)
97
99
  this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
98
100
  }
99
101
  else {
100
102
  this.client.application.commands.edit(command, newCommand, guild);
101
- if (this.client.isClientLogsEnabled())
103
+ if (!this.client.isClientLogsSilent)
102
104
  this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
103
105
  }
104
106
  }
@@ -106,9 +108,7 @@ class ApplicationCommandManager {
106
108
  const commands = guild ? this.client.guilds.resolve(guild)?.commands.cache : this.client.application?.commands.cache;
107
109
  if (!commands)
108
110
  throw new Error('Guild not found in cache');
109
- return commands.find(cmd => typeof command === 'string'
110
- ? (cmd.id === command || cmd.name === command)
111
- : (cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id)));
111
+ return commands.find(cmd => typeof command === 'string' ? cmd.id === command || cmd.name === command : cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id));
112
112
  }
113
113
  async fetch(commandId, guild) {
114
114
  const manager = guild ? this.client.guilds.resolve(guild)?.commands : this.client.application?.commands;
@@ -119,14 +119,14 @@ class ApplicationCommandManager {
119
119
  parseCommands(commands, setPermissions = true) {
120
120
  return commands.map(cmd => {
121
121
  if (cmd?.toJSON === undefined)
122
- return (cmd);
122
+ return cmd;
123
123
  if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && this.client.config.commands.slashCommand.setRequiredPermissions) {
124
- const permissions = (setPermissions || this.client.config.commands.slashCommand.permissions.enabled)
124
+ const permissions = setPermissions || this.client.config.commands.slashCommand.permissions.enabled
125
125
  ? this.client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions
126
126
  : undefined;
127
127
  if (permissions) {
128
128
  cmd.setRequiredMemberPermissions(...permissions);
129
- if (this.client.isClientLogsEnabled())
129
+ if (!this.client.isClientLogsSilent)
130
130
  this.client.logger.debug(`Set required permissions for ${cmd.name}`);
131
131
  }
132
132
  }
@@ -14,7 +14,9 @@ class ClientCommandManager {
14
14
  options.slashCommands?.forEach(e => this.slashCommands.set(e.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(e)));
15
15
  options.messageCommands?.forEach(e => this.messageCommands.set(e.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(e)));
16
16
  }
17
- get applicationCommandsSize() { return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length; }
17
+ get applicationCommandsSize() {
18
+ return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length;
19
+ }
18
20
  /**
19
21
  * Add command to command manager
20
22
  * @param commands Any command data or builder
@@ -35,10 +37,8 @@ class ClientCommandManager {
35
37
  case builders_1.CommandBuilderType.SlashCommand:
36
38
  return this.slashCommands.get(command);
37
39
  case builders_1.CommandBuilderType.MessageCommand:
38
- return this.messageCommands.get(command.toLowerCase())
39
- ?? (this.client.config.commands.messageCommand.allowCommandAlias
40
- ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase()))
41
- : undefined);
40
+ return (this.messageCommands.get(command.toLowerCase()) ??
41
+ (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined));
42
42
  default:
43
43
  throw new TypeError('Unknown command type');
44
44
  }
@@ -49,10 +49,8 @@ class ClientCommandManager {
49
49
  */
50
50
  async registerApplicationCommands(...guilds) {
51
51
  guilds = (0, discord_js_1.normalizeArray)(guilds);
52
- guilds = guilds.length
53
- ? guilds
54
- : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
55
- if (this.client.isClientLogsEnabled())
52
+ guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
53
+ if (!this.client.isClientLogsSilent)
56
54
  this.client.logger.log(`Regestering ${this.applicationCommandsSize} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
57
55
  await this.client.applicationCommands.set([...this.slashCommands.toJSON(), ...this.additionalApplicationCommands], guilds);
58
56
  this.client.emit('RegisterApplicationCommands');
@@ -57,7 +57,7 @@ class ClientModuleManager {
57
57
  catch (err) {
58
58
  if (options.dontSkipError)
59
59
  throw err;
60
- if (this.client.isClientLogsEnabled())
60
+ if (!this.client.isClientLogsSilent)
61
61
  this.client.logger.err(`Cannot start module ${ClientModuleManager.getModuleDisplayId(module_)}:`, err);
62
62
  }
63
63
  }
@@ -65,7 +65,7 @@ class ClientModuleManager {
65
65
  }
66
66
  async resolveModulesFromFiles(options) {
67
67
  const modules = [];
68
- const isVersionCheckDisabled = (options.disabeVersionCheck || this.client.config.disableVersionCheck);
68
+ const isVersionCheckDisabled = options.disabeVersionCheck || this.client.config.disableVersionCheck;
69
69
  for (const file of options.files) {
70
70
  const moduleFileName = path_1.default.basename(file);
71
71
  const moduleDirPath = path_1.default.dirname(file);
@@ -79,17 +79,17 @@ class ClientModuleManager {
79
79
  script,
80
80
  info: {
81
81
  filename: moduleFileName,
82
- path: moduleDirPath
83
- }
82
+ path: moduleDirPath,
83
+ },
84
84
  }, isVersionCheckDisabled);
85
85
  modules.push(module_);
86
- if (this.client.isClientLogsEnabled())
86
+ if (!this.client.isClientLogsSilent)
87
87
  this.client.logger.log(`Resolved ${file}`);
88
88
  }
89
89
  catch (err) {
90
90
  if (options.dontSkipError)
91
91
  throw err;
92
- if (this.client.isClientLogsEnabled())
92
+ if (!this.client.isClientLogsSilent)
93
93
  this.client.logger.err(`Cannot resolve module file ${file}:`, err);
94
94
  }
95
95
  }
@@ -114,7 +114,7 @@ class ClientModuleManager {
114
114
  throw new Error(`Module script commands contains a command builder without name or option name`);
115
115
  resolvedCommands.push({
116
116
  script,
117
- commands
117
+ commands,
118
118
  });
119
119
  }
120
120
  return resolvedCommands;
@@ -123,20 +123,22 @@ class ClientModuleManager {
123
123
  await Promise.all(this.modules.map(async (m) => {
124
124
  if (typeof m.script?.onLoad === 'function') {
125
125
  try {
126
- await Promise.resolve(m.script.onLoad(this.client)).catch(err => { throw err; });
126
+ await Promise.resolve(m.script.onLoad(this.client)).catch(err => {
127
+ throw err;
128
+ });
127
129
  }
128
130
  catch (err) {
129
131
  this.modules.delete(m.id);
130
- if (this.client.isClientLogsEnabled())
132
+ if (!this.client.isClientLogsSilent)
131
133
  this.client.logger.error(`Error loading ${m.info.filename ?? 'unknown module'}:`, err);
132
134
  return;
133
135
  }
134
136
  }
135
137
  this.client.commands.add(m.commands);
136
- if (this.client.isClientLogsEnabled())
138
+ if (!this.client.isClientLogsSilent)
137
139
  this.client.logger.log(`Loaded module: ${ClientModuleManager.getModuleDisplayId(m)}`);
138
140
  }));
139
- if (this.client.isClientLogsEnabled()) {
141
+ if (!this.client.isClientLogsSilent) {
140
142
  this.client.logger.info(`${this.modules.size} modules loaded.`);
141
143
  this.client.logger.info(`${this.client.commands.messageCommands.size} message commands loaded.`);
142
144
  this.client.logger.info(`${this.client.commands.slashCommands.size} slash commands loaded.`);
@@ -147,9 +149,9 @@ class ClientModuleManager {
147
149
  async startModule(mod) {
148
150
  let err;
149
151
  const identifier = ClientModuleManager.getModuleDisplayId(mod);
150
- if (this.client.isClientLogsEnabled())
152
+ if (!this.client.isClientLogsSilent)
151
153
  this.client.logger.log(`Starting Module: ${identifier}`);
152
- const start = await Promise.resolve(mod.script.onStart(this.client)).catch(e => err = e);
154
+ const start = await Promise.resolve(mod.script.onStart(this.client)).catch(e => (err = e));
153
155
  if (err)
154
156
  throw err;
155
157
  if (!start)
@@ -173,14 +175,16 @@ class ClientModuleManager {
173
175
  }
174
176
  async getModuleFiles(...folders) {
175
177
  const modules = [];
176
- for (const dir of ((0, discord_js_1.normalizeArray)(folders).length ? (0, discord_js_1.normalizeArray)(folders) : (0, discord_js_1.normalizeArray)([this.client.config.modulesFolder]))) {
178
+ for (const dir of (0, discord_js_1.normalizeArray)(folders).length ? (0, discord_js_1.normalizeArray)(folders) : (0, discord_js_1.normalizeArray)([this.client.config.modulesFolder])) {
177
179
  if (!(0, fs_1.existsSync)(dir))
178
180
  (0, fs_1.mkdirSync)(dir, { recursive: true });
179
181
  if (!(0, fs_1.lstatSync)(dir).isDirectory())
180
182
  continue;
181
- modules.push(...(0, fs_1.readdirSync)(dir).map(file => path_1.default.join(flags_1.cwd, dir, file)).filter(file => file.endsWith('.js') || file.endsWith('.cjs')));
183
+ modules.push(...(0, fs_1.readdirSync)(dir)
184
+ .map(file => path_1.default.join(flags_1.cwd, dir, file))
185
+ .filter(file => file.endsWith('.js') || file.endsWith('.cjs')));
182
186
  }
183
- return modules.filter(file => !this.client.config.ignoredFiles.some(ignored => (0, wildcard_match_1.default)(ignored, path_1.default.basename(file))));
187
+ return modules.filter(file => !this.client.config.ignoredFiles.some(ignored => (0, wildcard_match_1.default)(ignored)(path_1.default.basename(file))));
184
188
  }
185
189
  static getModuleDisplayId(mod) {
186
190
  return mod.info.path && mod.info.filename ? path_1.default.join(mod.info.path, mod.info.filename) : mod.id;
@@ -47,7 +47,13 @@ class CommandCooldownManager extends Array {
47
47
  const data = this.get(options);
48
48
  if (!data)
49
49
  return false;
50
- this.remove({ ...data, channel: undefined, guild: undefined, type: undefined, command: undefined });
50
+ this.remove({
51
+ ...data,
52
+ channel: undefined,
53
+ guild: undefined,
54
+ type: undefined,
55
+ command: undefined,
56
+ });
51
57
  if (data.expireTime < Date.now())
52
58
  return false;
53
59
  return true;
@@ -19,17 +19,19 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
19
19
  enableDebugMode: flags_1.flags.debugmode ?? debugmode,
20
20
  loggerName: 'Main',
21
21
  prefixes: {
22
- [fallout_utility_1.LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, { hour12: false })}][${(name ? name + "/" : '') + "INFO"}]`,
23
- [fallout_utility_1.LogLevels.WARN]: (name) => `[${chalk_1.default.yellow(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.yellow((name ? name + "/" : '') + "WARN")}]`,
24
- [fallout_utility_1.LogLevels.ERROR]: (name) => `[${chalk_1.default.red(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.red((name ? name + "/" : '') + "ERROR")}]`,
25
- [fallout_utility_1.LogLevels.DEBUG]: (name) => `[${chalk_1.default.blue(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.blue((name ? name + "/" : '') + "DEBUG")}]`
22
+ [fallout_utility_1.LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, {
23
+ hour12: false,
24
+ })}][${(name ? name + '/' : '') + 'INFO'}]`,
25
+ [fallout_utility_1.LogLevels.WARN]: (name) => `[${chalk_1.default.yellow(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.yellow((name ? name + '/' : '') + 'WARN')}]`,
26
+ [fallout_utility_1.LogLevels.ERROR]: (name) => `[${chalk_1.default.red(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.red((name ? name + '/' : '') + 'ERROR')}]`,
27
+ [fallout_utility_1.LogLevels.DEBUG]: (name) => `[${chalk_1.default.blue(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.blue((name ? name + '/' : '') + 'DEBUG')}]`,
26
28
  },
27
29
  colorMessages: {
28
30
  [fallout_utility_1.LogLevels.INFO]: (message) => message,
29
- [fallout_utility_1.LogLevels.WARN]: (message) => !colorizeMessage ? message : chalk_1.default.yellow(message),
30
- [fallout_utility_1.LogLevels.ERROR]: (message) => !colorizeMessage ? message : chalk_1.default.red(message),
31
- [fallout_utility_1.LogLevels.DEBUG]: (message) => !colorizeMessage ? message : chalk_1.default.blue(message)
32
- }
31
+ [fallout_utility_1.LogLevels.WARN]: (message) => (!colorizeMessage ? message : chalk_1.default.yellow(message)),
32
+ [fallout_utility_1.LogLevels.ERROR]: (message) => (!colorizeMessage ? message : chalk_1.default.red(message)),
33
+ [fallout_utility_1.LogLevels.DEBUG]: (message) => (!colorizeMessage ? message : chalk_1.default.blue(message)),
34
+ },
33
35
  });
34
36
  }
35
37
  exports.createLogger = createLogger;
@@ -7,10 +7,9 @@ const discord_js_1 = require("discord.js");
7
7
  * @param options options
8
8
  */
9
9
  function userHasCommandPermissions(options) {
10
- const command = (options.commandPermissions?.enabled
11
- ? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase())
12
- : null)
13
- ?? { permissions: options.builder.requiredMemberPermissions };
10
+ const command = (options.commandPermissions?.enabled ? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase()) : null) ?? {
11
+ permissions: options.builder.requiredMemberPermissions,
12
+ };
14
13
  if (!command.permissions.length)
15
14
  return true;
16
15
  return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
@@ -4,6 +4,7 @@ export * from './reciple/classes/builders/SlashCommandBuilder';
4
4
  export * from './reciple/classes/managers/ApplicationCommandManager';
5
5
  export * from './reciple/classes/managers/CommandCooldownManager';
6
6
  export * from './reciple/classes/managers/ClientCommandManager';
7
+ export * from './reciple/classes/managers/ClientModuleManager';
7
8
  export * from './reciple/classes/managers/MessageCommandOptionManager';
8
9
  export * from './reciple/classes/RecipleClient';
9
10
  export * from './reciple/classes/RecipleConfig';
@@ -12,7 +13,6 @@ export * from './reciple/types/commands';
12
13
  export * from './reciple/types/paramOptions';
13
14
  export * from './reciple/flags';
14
15
  export * from './reciple/logger';
15
- export * from './reciple/modules';
16
16
  export * from './reciple/permissions';
17
17
  export * from './reciple/util';
18
18
  export * from './reciple/version';
@@ -1,13 +1,13 @@
1
1
  import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandHaltData } from './builders/MessageCommandBuilder';
2
+ import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
2
3
  import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandHaltData } from './builders/SlashCommandBuilder';
3
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
4
5
  import { CommandCooldownManager } from './managers/CommandCooldownManager';
5
6
  import { ApplicationCommandManager } from './managers/ApplicationCommandManager';
6
7
  import { ClientCommandManager } from './managers/ClientCommandManager';
8
+ import { ClientModuleManager } from './managers/ClientModuleManager';
7
9
  import { Config } from './RecipleConfig';
8
10
  import { Logger } from 'fallout-utility';
9
- import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
10
- import { ClientModuleManager } from './managers/ClientModuleManager';
11
11
  /**
12
12
  * Options for {@link RecipleClient}
13
13
  */
@@ -47,6 +47,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
47
47
  readonly modules: ClientModuleManager;
48
48
  readonly logger: Logger;
49
49
  readonly version: string;
50
+ get isClientLogsSilent(): boolean;
50
51
  /**
51
52
  * @param options Client options
52
53
  */
@@ -72,10 +73,6 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
72
73
  * @param defaultMessage Default message when the key does not exists
73
74
  */
74
75
  getConfigMessage<T = unknown>(messageKey: string, defaultMessage?: T): T;
75
- /**
76
- * Returns true if client logs is enabled
77
- */
78
- isClientLogsEnabled(): boolean;
79
76
  /**
80
77
  * Emits the {@link RecipleClientEvents["recipleReplyError"]} event
81
78
  * @param error Received Error
@@ -80,7 +80,7 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
80
80
  halt?: MessageCommandHaltFunction<T>;
81
81
  execute: MessageCommandExecuteFunction<T>;
82
82
  metadata?: T;
83
- constructor(data?: Partial<Omit<MessageCommandData<T>, "type">>);
83
+ constructor(data?: Partial<Omit<MessageCommandData<T>, 'type'>>);
84
84
  /**
85
85
  * Sets the command name
86
86
  * @param name Command name
@@ -26,20 +26,20 @@ export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<
26
26
  * Slash command execute function
27
27
  */
28
28
  export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.SlashCommand, T>;
29
- export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addBooleanOption" | "addUserOption" | "addChannelOption" | "addRoleOption" | "addAttachmentOption" | "addMentionableOption" | "addStringOption" | "addIntegerOption" | "addNumberOption">;
30
- export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, "addSubcommand" | "addSubcommandGroup">;
29
+ export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addBooleanOption' | 'addUserOption' | 'addChannelOption' | 'addRoleOption' | 'addAttachmentOption' | 'addMentionableOption' | 'addStringOption' | 'addIntegerOption' | 'addNumberOption'>;
30
+ export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addSubcommand' | 'addSubcommandGroup'>;
31
31
  export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
32
32
  addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
33
33
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
34
- addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
35
- addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
36
- addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
37
- addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
38
- addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
39
- addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
40
- addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
41
- addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
42
- addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)): Omit<this, "addSubcommand" | "addSubcommandGroup">;
34
+ addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
35
+ addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
36
+ addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
37
+ addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
38
+ addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
39
+ addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
40
+ addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
41
+ addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
42
+ addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)): Omit<this, 'addSubcommand' | 'addSubcommandGroup'>;
43
43
  }
44
44
  /**
45
45
  * Reciple builder for slash command
@@ -52,7 +52,7 @@ export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashComm
52
52
  halt?: SlashCommandHaltFunction<T>;
53
53
  execute: SlashCommandExecuteFunction<T>;
54
54
  metadata?: T;
55
- constructor(data?: Partial<Omit<SlashCommandData<T>, "type">>);
55
+ constructor(data?: Partial<Omit<SlashCommandData<T>, 'type'>>);
56
56
  setCooldown(cooldown: number): this;
57
57
  setRequiredBotPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
58
58
  setRequiredMemberPermissions(...permissions: RestOrArray<PermissionResolvable>): this;
@@ -14,7 +14,7 @@ export declare class ApplicationCommandManager {
14
14
  add(command: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
15
15
  remove(command: string | ApplicationCommand, guilds?: GuildResolvable[]): Promise<void>;
16
16
  edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
17
- get(command: (ApplicationCommandData | ApplicationCommandBuilder | string), guild?: GuildResolvable): ApplicationCommand | undefined;
17
+ get(command: ApplicationCommandData | ApplicationCommandBuilder | string, guild?: GuildResolvable): ApplicationCommand | undefined;
18
18
  fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
19
19
  protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
20
20
  }
@@ -88,12 +88,12 @@ export interface SharedCommandBuilderProperties<T = unknown> {
88
88
  * Function when the command is interupted
89
89
  * @param halt Function to execute when command is halted
90
90
  */
91
- setHalt(halt?: this["halt"]): this;
91
+ setHalt(halt?: this['halt']): this;
92
92
  /**
93
93
  * Function when the command is executed
94
94
  * @param execute Function to execute when the command is called
95
95
  */
96
- setExecute(execute: this["execute"]): this;
96
+ setExecute(execute: this['execute']): this;
97
97
  /**
98
98
  * Set a command metadata
99
99
  * @param metadata Command metadata
@@ -110,7 +110,7 @@ export interface SharedCommandDataProperties {
110
110
  /**
111
111
  * Slash command object data interface
112
112
  */
113
- export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
113
+ export interface SlashCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
114
114
  type: CommandBuilderType.SlashCommand;
115
115
  nameLocalizations?: LocalizationMap;
116
116
  descriptionLocalizations?: LocalizationMap;
@@ -124,7 +124,7 @@ export interface SlashCommandData<T = unknown> extends SharedCommandDataProperti
124
124
  halt?: SlashCommandHaltFunction<T>;
125
125
  execute: SlashCommandExecuteFunction<T>;
126
126
  }
127
- export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
127
+ export interface SharedSlashCommandOptionData<V = string | number> extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
128
128
  choices?: {
129
129
  name: string;
130
130
  nameLocalizations?: LocalizationMap;
@@ -133,13 +133,13 @@ export interface SharedSlashCommandOptionData<V = string | number> extends Share
133
133
  autocomplete?: boolean;
134
134
  required?: boolean;
135
135
  }
136
- export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
136
+ export interface SlashCommandAttachmentOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
137
137
  type: ApplicationCommandOptionType.Attachment;
138
138
  }
139
- export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
139
+ export interface SlashCommandBooleanOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
140
140
  type: ApplicationCommandOptionType.Boolean;
141
141
  }
142
- export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
142
+ export interface SlashCommandChannelOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
143
143
  type: ApplicationCommandOptionType.Channel;
144
144
  channelTypes?: ApplicationCommandOptionAllowedChannelTypes[];
145
145
  }
@@ -148,7 +148,7 @@ export interface SlashCommandIntegerOptionData extends SharedSlashCommandOptionD
148
148
  minValue?: number;
149
149
  maxValue?: number;
150
150
  }
151
- export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
151
+ export interface SlashCommandMentionableOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
152
152
  type: ApplicationCommandOptionType.Mentionable;
153
153
  }
154
154
  export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionData<number> {
@@ -156,7 +156,7 @@ export interface SlashCommandNumberOptionData extends SharedSlashCommandOptionDa
156
156
  minValue?: number;
157
157
  maxValue?: number;
158
158
  }
159
- export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
159
+ export interface SlashCommandRoleOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
160
160
  type: ApplicationCommandOptionType.Role;
161
161
  }
162
162
  export interface SlashCommandStringOptionData extends SharedSlashCommandOptionData<string> {
@@ -164,21 +164,21 @@ export interface SlashCommandStringOptionData extends SharedSlashCommandOptionDa
164
164
  minLength?: number;
165
165
  maxLength?: number;
166
166
  }
167
- export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, "choices" | "autocomplete"> {
167
+ export interface SlashCommandUserOptionData extends Omit<SharedSlashCommandOptionData, 'choices' | 'autocomplete'> {
168
168
  type: ApplicationCommandOptionType.User;
169
169
  }
170
- export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
170
+ export interface SlashCommandSubCommandData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
171
171
  type: ApplicationCommandOptionType.Subcommand;
172
172
  options: (AnySlashCommandOptionsOnlyOptionData | AnySlashCommandOptionsOnlyOptionBuilder)[];
173
173
  }
174
- export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, "nameLocalizations" | "descriptionLocalizations"> {
174
+ export interface SlashCommandSubCommandGroupData extends SharedCommandDataProperties, Pick<SlashCommandData, 'nameLocalizations' | 'descriptionLocalizations'> {
175
175
  type: ApplicationCommandOptionType.SubcommandGroup;
176
176
  options: (SlashCommandSubCommandData | SlashCommandSubcommandBuilder)[];
177
177
  }
178
178
  /**
179
179
  * Message command object data interface
180
180
  */
181
- export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, "setCooldown" | "setRequiredBotPermissions" | "setRequiredMemberPermissions" | "setHalt" | "setExecute" | "setMetadata" | "halt" | "execute">> {
181
+ export interface MessageCommandData<T = unknown> extends SharedCommandDataProperties, Partial<Omit<SharedCommandBuilderProperties<T>, 'setCooldown' | 'setRequiredBotPermissions' | 'setRequiredMemberPermissions' | 'setHalt' | 'setExecute' | 'setMetadata' | 'halt' | 'execute'>> {
182
182
  type: CommandBuilderType.MessageCommand;
183
183
  aliases?: string[];
184
184
  validateOptions?: boolean;
@@ -1,5 +1,5 @@
1
+ import { RecipleModule, RecipleScript } from '../classes/managers/ClientModuleManager';
1
2
  import { ConfigCommandPermissions } from '../classes/RecipleConfig';
2
- import { RecipleModule, RecipleScript } from '../modules';
3
3
  import { PermissionsBitField } from 'discord.js';
4
4
  import { AnyCommandBuilder } from './builders';
5
5
  export interface RecipleClientAddModuleOptions {
@@ -14,7 +14,7 @@ export interface RecipleClientAddModuleOptions {
14
14
  /**
15
15
  * Module optional info
16
16
  */
17
- moduleInfo?: RecipleModule["info"];
17
+ moduleInfo?: RecipleModule['info'];
18
18
  }
19
19
  export interface UserHasCommandPermissionsOptions {
20
20
  /**
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "6.0.0-dev.1",
3
+ "version": "6.0.0-dev.3",
4
4
  "bin": "./dist/cjs/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/cjs/index.js",
7
- "typings": "./dist/types/index.d.ts",
7
+ "types": "./dist/types/index.d.ts",
8
8
  "module": "./dist/mjs/index.js",
9
9
  "author": "FalloutStudios",
10
10
  "description": "Handler for Discord.js",
11
11
  "homepage": "https://reciple.js.org",
12
12
  "exports": {
13
13
  "require": "./dist/cjs/index.js",
14
- "import": "./dist/mjs/index.js"
14
+ "import": "./dist/mjs/index.js",
15
+ "types": "./dist/types/index.d.ts"
15
16
  },
16
17
  "keywords": [
17
18
  "Discord",
@@ -25,8 +26,9 @@
25
26
  "url": "https://github.com/FalloutStudios/reciple/issues"
26
27
  },
27
28
  "scripts": {
29
+ "format": "yarn prettier --write src",
28
30
  "clean": "yarn exec rimraf dist",
29
- "build": "yarn clean && yarn exec tsc",
31
+ "build": "yarn clean && yarn format && yarn exec tsc",
30
32
  "build:publish": "yarn build && yarn docs && yarn npm publish",
31
33
  "build:publish-dev": "yarn build && yarn npm publish --tag dev",
32
34
  "test": "yarn build && yarn workspace test start",
@@ -61,6 +63,7 @@
61
63
  "@types/node": "^18.11.0",
62
64
  "@types/semver": "^7.3.12",
63
65
  "discord.js": "^14.6.0",
66
+ "prettier": "2.7.1",
64
67
  "rimraf": "^3.0.2",
65
68
  "typescript": "^4.8.4"
66
69
  },
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getModules = void 0;
30
- const builders_1 = require("./types/builders");
31
- const MessageCommandBuilder_1 = require("./classes/builders/MessageCommandBuilder");
32
- const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
33
- const discord_js_1 = require("discord.js");
34
- const version_1 = require("./version");
35
- const fs_1 = require("fs");
36
- const wildcard_match_1 = __importDefault(require("wildcard-match"));
37
- const flags_1 = require("./flags");
38
- const path_1 = __importDefault(require("path"));
39
- /**
40
- * Load modules from folder
41
- * @param client Reciple client
42
- * @param folder Modules folder
43
- */
44
- async function getModules(client, folder) {
45
- const response = { commands: [], modules: [] };
46
- const modulesDir = folder || path_1.default.join(flags_1.cwd, 'modules');
47
- if (!(0, fs_1.existsSync)(modulesDir))
48
- (0, fs_1.mkdirSync)(modulesDir, { recursive: true });
49
- const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
50
- const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
51
- return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
52
- });
53
- for (const script of scripts) {
54
- const modulePath = path_1.default.join(modulesDir, script);
55
- const commands = [];
56
- let module_;
57
- try {
58
- const reqMod = await Promise.resolve().then(() => __importStar(require(modulePath)));
59
- module_ = reqMod?.default !== undefined ? reqMod.default : reqMod;
60
- if (typeof module_ !== 'object')
61
- throw new Error(`Module ${modulePath} is not an object`);
62
- if (!client.config.disableVersionCheck && !module_?.versions?.length)
63
- throw new Error(`${modulePath} does not have supported versions.`);
64
- const versions = (0, discord_js_1.normalizeArray)([module_.versions]);
65
- if (!client.config.disableVersionCheck && !versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
66
- throw new Error(`${modulePath} is unsupported; current version: ${version_1.version}; module supported versions: ` + versions.join(', ') ?? 'none');
67
- if (!await Promise.resolve(module_.onStart(client)).catch(() => false))
68
- throw new Error(script + ' onStart returned false or undefined.');
69
- if (module_.commands) {
70
- for (const command of module_.commands) {
71
- if (command.type === builders_1.CommandBuilderType.MessageCommand) {
72
- commands.push(MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
73
- }
74
- else if (command.type === builders_1.CommandBuilderType.SlashCommand) {
75
- commands.push(SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
76
- }
77
- }
78
- }
79
- }
80
- catch (error) {
81
- if (client.isClientLogsEnabled()) {
82
- client.logger.error(`Failed to load module ${script}`);
83
- client.logger.error(error);
84
- }
85
- continue;
86
- }
87
- response.commands.push(...commands.filter((c) => {
88
- if (!c.name) {
89
- if (client.isClientLogsEnabled())
90
- client.logger.error(`A ${builders_1.CommandBuilderType[c.type]} command name is not defined in ${modulePath}`);
91
- return false;
92
- }
93
- if (c.type === builders_1.CommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
94
- if (client.isClientLogsEnabled())
95
- client.logger.error(`A ${builders_1.CommandBuilderType[c.type]} option name is not defined in ${modulePath}`);
96
- return false;
97
- }
98
- return true;
99
- }));
100
- response.modules.push({
101
- script: module_,
102
- info: {
103
- filename: script,
104
- versions: (0, discord_js_1.normalizeArray)([module_.versions]),
105
- path: modulePath
106
- }
107
- });
108
- if (client.isClientLogsEnabled())
109
- client.logger.info(`Loaded module ${modulePath}`);
110
- }
111
- return response;
112
- }
113
- exports.getModules = getModules;
@@ -1,64 +0,0 @@
1
- import { AnyCommandBuilder, AnyCommandData } from './types/builders';
2
- import { RecipleClient } from './classes/RecipleClient';
3
- /**
4
- * Loaded modules and commands
5
- */
6
- export interface LoadedModules {
7
- commands: AnyCommandBuilder[];
8
- modules: RecipleModule[];
9
- }
10
- /**
11
- * Reciple script object
12
- */
13
- export interface RecipleScript {
14
- /**
15
- * Supported reciple versions
16
- */
17
- versions: string | string[];
18
- /**
19
- * Module commands
20
- */
21
- commands?: (AnyCommandBuilder | AnyCommandData)[];
22
- /**
23
- * Action on bot ready
24
- * @param client Bot client
25
- */
26
- onLoad?(client: RecipleClient<true>): void | Promise<void>;
27
- /**
28
- * Action on module start
29
- * @param client Bot client
30
- */
31
- onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
32
- }
33
- /**
34
- * Reciple module object
35
- */
36
- export interface RecipleModule {
37
- /**
38
- * Module script
39
- */
40
- script: RecipleScript;
41
- /**
42
- * Module local information
43
- */
44
- info: {
45
- /**
46
- * Module file name
47
- */
48
- filename?: string;
49
- /**
50
- * Supported reciple versions
51
- */
52
- versions: string[];
53
- /**
54
- * Module local file path
55
- */
56
- path?: string;
57
- };
58
- }
59
- /**
60
- * Load modules from folder
61
- * @param client Reciple client
62
- * @param folder Modules folder
63
- */
64
- export declare function getModules(client: RecipleClient, folder?: string): Promise<LoadedModules>;