reciple 6.0.0-dev.23 → 6.0.0-dev.26

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/lib/bin.mjs CHANGED
@@ -1,20 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import { RecipleClient } from './reciple/classes/RecipleClient.js';
3
3
  import { RecipleConfig } from './reciple/classes/RecipleConfig.js';
4
- import { rawVersion } from './reciple/version.js';
5
4
  import { existsSync, mkdirSync, readdirSync } from 'fs';
5
+ import { rawVersion } from './reciple/version.js';
6
6
  import { cwd, flags } from './reciple/flags.js';
7
- import { input } from 'fallout-utility';
8
7
  import { path } from './reciple/util.js';
8
+ import { input } from 'fallout-utility';
9
+ import match from 'micromatch';
10
+ import { inspect } from 'util';
9
11
  import chalk from 'chalk';
10
12
  import 'dotenv/config';
11
- import { inspect } from 'util';
12
- const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
13
+ import { Events } from 'discord.js';
14
+ const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', '.*'];
13
15
  const configPath = path.join(cwd, 'reciple.yml');
14
16
  if (!existsSync(cwd))
15
17
  mkdirSync(cwd, { recursive: true });
16
- if (readdirSync(cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !existsSync(flags.config ?? configPath)) {
17
- const ask = (flags.yes ? 'y' : null) ?? input('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ') ?? '';
18
+ if (readdirSync(cwd).some(f => match.isMatch(f, allowedFiles)) && !existsSync(flags.config ?? configPath)) {
19
+ const ask = (flags.yes ? 'y' : null) ?? input('Would you like to create Reciple config here? [y/n] ') ?? '';
18
20
  if (ask.toString().toLowerCase() !== 'y')
19
21
  process.exit(0);
20
22
  }
@@ -41,7 +43,7 @@ await client.modules.startModules({
41
43
  }),
42
44
  }),
43
45
  });
44
- client.on('ready', async () => {
46
+ client.on(Events.ClientReady, async () => {
45
47
  await client.modules.loadModules();
46
48
  const unloadModulesAndStopProcess = async (signal) => {
47
49
  await client.modules.unloadModules({ reason: 'ProcessExit' });
@@ -57,7 +59,7 @@ client.on('ready', async () => {
57
59
  }
58
60
  if (!client.isClientLogsSilent)
59
61
  client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
60
- client.on('cacheSweep', () => client.cooldowns.clean());
62
+ client.on(Events.CacheSweep, () => client.cooldowns.clean());
61
63
  });
62
64
  client.login(config.token).catch(err => {
63
65
  if (!client.isClientLogsSilent)
package/dist/lib/index.js CHANGED
@@ -18,17 +18,15 @@ __exportStar(require("./reciple/classes/builders/MessageCommandBuilder.js"), exp
18
18
  __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder.js"), exports);
19
19
  __exportStar(require("./reciple/classes/builders/SlashCommandBuilder.js"), exports);
20
20
  __exportStar(require("./reciple/classes/managers/ApplicationCommandManager.js"), exports);
21
- __exportStar(require("./reciple/classes/managers/CommandManager.js"), exports);
22
- __exportStar(require("./reciple/classes/managers/ModuleManager.js"), exports);
23
21
  __exportStar(require("./reciple/classes/managers/CommandCooldownManager.js"), exports);
22
+ __exportStar(require("./reciple/classes/managers/CommandManager.js"), exports);
24
23
  __exportStar(require("./reciple/classes/managers/MessageCommandOptionManager.js"), exports);
24
+ __exportStar(require("./reciple/classes/managers/ModuleManager.js"), exports);
25
25
  __exportStar(require("./reciple/classes/RecipleClient.js"), exports);
26
26
  __exportStar(require("./reciple/classes/RecipleConfig.js"), exports);
27
27
  __exportStar(require("./reciple/classes/RecipleModule.js"), exports);
28
28
  __exportStar(require("./reciple/types/builders.js"), exports);
29
29
  __exportStar(require("./reciple/types/commands.js"), exports);
30
- __exportStar(require("./reciple/types/builders.js"), exports);
31
- __exportStar(require("./reciple/types/builders.js"), exports);
32
30
  __exportStar(require("./reciple/flags"), exports);
33
31
  __exportStar(require("./reciple/permissions.js"), exports);
34
32
  __exportStar(require("./reciple/util.js"), exports);
@@ -1,22 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecipleClient = void 0;
3
+ exports.RecipleClient = exports.RecipleEvents = void 0;
4
4
  const discord_js_1 = require("discord.js");
5
5
  const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
6
6
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
7
7
  const commands_1 = require("../types/commands");
8
8
  const CommandCooldownManager_1 = require("./managers/CommandCooldownManager");
9
+ const builders_1 = require("../types/builders");
9
10
  const permissions_1 = require("../permissions");
10
11
  const MessageCommandOptionManager_1 = require("./managers/MessageCommandOptionManager");
11
12
  const ApplicationCommandManager_1 = require("./managers/ApplicationCommandManager");
12
13
  const CommandManager_1 = require("./managers/CommandManager");
13
- const builders_1 = require("../types/builders");
14
14
  const ModuleManager_1 = require("./managers/ModuleManager");
15
15
  const RecipleConfig_1 = require("./RecipleConfig");
16
16
  const fallout_utility_1 = require("fallout-utility");
17
17
  const util_1 = require("../util");
18
18
  const version_js_1 = require("../version.js");
19
19
  const flags_1 = require("../flags");
20
+ var RecipleEvents;
21
+ (function (RecipleEvents) {
22
+ RecipleEvents["RecipleCommandExecute"] = "recipleCommandExecute";
23
+ RecipleEvents["RecipleCommandHalt"] = "recipleCommandHalt";
24
+ RecipleEvents["RecipleRegisterApplicationCommands"] = "recipleRegisterApplicationCommands";
25
+ RecipleEvents["RecipleReplyError"] = "recipleReplyError";
26
+ RecipleEvents["CommandExecute"] = "recipleCommandExecute";
27
+ RecipleEvents["CommandHalt"] = "recipleCommandHalt";
28
+ RecipleEvents["RegisterApplicationCommands"] = "recipleRegisterApplicationCommands";
29
+ RecipleEvents["ReplyError"] = "recipleReplyError";
30
+ })(RecipleEvents = exports.RecipleEvents || (exports.RecipleEvents = {}));
20
31
  class RecipleClient extends discord_js_1.Client {
21
32
  /**
22
33
  * @param options Client options
@@ -46,11 +57,11 @@ class RecipleClient extends discord_js_1.Client {
46
57
  * Listed to command executions
47
58
  */
48
59
  addCommandListeners() {
49
- this.on('messageCreate', message => {
60
+ this.on(discord_js_1.Events.MessageCreate, message => {
50
61
  if (this.config.commands.messageCommand.enabled)
51
62
  this.messageCommandExecute(message);
52
63
  });
53
- this.on('interactionCreate', interaction => {
64
+ this.on(discord_js_1.Events.InteractionCreate, interaction => {
54
65
  if (this.config.commands.slashCommand.enabled)
55
66
  this.slashCommandExecute(interaction);
56
67
  });
@@ -226,7 +237,7 @@ class RecipleClient extends discord_js_1.Client {
226
237
  * @param error Received Error
227
238
  */
228
239
  _replyError(error) {
229
- this.emit('recipleReplyError', error);
240
+ this.emit(RecipleEvents.ReplyError, error);
230
241
  }
231
242
  async _haltCommand(command, haltData) {
232
243
  try {
@@ -235,7 +246,7 @@ class RecipleClient extends discord_js_1.Client {
235
246
  console.log(err);
236
247
  })
237
248
  : false) || false;
238
- this.emit('recipleCommandHalt', haltData);
249
+ this.emit(RecipleEvents.CommandHalt, haltData);
239
250
  return haltResolved;
240
251
  }
241
252
  catch (err) {
@@ -249,7 +260,7 @@ class RecipleClient extends discord_js_1.Client {
249
260
  async _executeCommand(command, executeData) {
250
261
  try {
251
262
  await Promise.resolve(command.type === builders_1.CommandType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
252
- .then(() => this.emit('recipleCommandExecute', executeData))
263
+ .then(() => this.emit(RecipleEvents.CommandExecute, executeData))
253
264
  .catch(async (err) => !(await this._haltCommand(command, {
254
265
  executeData: executeData,
255
266
  reason: commands_1.CommandHaltReason.Error,
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RecipleModule = void 0;
4
- const crypto_1 = require("crypto");
5
- const discord_js_1 = require("discord.js");
6
4
  const builders_1 = require("../types/builders");
7
- const util_1 = require("../util");
5
+ const discord_js_1 = require("discord.js");
8
6
  const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
9
7
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
8
+ const util_1 = require("../util");
9
+ const crypto_1 = require("crypto");
10
10
  class RecipleModule {
11
11
  constructor(options) {
12
12
  this.commands = [];
@@ -183,7 +183,7 @@ class MessageCommandBuilder {
183
183
  return this;
184
184
  }
185
185
  /**
186
- * Add options to command
186
+ * Add new command options
187
187
  * @param options Message options
188
188
  */
189
189
  addOptions(...options) {
@@ -200,7 +200,14 @@ class MessageCommandBuilder {
200
200
  return this;
201
201
  }
202
202
  /**
203
- * Replace options from command
203
+ * Add new command option
204
+ * @param option Message option
205
+ */
206
+ addOption(option) {
207
+ return this.addOptions(option);
208
+ }
209
+ /**
210
+ * Set options from command
204
211
  * @params options Message options
205
212
  */
206
213
  setOptions(...options) {
@@ -288,36 +295,13 @@ class MessageCommandBuilder {
288
295
  * @param builder Command builder
289
296
  * @param options Parsed command args
290
297
  */
291
- static async validateOptions(builder, options) {
292
- const args = options.args || [];
293
- const required = builder.options.filter(o => o.required);
294
- const optional = builder.options.filter(o => !o.required);
295
- const allOptions = [...required, ...optional];
298
+ static async validateOptions(builder, commandArgs) {
299
+ const args = Array.isArray(commandArgs) ? commandArgs : commandArgs.args || [];
300
+ const allOptions = [...(builder.options ?? []).filter(o => o.required), ...(builder.options ?? []).filter(o => !o.required)];
296
301
  const result = [];
297
- let i = 0;
298
- for (const option of allOptions) {
302
+ for (let i = 0; i < allOptions.length; i++) {
299
303
  const arg = args[i];
300
- const value = {
301
- name: option.name,
302
- value: arg ?? undefined,
303
- required: !!option.required,
304
- invalid: false,
305
- missing: false,
306
- };
307
- if (arg == undefined && option.required) {
308
- value.missing = true;
309
- result.push(value);
310
- continue;
311
- }
312
- if (arg == undefined && !option.required) {
313
- result.push(value);
314
- continue;
315
- }
316
- const validate = option.validator ? await Promise.resolve(option.validator(arg)) : true;
317
- if (!validate)
318
- value.invalid = true;
319
- result.push(value);
320
- i++;
304
+ result.push(await MessageCommandOptionBuilder_1.MessageCommandOptionBuilder.validateOption(allOptions[i], arg));
321
305
  }
322
306
  return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
323
307
  }
@@ -103,5 +103,24 @@ class MessageCommandOptionBuilder {
103
103
  static isMessageCommandOption(builder) {
104
104
  return builder instanceof MessageCommandOptionBuilder;
105
105
  }
106
+ static async validateOption(option, value) {
107
+ const validatedOption = {
108
+ name: option.name,
109
+ value,
110
+ required: !!option.required,
111
+ invalid: false,
112
+ missing: false,
113
+ };
114
+ if (value == undefined && option.required) {
115
+ validatedOption.missing = true;
116
+ return validatedOption;
117
+ }
118
+ if (value == undefined && !option.required)
119
+ return validatedOption;
120
+ const validate = option.validator !== undefined ? await Promise.resolve(option.validator(value ?? '')) : true;
121
+ if (!validate)
122
+ validatedOption.invalid = true;
123
+ return validatedOption;
124
+ }
106
125
  }
107
126
  exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
@@ -26,7 +26,6 @@ class CommandCooldownManager extends Array {
26
26
  if (!Object.keys(options).length)
27
27
  throw new TypeError('Provide atleast one option to remove cooldown data.');
28
28
  const removed = [];
29
- let i = 0;
30
29
  for (let i = 0; i < this.length; i++) {
31
30
  if (!CommandCooldownManager.checkOptions(options, this[i]))
32
31
  continue;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandManager = void 0;
4
- const discord_js_1 = require("discord.js");
5
4
  const builders_1 = require("../../types/builders");
5
+ const discord_js_1 = require("discord.js");
6
6
  const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
7
7
  const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
8
+ const RecipleClient_1 = require("../RecipleClient");
8
9
  class CommandManager {
9
10
  constructor(options) {
10
11
  this.slashCommands = new discord_js_1.Collection();
@@ -37,7 +38,7 @@ class CommandManager {
37
38
  case builders_1.CommandType.SlashCommand:
38
39
  return this.slashCommands.get(command);
39
40
  case builders_1.CommandType.MessageCommand:
40
- return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
41
+ return (this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined));
41
42
  default:
42
43
  throw new TypeError('Unknown command type');
43
44
  }
@@ -52,7 +53,7 @@ class CommandManager {
52
53
  if (!this.client.isClientLogsSilent)
53
54
  this.client.logger.log(`Regestering ${this.client.applicationCommands.size} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
54
55
  await this.client.applicationCommands.set([...this.client.applicationCommands.commands], guilds);
55
- this.client.emit('recipleRegisterApplicationCommands');
56
+ this.client.emit(RecipleClient_1.RecipleEvents.RegisterApplicationCommands);
56
57
  return this;
57
58
  }
58
59
  }
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ModuleManager = void 0;
7
4
  const discord_js_1 = require("discord.js");
8
5
  const fs_1 = require("fs");
9
- const util_1 = require("util");
10
- const wildcard_match_1 = __importDefault(require("wildcard-match"));
11
6
  const RecipleModule_1 = require("../RecipleModule");
12
- const util_2 = require("../../util");
7
+ const util_1 = require("../../util");
8
+ const util_2 = require("util");
9
+ const micromatch_1 = require("micromatch");
13
10
  class ModuleManager {
14
11
  constructor(options) {
15
12
  this.modules = new discord_js_1.Collection();
@@ -33,7 +30,7 @@ class ModuleManager {
33
30
  return false;
34
31
  });
35
32
  if (error)
36
- throw new Error(`An error occured while loading module '${module_}': \n${(0, util_1.inspect)(error)}`);
33
+ throw new Error(`An error occured while loading module '${module_}': \n${(0, util_2.inspect)(error)}`);
37
34
  if (!start) {
38
35
  if (!this.client.isClientLogsSilent)
39
36
  this.client.logger.error(`Module '${module_}' returned false onStart`);
@@ -115,8 +112,8 @@ class ModuleManager {
115
112
  const modules = [];
116
113
  for (const file of options.files) {
117
114
  try {
118
- const resolveFile = await import((util_2.path.isAbsolute(file) ? 'file://' : '') + file);
119
- let script = resolveFile instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile) ? resolveFile : resolveFile?.default?.default instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile?.default?.default) ? resolveFile.default.default : resolveFile?.default;
115
+ const resolveFile = await import((util_1.path.isAbsolute(file) ? 'file://' : '') + file);
116
+ const script = resolveFile instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile) ? resolveFile : resolveFile?.default?.default instanceof RecipleModule_1.RecipleModule || ModuleManager.validateScript(resolveFile?.default?.default) ? resolveFile.default.default : resolveFile?.default;
120
117
  if (script instanceof RecipleModule_1.RecipleModule) {
121
118
  modules.push(script);
122
119
  continue;
@@ -170,10 +167,10 @@ class ModuleManager {
170
167
  if (!(0, fs_1.lstatSync)(dir).isDirectory())
171
168
  continue;
172
169
  modules.push(...(0, fs_1.readdirSync)(dir)
173
- .map(file => util_2.path.join(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
170
+ .map(file => util_1.path.join(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
174
171
  .filter(file => (options?.filter ? options.filter(file) : file.endsWith('.js'))));
175
172
  }
176
- return modules.filter(file => !(options?.ignoredFiles ?? this.client.config.ignoredFiles).some(ignored => (0, wildcard_match_1.default)(ignored)(util_2.path.basename(file))));
173
+ return modules.filter(file => !(0, micromatch_1.isMatch)(util_1.path.basename(file), options?.ignoredFiles ?? this.client.config.ignoredFiles));
177
174
  }
178
175
  }
179
176
  exports.ModuleManager = ModuleManager;
@@ -18,7 +18,7 @@ exports.commander = new commander_1.Command()
18
18
  .option('-v, --version', 'Display version')
19
19
  .parse();
20
20
  /**
21
- * Used flags
21
+ * Used commander flags
22
22
  */
23
23
  exports.flags = exports.commander.opts();
24
24
  /**
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.path = exports.createLogger = exports.validateCommandBuilder = exports.deprecationWarning = exports.isClass = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
7
  const fallout_utility_1 = require("fallout-utility");
9
- const path_1 = __importDefault(require("path"));
10
- const flags_1 = require("./flags");
11
8
  const builders_1 = require("./types/builders");
9
+ const flags_1 = require("./flags");
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const path_1 = __importDefault(require("path"));
12
12
  /**
13
13
  * Check if an object is a class
14
14
  * @param object Object to identify
@@ -49,9 +49,7 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
49
49
  enableDebugMode: flags_1.flags.debugmode ?? debugmode,
50
50
  loggerName: 'Main',
51
51
  prefixes: {
52
- [fallout_utility_1.LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, {
53
- hour12: false,
54
- })}][${(name ? name + '/' : '') + 'INFO'}]`,
52
+ [fallout_utility_1.LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, { hour12: false })}][${(name ? name + '/' : '') + 'INFO'}]`,
55
53
  [fallout_utility_1.LogLevels.WARN]: (name) => `[${chalk_1.default.yellow(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.yellow((name ? name + '/' : '') + 'WARN')}]`,
56
54
  [fallout_utility_1.LogLevels.ERROR]: (name) => `[${chalk_1.default.red(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.red((name ? name + '/' : '') + 'ERROR')}]`,
57
55
  [fallout_utility_1.LogLevels.DEBUG]: (name) => `[${chalk_1.default.blue(new Date().toLocaleTimeString(undefined, { hour12: false }))}][${chalk_1.default.blue((name ? name + '/' : '') + 'DEBUG')}]`,
@@ -62,7 +60,12 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
62
60
  [fallout_utility_1.LogLevels.ERROR]: (message) => (!colorizeMessage ? message : chalk_1.default.red(message)),
63
61
  [fallout_utility_1.LogLevels.DEBUG]: (message) => (!colorizeMessage ? message : chalk_1.default.blue(message)),
64
62
  },
63
+ ObjectInspectDepth: 3,
64
+ ObjectInspectColorized: colorizeMessage,
65
65
  });
66
66
  }
67
67
  exports.createLogger = createLogger;
68
+ /**
69
+ * Path module that depending on os
70
+ */
68
71
  exports.path = (0, fallout_utility_1.getOperatingSystem)() === fallout_utility_1.OS.WINDOWS ? path_1.default.win32 : path_1.default.posix;
@@ -2,17 +2,15 @@ export * from './reciple/classes/builders/MessageCommandBuilder.js';
2
2
  export * from './reciple/classes/builders/MessageCommandOptionBuilder.js';
3
3
  export * from './reciple/classes/builders/SlashCommandBuilder.js';
4
4
  export * from './reciple/classes/managers/ApplicationCommandManager.js';
5
- export * from './reciple/classes/managers/CommandManager.js';
6
- export * from './reciple/classes/managers/ModuleManager.js';
7
5
  export * from './reciple/classes/managers/CommandCooldownManager.js';
6
+ export * from './reciple/classes/managers/CommandManager.js';
8
7
  export * from './reciple/classes/managers/MessageCommandOptionManager.js';
8
+ export * from './reciple/classes/managers/ModuleManager.js';
9
9
  export * from './reciple/classes/RecipleClient.js';
10
10
  export * from './reciple/classes/RecipleConfig.js';
11
11
  export * from './reciple/classes/RecipleModule.js';
12
12
  export * from './reciple/types/builders.js';
13
13
  export * from './reciple/types/commands.js';
14
- export * from './reciple/types/builders.js';
15
- export * from './reciple/types/builders.js';
16
14
  export * from './reciple/flags';
17
15
  export * from './reciple/permissions.js';
18
16
  export * from './reciple/util.js';
@@ -1,8 +1,9 @@
1
1
  import { Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
2
2
  import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandHaltData } from './builders/MessageCommandBuilder';
3
- import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandHaltData } from './builders/SlashCommandBuilder';
3
+ import { SlashCommandExecuteData, SlashCommandHaltData } from './builders/SlashCommandBuilder';
4
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
5
5
  import { CommandCooldownManager } from './managers/CommandCooldownManager';
6
+ import { AnySlashCommandBuilder } from '../types/builders';
6
7
  import { ApplicationCommandManager } from './managers/ApplicationCommandManager';
7
8
  import { CommandManager } from './managers/CommandManager';
8
9
  import { ModuleManager } from './managers/ModuleManager';
@@ -24,6 +25,16 @@ export interface RecipleClientEvents extends ClientEvents {
24
25
  recipleRegisterApplicationCommands: [];
25
26
  recipleReplyError: [error: unknown];
26
27
  }
28
+ export declare enum RecipleEvents {
29
+ RecipleCommandExecute = "recipleCommandExecute",
30
+ RecipleCommandHalt = "recipleCommandHalt",
31
+ RecipleRegisterApplicationCommands = "recipleRegisterApplicationCommands",
32
+ RecipleReplyError = "recipleReplyError",
33
+ CommandExecute = "recipleCommandExecute",
34
+ CommandHalt = "recipleCommandHalt",
35
+ RegisterApplicationCommands = "recipleRegisterApplicationCommands",
36
+ ReplyError = "recipleReplyError"
37
+ }
27
38
  /**
28
39
  * Reciple client
29
40
  */
@@ -85,14 +96,14 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
85
96
  * @param command Halted command's builder
86
97
  * @param haltData Halted command's data
87
98
  */
88
- protected _haltCommand(command: SlashCommandBuilder, haltData: SlashCommandHaltData): Promise<boolean>;
99
+ protected _haltCommand(command: AnySlashCommandBuilder, haltData: SlashCommandHaltData): Promise<boolean>;
89
100
  protected _haltCommand(command: MessageCommandBuilder, haltData: MessageCommandHaltData): Promise<boolean>;
90
101
  /**
91
102
  * Executes a command's {@link SharedCommandBuilderProperties["execute"]} method
92
103
  * @param command Command builder
93
104
  * @param executeData Command execute data
94
105
  */
95
- protected _executeCommand(command: SlashCommandBuilder, executeData: SlashCommandExecuteData): Promise<SlashCommandExecuteData | undefined>;
106
+ protected _executeCommand(command: AnySlashCommandBuilder, executeData: SlashCommandExecuteData): Promise<SlashCommandExecuteData | undefined>;
96
107
  protected _executeCommand(command: MessageCommandBuilder, executeData: MessageCommandExecuteData): Promise<MessageCommandExecuteData | undefined>;
97
108
  /**
98
109
  * Error message when a command fails to execute
@@ -1,5 +1,5 @@
1
- import { GuildResolvable, RestOrArray } from 'discord.js';
2
1
  import { AnyCommandBuilder, AnyCommandData } from '../types/builders';
2
+ import { GuildResolvable, RestOrArray } from 'discord.js';
3
3
  import { RecipleClient } from './RecipleClient';
4
4
  /**
5
5
  * Reciple script object
@@ -1,7 +1,7 @@
1
- import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData, MessageCommandOptionResolvable } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData, MessageCommandOptionResolvable, MessageCommandResolvable } from '../../types/builders';
2
2
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
3
- import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
4
3
  import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
4
+ import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
5
5
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
6
6
  import { Command } from 'fallout-utility';
7
7
  /**
@@ -136,12 +136,17 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
136
136
  */
137
137
  setAllowExecuteByBots(allowExecuteByBots: boolean): this;
138
138
  /**
139
- * Add options to command
139
+ * Add new command options
140
140
  * @param options Message options
141
141
  */
142
142
  addOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
143
143
  /**
144
- * Replace options from command
144
+ * Add new command option
145
+ * @param option Message option
146
+ */
147
+ addOption(option: MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): this;
148
+ /**
149
+ * Set options from command
145
150
  * @params options Message options
146
151
  */
147
152
  setOptions(...options: RestOrArray<MessageCommandOptionResolvable | ((builder: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)>): this;
@@ -180,5 +185,5 @@ export declare class MessageCommandBuilder<T = unknown> implements SharedCommand
180
185
  * @param builder Command builder
181
186
  * @param options Parsed command args
182
187
  */
183
- static validateOptions(builder: MessageCommandBuilder, options: Command): Promise<MessageCommandOptionManager>;
188
+ static validateOptions(builder: MessageCommandResolvable, commandArgs: Command | string[]): Promise<MessageCommandOptionManager>;
184
189
  }
@@ -1,5 +1,6 @@
1
1
  import { MessageCommandOptionData, MessageCommandOptionResolvable } from '../../types/builders';
2
2
  import { Awaitable } from 'discord.js';
3
+ import { MessageCommandValidatedOption } from './MessageCommandBuilder';
3
4
  /**
4
5
  * Option builder for MessageCommandBuilder
5
6
  */
@@ -48,4 +49,5 @@ export declare class MessageCommandOptionBuilder {
48
49
  * @param builder data to check
49
50
  */
50
51
  static isMessageCommandOption(builder: unknown): builder is MessageCommandOptionBuilder;
52
+ static validateOption(option: MessageCommandOptionResolvable, value?: string): Promise<MessageCommandValidatedOption>;
51
53
  }
@@ -1,13 +1,12 @@
1
+ import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandType, MessageCommandResolvable, SlashCommandResolvable } from '../../types/builders';
1
2
  import { ApplicationCommandData, Collection, GuildResolvable, RestOrArray } from 'discord.js';
2
- import { AnyCommandBuilder, AnyCommandData, AnySlashCommandBuilder, CommandType, MessageCommandData, SlashCommandData } from '../../types/builders';
3
3
  import { MessageCommandBuilder } from '../builders/MessageCommandBuilder';
4
- import { SlashCommandBuilder } from '../builders/SlashCommandBuilder';
5
- import { RecipleClient } from '../RecipleClient';
6
4
  import { ApplicationCommandBuilder } from './ApplicationCommandManager';
5
+ import { RecipleClient } from '../RecipleClient';
7
6
  export interface CommandManagerOptions {
8
7
  client: RecipleClient;
9
- messageCommands?: (MessageCommandBuilder | MessageCommandData)[];
10
- slashCommands?: (AnySlashCommandBuilder | SlashCommandData)[];
8
+ messageCommands?: MessageCommandResolvable[];
9
+ slashCommands?: SlashCommandResolvable[];
11
10
  }
12
11
  export declare class CommandManager {
13
12
  readonly client: RecipleClient;
@@ -25,9 +24,8 @@ export declare class CommandManager {
25
24
  * @param command Command name
26
25
  * @param type Command type
27
26
  */
28
- get(command: string, type?: undefined): AnyCommandBuilder | undefined;
29
- get(command: string, type?: CommandType.MessageCommand): MessageCommandBuilder | undefined;
30
- get(command: string, type?: CommandType.SlashCommand): SlashCommandBuilder | undefined;
27
+ get<T = unknown>(command: string, type: CommandType.SlashCommand): AnySlashCommandBuilder<T> | undefined;
28
+ get<T = unknown>(command: string, type: CommandType.MessageCommand): MessageCommandBuilder<T> | undefined;
31
29
  /**
32
30
  * Register application commands
33
31
  * @param guilds Register application commands to guilds
@@ -10,8 +10,8 @@ export declare class MessageCommandOptionManager extends Array<MessageCommandVal
10
10
  * @param name Option name
11
11
  * @param requied Is the option required
12
12
  */
13
- get(name: string, requied: true): MessageCommandValidatedOption;
14
13
  get(name: string, requied?: boolean): MessageCommandValidatedOption | null;
14
+ get(name: string, requied: true): MessageCommandValidatedOption;
15
15
  /**
16
16
  * Get the option value
17
17
  * @param name Option name
@@ -1,7 +1,7 @@
1
- import { Collection } from 'discord.js';
2
1
  import { ModuleManagerGetModulePathsOptions, ModuleManagerLoadModulesOptions, ModuleManagerResolveModuleFilesOptions, ModuleManagerStartModulesOptions, ModuleManagerUnloadModulesOptions } from '../../types/paramOptions';
3
- import { RecipleClient } from '../RecipleClient';
2
+ import { Collection } from 'discord.js';
4
3
  import { RecipleModule, RecipleScript } from '../RecipleModule';
4
+ import { RecipleClient } from '../RecipleClient';
5
5
  export interface ModuleManagerOptions {
6
6
  client: RecipleClient;
7
7
  modules?: (RecipleModule | RecipleScript)[];
@@ -4,7 +4,7 @@ import { Command } from 'commander';
4
4
  */
5
5
  export declare const commander: Command;
6
6
  /**
7
- * Used flags
7
+ * Used commander flags
8
8
  */
9
9
  export declare const flags: import("commander").OptionValues;
10
10
  /**
@@ -7,13 +7,9 @@ import { UserHasCommandPermissionsOptions } from './types/paramOptions';
7
7
  export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
8
8
  /**
9
9
  * Check if the bot has the required permissions in a guild
10
- * @param guild Check if the bot has the required permissions in this guild
10
+ * @param guildOrChannel Check if the bot has the required permissions in this guild or channel
11
11
  * @param requiredPermissions Required guild bot permissions
12
12
  */
13
+ export declare function botHasExecutePermissions(guildOrChannel?: Guild | GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
13
14
  export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
14
- /**
15
- * Check if the bot has the required permissions in a channel
16
- * @param channel Check if the bot has the required permissions in this channel
17
- * @param requiredPermissions Required guild bot permissions
18
- */
19
15
  export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
@@ -1,7 +1,7 @@
1
- import { ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionType, Awaitable, LocalizationMap, PermissionResolvable, RestOrArray, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption } from 'discord.js';
2
1
  import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder } from '../classes/builders/SlashCommandBuilder';
3
2
  import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecuteFunction, MessageCommandHaltData, MessageCommandHaltFunction } from '../classes/builders/MessageCommandBuilder';
4
3
  import { MessageCommandOptionBuilder } from '../classes/builders/MessageCommandOptionBuilder';
4
+ import { ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionType, Awaitable, LocalizationMap, PermissionResolvable, RestOrArray, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption } from 'discord.js';
5
5
  /**
6
6
  * Any command builders
7
7
  */
@@ -31,7 +31,15 @@ export declare type CommandHaltFunction<T extends CommandType, M = unknown> = (h
31
31
  */
32
32
  export declare type CommandExecuteFunction<T extends CommandType, M = unknown> = (executeData: T extends CommandType.SlashCommand ? SlashCommandExecuteData<M> : T extends CommandType.MessageCommand ? MessageCommandExecuteData<M> : SlashCommandExecuteData<M> | MessageCommandExecuteData<M>) => Awaitable<void>;
33
33
  /**
34
- * Message command options resolvable
34
+ * Slash command options resolvable
35
+ */
36
+ export declare type SlashCommandResolvable<T = unknown, OptionsOnly = unknown> = OptionsOnly extends true ? SlashCommandOptionsOnlyBuilder<T> : OptionsOnly extends false ? SlashCommandSubcommandsOnlyBuilder<T> : AnySlashCommandBuilder<T> | SlashCommandData<T>;
37
+ /**
38
+ * Message command resolvable
39
+ */
40
+ export declare type MessageCommandResolvable<T = unknown> = MessageCommandBuilder<T> | MessageCommandData<T>;
41
+ /**
42
+ * Message command option resolvable
35
43
  */
36
44
  export declare type MessageCommandOptionResolvable = MessageCommandOptionBuilder | MessageCommandOptionData;
37
45
  /**
@@ -1,7 +1,7 @@
1
1
  import { ConfigCommandPermissions } from '../classes/RecipleConfig';
2
2
  import { Awaitable, PermissionsBitField } from 'discord.js';
3
- import { AnyCommandBuilder } from './builders';
4
3
  import { RecipleModule } from '../classes/RecipleModule';
4
+ import { AnyCommandBuilder } from './builders';
5
5
  export interface UserHasCommandPermissionsOptions {
6
6
  /**
7
7
  * Command builder
@@ -1,18 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import { Logger } from 'fallout-utility';
3
- import { default as _path } from 'path';
4
3
  import { AnyCommandBuilder } from './types/builders';
4
+ import _path from 'path';
5
5
  /**
6
6
  * Check if an object is a class
7
7
  * @param object Object to identify
8
8
  */
9
- export declare function isClass<T = any>(object: any): object is T;
9
+ export declare function isClass<T>(object: any): object is T;
10
10
  /**
11
11
  * Emit process warning about deprecated method/function
12
12
  * @param content Warning content
13
13
  */
14
14
  export declare function deprecationWarning(content: string | Error): void;
15
- export declare function validateCommandBuilder(command: AnyCommandBuilder): boolean;
15
+ export declare function validateCommandBuilder(command: AnyCommandBuilder): command is AnyCommandBuilder;
16
16
  /**
17
17
  * Create new logger
18
18
  * @param stringifyJSON stringify json objects in console
@@ -20,4 +20,7 @@ export declare function validateCommandBuilder(command: AnyCommandBuilder): bool
20
20
  * @param colorizeMessage add logger colours to messages
21
21
  */
22
22
  export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
23
+ /**
24
+ * Path module that depending on os
25
+ */
23
26
  export declare const path: _path.PlatformPath;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "6.0.0-dev.23",
4
- "bin": "./dist/lib/bin.mjs",
5
3
  "license": "GPL-3.0",
6
- "type": "commonjs",
4
+ "version": "6.0.0-dev.26",
5
+ "bin": "./dist/lib/bin.mjs",
6
+ "author": "FalloutStudios",
7
7
  "main": "./dist/lib/index.js",
8
- "types": "./dist/types/index.d.ts",
9
8
  "module": "./dist/lib/esm.mjs",
10
- "author": "FalloutStudios",
9
+ "types": "./dist/types/index.d.ts",
11
10
  "description": "Handler for Discord.js",
12
11
  "homepage": "https://reciple.js.org",
12
+ "engineStrict": true,
13
+ "type": "commonjs",
13
14
  "exports": {
14
15
  ".": {
15
16
  "import": {
@@ -33,6 +34,18 @@
33
34
  "bugs": {
34
35
  "url": "https://github.com/FalloutStudios/reciple/issues"
35
36
  },
37
+ "engines": {
38
+ "node": ">=16.9.0"
39
+ },
40
+ "workspaces": [
41
+ "test"
42
+ ],
43
+ "files": [
44
+ "dist",
45
+ "resource",
46
+ "LICENSE",
47
+ "README.md"
48
+ ],
36
49
  "scripts": {
37
50
  "format": "npx prettier --write src",
38
51
  "clean": "npx rimraf dist",
@@ -47,27 +60,18 @@
47
60
  "type": "git",
48
61
  "url": "git+https://github.com/FalloutStudios/reciple.git"
49
62
  },
50
- "engineStrict": true,
51
- "engines": {
52
- "node": ">=16.9.0"
53
- },
54
- "files": [
55
- "dist",
56
- "resource",
57
- "LICENSE",
58
- "README.md"
59
- ],
60
63
  "dependencies": {
61
64
  "chalk": "4.1.2",
62
65
  "commander": "^9.4.1",
63
66
  "dotenv": "^16.0.3",
64
- "fallout-utility": "^1.5.13",
67
+ "fallout-utility": "^1.5.15",
68
+ "micromatch": "^4.0.5",
65
69
  "semver": "^7.3.7",
66
- "wildcard-match": "^5.1.2",
67
70
  "yaml": "^2.1.1"
68
71
  },
69
72
  "devDependencies": {
70
73
  "@discordjs/docgen": "^0.12.1",
74
+ "@types/micromatch": "^4.0.2",
71
75
  "@types/node": "^18.11.7",
72
76
  "@types/semver": "^7.3.13",
73
77
  "discord.js": "^14.6.0",
@@ -77,8 +81,5 @@
77
81
  },
78
82
  "peerDependencies": {
79
83
  "discord.js": "^14.5.0"
80
- },
81
- "workspaces": [
82
- "test"
83
- ]
84
+ }
84
85
  }