reciple 6.0.0-dev.2 → 6.0.0-dev.20

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.
Files changed (46) hide show
  1. package/dist/lib/bin.mjs +65 -0
  2. package/dist/lib/esm.mjs +1 -0
  3. package/dist/{cjs → lib}/index.js +18 -17
  4. package/dist/{cjs → lib}/reciple/classes/RecipleClient.js +17 -20
  5. package/dist/{cjs → lib}/reciple/classes/RecipleConfig.js +10 -10
  6. package/dist/lib/reciple/classes/RecipleModule.js +94 -0
  7. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandBuilder.js +1 -1
  8. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandOptionBuilder.js +0 -0
  9. package/dist/{cjs → lib}/reciple/classes/builders/SlashCommandBuilder.js +2 -5
  10. package/dist/{cjs → lib}/reciple/classes/managers/ApplicationCommandManager.js +64 -23
  11. package/dist/{cjs → lib}/reciple/classes/managers/CommandCooldownManager.js +0 -0
  12. package/dist/{cjs/reciple/classes/managers/ClientCommandManager.js → lib/reciple/classes/managers/CommandManager.js} +14 -15
  13. package/dist/{cjs → lib}/reciple/classes/managers/MessageCommandOptionManager.js +0 -0
  14. package/dist/lib/reciple/classes/managers/ModuleManager.js +179 -0
  15. package/dist/{cjs → lib}/reciple/flags.js +2 -2
  16. package/dist/{cjs → lib}/reciple/permissions.js +0 -0
  17. package/dist/lib/reciple/types/builders.js +11 -0
  18. package/dist/{cjs → lib}/reciple/types/commands.js +6 -6
  19. package/dist/{cjs → lib}/reciple/types/paramOptions.js +0 -0
  20. package/dist/{cjs/reciple/logger.js → lib/reciple/util.js} +33 -2
  21. package/dist/{cjs → lib}/reciple/version.js +0 -1
  22. package/dist/types/{bin.d.ts → bin.d.mts} +0 -0
  23. package/dist/types/esm.d.mts +1 -0
  24. package/dist/types/index.d.ts +18 -17
  25. package/dist/types/reciple/classes/RecipleClient.d.ts +6 -4
  26. package/dist/types/reciple/classes/RecipleConfig.d.ts +3 -2
  27. package/dist/types/reciple/classes/RecipleModule.d.ts +56 -0
  28. package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +5 -5
  29. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +5 -5
  30. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +43 -10
  31. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +2 -2
  32. package/dist/types/reciple/classes/managers/{ClientCommandManager.d.ts → CommandManager.d.ts} +6 -7
  33. package/dist/types/reciple/classes/managers/ModuleManager.d.ts +49 -0
  34. package/dist/types/reciple/types/builders.d.ts +8 -8
  35. package/dist/types/reciple/types/commands.d.ts +16 -16
  36. package/dist/types/reciple/types/paramOptions.d.ts +79 -18
  37. package/dist/types/reciple/util.d.ts +11 -0
  38. package/package.json +26 -19
  39. package/resource/reciple.yml +25 -22
  40. package/dist/cjs/bin.js +0 -50
  41. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +0 -193
  42. package/dist/cjs/reciple/types/builders.js +0 -11
  43. package/dist/cjs/reciple/util.js +0 -32
  44. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +0 -79
  45. package/dist/types/reciple/logger.d.ts +0 -8
  46. package/docs/README.md +0 -1
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientCommandManager = void 0;
3
+ exports.CommandManager = void 0;
4
4
  const discord_js_1 = require("discord.js");
5
5
  const builders_1 = require("../../types/builders");
6
6
  const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
7
7
  const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
8
- class ClientCommandManager {
8
+ class CommandManager {
9
9
  constructor(options) {
10
10
  this.slashCommands = new discord_js_1.Collection();
11
11
  this.messageCommands = new discord_js_1.Collection();
@@ -14,31 +14,30 @@ 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() {
18
- return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length;
19
- }
20
17
  /**
21
18
  * Add command to command manager
22
19
  * @param commands Any command data or builder
23
20
  */
24
21
  add(...commands) {
25
22
  for (const command of (0, discord_js_1.normalizeArray)(commands)) {
26
- if (command.type === builders_1.CommandBuilderType.SlashCommand) {
23
+ if (command.type === builders_1.CommandType.SlashCommand) {
27
24
  this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
28
25
  }
29
- else if (command.type === builders_1.CommandBuilderType.MessageCommand) {
26
+ else if (command.type === builders_1.CommandType.MessageCommand) {
30
27
  this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
31
28
  }
29
+ else {
30
+ throw new Error(`Unknown reciple command type`);
31
+ }
32
32
  }
33
33
  return this;
34
34
  }
35
35
  get(command, type) {
36
36
  switch (type) {
37
- case builders_1.CommandBuilderType.SlashCommand:
37
+ case builders_1.CommandType.SlashCommand:
38
38
  return this.slashCommands.get(command);
39
- case builders_1.CommandBuilderType.MessageCommand:
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));
39
+ 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);
42
41
  default:
43
42
  throw new TypeError('Unknown command type');
44
43
  }
@@ -51,10 +50,10 @@ class ClientCommandManager {
51
50
  guilds = (0, discord_js_1.normalizeArray)(guilds);
52
51
  guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
53
52
  if (!this.client.isClientLogsSilent)
54
- this.client.logger.log(`Regestering ${this.applicationCommandsSize} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
55
- await this.client.applicationCommands.set([...this.slashCommands.toJSON(), ...this.additionalApplicationCommands], guilds);
56
- this.client.emit('RegisterApplicationCommands');
53
+ this.client.logger.log(`Regestering ${this.client.applicationCommands.size} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
54
+ await this.client.applicationCommands.set([...this.client.applicationCommands.commands], guilds);
55
+ this.client.emit('recipleRegisterApplicationCommands');
57
56
  return this;
58
57
  }
59
58
  }
60
- exports.ClientCommandManager = ClientCommandManager;
59
+ exports.CommandManager = CommandManager;
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModuleManager = void 0;
7
+ const discord_js_1 = require("discord.js");
8
+ const fs_1 = require("fs");
9
+ const util_1 = require("util");
10
+ const wildcard_match_1 = __importDefault(require("wildcard-match"));
11
+ const RecipleModule_1 = require("../RecipleModule");
12
+ const util_2 = require("../../util");
13
+ class ModuleManager {
14
+ constructor(options) {
15
+ this.modules = new discord_js_1.Collection();
16
+ this.client = options.client;
17
+ options.modules?.forEach(m => (m instanceof RecipleModule_1.RecipleModule ? m : new RecipleModule_1.RecipleModule({ client: this.client, script: m })));
18
+ }
19
+ /**
20
+ * Start modules
21
+ * @param options start modules options
22
+ * @returns started modules
23
+ */
24
+ async startModules(options) {
25
+ const startedModules = [];
26
+ for (const module_ of options.modules) {
27
+ if (!this.client.isClientLogsSilent)
28
+ this.client.logger.log(`Starting module '${module_}'`);
29
+ try {
30
+ let error;
31
+ const start = await module_.start().catch(err => {
32
+ error = err;
33
+ return false;
34
+ });
35
+ if (error)
36
+ throw new Error(`An error occured while loading module '${module_}': \n${(0, util_1.inspect)(error)}`);
37
+ if (!start) {
38
+ if (!this.client.isClientLogsSilent)
39
+ this.client.logger.error(`Module '${module_}' returned false onStart`);
40
+ continue;
41
+ }
42
+ if (options.addToModulesCollection !== false)
43
+ this.modules.set(module_.id, module_);
44
+ startedModules.push(module_);
45
+ }
46
+ catch (err) {
47
+ if (options?.ignoreErrors === false)
48
+ throw err;
49
+ if (!this.client.isClientLogsSilent)
50
+ this.client.logger.error(`Failed to start module '${module_}': `, err);
51
+ }
52
+ }
53
+ return startedModules;
54
+ }
55
+ /**
56
+ * Load modules
57
+ * @param options load modules options
58
+ * @returns loaded modules
59
+ */
60
+ async loadModules(options) {
61
+ const loadedModules = [];
62
+ for (const module_ of options?.modules ?? this.modules.toJSON()) {
63
+ try {
64
+ await module_.load().catch(err => {
65
+ throw err;
66
+ });
67
+ if (options?.resolveCommands !== false) {
68
+ module_.resolveCommands();
69
+ this.client.commands.add(module_.commands);
70
+ }
71
+ loadedModules.push(module_);
72
+ if (!this.client.isClientLogsSilent)
73
+ this.client.logger.log(`Loaded module '${module_}'`);
74
+ }
75
+ catch (err) {
76
+ if (options?.ignoreErrors === false)
77
+ throw err;
78
+ if (!this.client.isClientLogsSilent)
79
+ this.client.logger.error(`Failed to load module '${module_}': `, err);
80
+ }
81
+ }
82
+ return loadedModules;
83
+ }
84
+ /**
85
+ * Unload modules
86
+ * @param options unload modules options
87
+ * @returns unloaded modules
88
+ */
89
+ async unloadModules(options) {
90
+ const unloadedModules = [];
91
+ for (const module_ of options?.modules ?? this.modules.toJSON()) {
92
+ try {
93
+ await module_.unload().catch(err => {
94
+ throw err;
95
+ });
96
+ unloadedModules.push(module_);
97
+ if (!this.client.isClientLogsSilent)
98
+ this.client.logger.log(`Unloaded module '${module_}'`);
99
+ }
100
+ catch (err) {
101
+ if (options?.ignoreErrors === false)
102
+ throw err;
103
+ if (!this.client.isClientLogsSilent)
104
+ this.client.logger.error(`Failed to unLoad module '${module_}': `, err);
105
+ }
106
+ }
107
+ return unloadedModules;
108
+ }
109
+ /**
110
+ * Resolve modules from file paths
111
+ * @param options resolve module files options
112
+ * @returns resolved modules
113
+ */
114
+ async resolveModuleFiles(options) {
115
+ const modules = [];
116
+ for (const file of options.files) {
117
+ 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;
120
+ if (script instanceof RecipleModule_1.RecipleModule) {
121
+ modules.push(script);
122
+ continue;
123
+ }
124
+ if (!ModuleManager.validateScript(script))
125
+ throw new Error(`Invalid module script: ${file}`);
126
+ modules.push(new RecipleModule_1.RecipleModule({
127
+ client: this.client,
128
+ script,
129
+ filePath: file,
130
+ }));
131
+ }
132
+ catch (err) {
133
+ if (options.ignoreErrors === false)
134
+ throw err;
135
+ if (!this.client.isClientLogsSilent)
136
+ this.client.logger.error(`Can't resolve module from: ${file}`, err);
137
+ }
138
+ }
139
+ return modules;
140
+ }
141
+ /**
142
+ * Validate module script
143
+ * @param script module script
144
+ * @returns `true` if script is valid
145
+ */
146
+ static validateScript(script) {
147
+ const s = script;
148
+ if (typeof s !== 'object')
149
+ return false;
150
+ if (typeof s.versions !== 'string' && !Array.isArray(s.versions))
151
+ return false;
152
+ if (typeof s.onStart !== 'function')
153
+ return false;
154
+ if (s.onLoad && typeof s.onLoad !== 'function')
155
+ return false;
156
+ if (s.onUnload && typeof s.onUnload !== 'function')
157
+ return false;
158
+ return true;
159
+ }
160
+ /**
161
+ * Get module file paths from folders
162
+ * @param options get module paths options
163
+ * @returns module paths
164
+ */
165
+ async getModulePaths(options) {
166
+ const modules = [];
167
+ for (const dir of options?.folders ?? (0, discord_js_1.normalizeArray)([this.client.config.modulesFolder])) {
168
+ if (!(0, fs_1.existsSync)(dir))
169
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
170
+ if (!(0, fs_1.lstatSync)(dir).isDirectory())
171
+ continue;
172
+ modules.push(...(0, fs_1.readdirSync)(dir)
173
+ .map(file => util_2.path.join(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
174
+ .filter(file => (options?.filter ? options.filter(file) : file.endsWith('.js'))));
175
+ }
176
+ return modules.filter(file => !(options?.ignoredFiles ?? this.client.config.ignoredFiles).some(ignored => (0, wildcard_match_1.default)(ignored)(util_2.path.basename(file))));
177
+ }
178
+ }
179
+ exports.ModuleManager = ModuleManager;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cwd = exports.token = exports.flags = exports.commander = void 0;
4
- const version_1 = require("./version");
4
+ const version_js_1 = require("./version.js");
5
5
  const commander_1 = require("commander");
6
6
  /**
7
7
  * Commander
@@ -9,7 +9,7 @@ const commander_1 = require("commander");
9
9
  exports.commander = new commander_1.Command()
10
10
  .name('reciple')
11
11
  .description('Reciple.js - Discord.js handler cli')
12
- .version(`v${version_1.rawVersion}`, '-v, --version')
12
+ .version(`v${version_js_1.rawVersion}`, '-v, --version')
13
13
  .argument('[current-working-directory]', 'Change the current working directory')
14
14
  .option('-t, --token <token>', 'Replace used bot token')
15
15
  .option('-c, --config <config>', 'Change path to config file')
File without changes
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandType = void 0;
4
+ /**
5
+ * Types of command builders
6
+ */
7
+ var CommandType;
8
+ (function (CommandType) {
9
+ CommandType[CommandType["SlashCommand"] = 1] = "SlashCommand";
10
+ CommandType[CommandType["MessageCommand"] = 2] = "MessageCommand";
11
+ })(CommandType = exports.CommandType || (exports.CommandType = {}));
@@ -6,10 +6,10 @@ exports.CommandHaltReason = void 0;
6
6
  */
7
7
  var CommandHaltReason;
8
8
  (function (CommandHaltReason) {
9
- CommandHaltReason[CommandHaltReason["Error"] = 0] = "Error";
10
- CommandHaltReason[CommandHaltReason["Cooldown"] = 1] = "Cooldown";
11
- CommandHaltReason[CommandHaltReason["InvalidArguments"] = 2] = "InvalidArguments";
12
- CommandHaltReason[CommandHaltReason["MissingArguments"] = 3] = "MissingArguments";
13
- CommandHaltReason[CommandHaltReason["MissingMemberPermissions"] = 4] = "MissingMemberPermissions";
14
- CommandHaltReason[CommandHaltReason["MissingBotPermissions"] = 5] = "MissingBotPermissions";
9
+ CommandHaltReason[CommandHaltReason["Error"] = 1] = "Error";
10
+ CommandHaltReason[CommandHaltReason["Cooldown"] = 2] = "Cooldown";
11
+ CommandHaltReason[CommandHaltReason["InvalidArguments"] = 3] = "InvalidArguments";
12
+ CommandHaltReason[CommandHaltReason["MissingArguments"] = 4] = "MissingArguments";
13
+ CommandHaltReason[CommandHaltReason["MissingMemberPermissions"] = 5] = "MissingMemberPermissions";
14
+ CommandHaltReason[CommandHaltReason["MissingBotPermissions"] = 6] = "MissingBotPermissions";
15
15
  })(CommandHaltReason = exports.CommandHaltReason || (exports.CommandHaltReason = {}));
File without changes
@@ -3,10 +3,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createLogger = void 0;
6
+ exports.path = exports.createLogger = exports.validateCommandBuilder = exports.deprecationWarning = exports.isClass = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
7
8
  const fallout_utility_1 = require("fallout-utility");
9
+ const path_1 = __importDefault(require("path"));
8
10
  const flags_1 = require("./flags");
9
- const chalk_1 = __importDefault(require("chalk"));
11
+ const builders_1 = require("./types/builders");
12
+ /**
13
+ * Check if an object is a class
14
+ * @param object Object to identify
15
+ */
16
+ function isClass(object) {
17
+ const isClassConstructor = object.constructor && object.constructor.toString().substring(0, 5) === 'class';
18
+ if (object.prototype === undefined)
19
+ return isClassConstructor;
20
+ const isPrototypeClassConstructor = object.prototype.constructor && object.prototype.constructor.toString && object.prototype.constructor.toString().substring(0, 5) === 'class';
21
+ return isClassConstructor || isPrototypeClassConstructor;
22
+ }
23
+ exports.isClass = isClass;
24
+ /**
25
+ * Emit process warning about deprecated method/function
26
+ * @param content Warning content
27
+ */
28
+ function deprecationWarning(content) {
29
+ process.emitWarning(content, 'DeprecationWarning');
30
+ }
31
+ exports.deprecationWarning = deprecationWarning;
32
+ function validateCommandBuilder(command) {
33
+ if (!command.name)
34
+ return false;
35
+ if (command.type === builders_1.CommandType.MessageCommand && command.options.length && command.options.some(o => !o.name))
36
+ return false;
37
+ return true;
38
+ }
39
+ exports.validateCommandBuilder = validateCommandBuilder;
10
40
  /**
11
41
  * Create new logger
12
42
  * @param stringifyJSON stringify json objects in console
@@ -35,3 +65,4 @@ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true)
35
65
  });
36
66
  }
37
67
  exports.createLogger = createLogger;
68
+ exports.path = (0, fallout_utility_1.getOperatingSystem)() === fallout_utility_1.OS.WINDOWS ? path_1.default.win32 : path_1.default.posix;
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isSupportedVersion = exports.parseVersion = exports.isValidVersion = exports.rawVersion = exports.version = void 0;
7
7
  const semver_1 = __importDefault(require("semver"));
8
- // TODO: ESM support
9
8
  /**
10
9
  * Current reciple version
11
10
  */
File without changes
@@ -0,0 +1 @@
1
+ export * from './index.js';
@@ -1,18 +1,19 @@
1
- export * from './reciple/classes/builders/MessageCommandBuilder';
2
- export * from './reciple/classes/builders/MessageCommandOptionBuilder';
3
- export * from './reciple/classes/builders/SlashCommandBuilder';
4
- export * from './reciple/classes/managers/ApplicationCommandManager';
5
- export * from './reciple/classes/managers/CommandCooldownManager';
6
- export * from './reciple/classes/managers/ClientCommandManager';
7
- export * from './reciple/classes/managers/ClientModuleManager';
8
- export * from './reciple/classes/managers/MessageCommandOptionManager';
9
- export * from './reciple/classes/RecipleClient';
10
- export * from './reciple/classes/RecipleConfig';
11
- export * from './reciple/types/builders';
12
- export * from './reciple/types/commands';
13
- export * from './reciple/types/paramOptions';
1
+ export * from './reciple/classes/builders/MessageCommandBuilder.js';
2
+ export * from './reciple/classes/builders/MessageCommandOptionBuilder.js';
3
+ export * from './reciple/classes/builders/SlashCommandBuilder.js';
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
+ export * from './reciple/classes/managers/CommandCooldownManager.js';
8
+ export * from './reciple/classes/managers/MessageCommandOptionManager.js';
9
+ export * from './reciple/classes/RecipleClient.js';
10
+ export * from './reciple/classes/RecipleConfig.js';
11
+ export * from './reciple/classes/RecipleModule.js';
12
+ export * from './reciple/types/builders.js';
13
+ export * from './reciple/types/commands.js';
14
+ export * from './reciple/types/builders.js';
15
+ export * from './reciple/types/builders.js';
14
16
  export * from './reciple/flags';
15
- export * from './reciple/logger';
16
- export * from './reciple/permissions';
17
- export * from './reciple/util';
18
- export * from './reciple/version';
17
+ export * from './reciple/permissions.js';
18
+ export * from './reciple/util.js';
19
+ export * from './reciple/version.js';
@@ -4,8 +4,8 @@ import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandHaltData } fr
4
4
  import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
5
5
  import { CommandCooldownManager } from './managers/CommandCooldownManager';
6
6
  import { ApplicationCommandManager } from './managers/ApplicationCommandManager';
7
- import { ClientCommandManager } from './managers/ClientCommandManager';
8
- import { ClientModuleManager } from './managers/ClientModuleManager';
7
+ import { CommandManager } from './managers/CommandManager';
8
+ import { ModuleManager } from './managers/ModuleManager';
9
9
  import { Config } from './RecipleConfig';
10
10
  import { Logger } from 'fallout-utility';
11
11
  /**
@@ -13,6 +13,7 @@ import { Logger } from 'fallout-utility';
13
13
  */
14
14
  export interface RecipleClientOptions extends ClientOptions {
15
15
  config?: Config;
16
+ cwd?: string;
16
17
  }
17
18
  /**
18
19
  * Reciple client events
@@ -41,10 +42,11 @@ export interface RecipleClient<Ready extends boolean = boolean> extends Client<R
41
42
  }
42
43
  export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
43
44
  readonly config: Config;
44
- readonly commands: ClientCommandManager;
45
+ readonly commands: CommandManager;
45
46
  readonly applicationCommands: ApplicationCommandManager;
46
47
  readonly cooldowns: CommandCooldownManager;
47
- readonly modules: ClientModuleManager;
48
+ readonly modules: ModuleManager;
49
+ readonly cwd: string;
48
50
  readonly logger: Logger;
49
51
  readonly version: string;
50
52
  get isClientLogsSilent(): boolean;
@@ -22,6 +22,7 @@ export interface Config {
22
22
  enabled: boolean;
23
23
  replyOnError: boolean;
24
24
  registerCommands: boolean;
25
+ allowRegisterEmptyCommandList: boolean;
25
26
  enableCooldown: boolean;
26
27
  setRequiredPermissions: boolean;
27
28
  acceptRepliedInteractions: boolean;
@@ -81,9 +82,9 @@ export declare class RecipleConfig {
81
82
  getConfig(): Config;
82
83
  /**
83
84
  * Parse token from config
84
- * @param askIfNull Ask for token if the token is null/undefined
85
+ * @param askIfEmpty Ask for token if the token is undefined
85
86
  */
86
- parseToken(askIfNull?: boolean): string | null;
87
+ parseToken(askIfEmpty?: boolean): string | null;
87
88
  /**
88
89
  * Check if the config version is supported
89
90
  */
@@ -0,0 +1,56 @@
1
+ import { GuildResolvable, RestOrArray } from 'discord.js';
2
+ import { AnyCommandBuilder, AnyCommandData } from '../types/builders';
3
+ import { RecipleClient } from './RecipleClient';
4
+ /**
5
+ * Reciple script object
6
+ */
7
+ export interface RecipleScript {
8
+ /**
9
+ * Supported reciple versions
10
+ */
11
+ versions: string | string[];
12
+ /**
13
+ * Module commands
14
+ */
15
+ commands?: (AnyCommandBuilder | AnyCommandData)[];
16
+ /**
17
+ * Action on module start
18
+ * @param client Bot client
19
+ */
20
+ onStart(client: RecipleClient<false>): boolean | Promise<boolean>;
21
+ /**
22
+ * Action on bot ready
23
+ * @param client Bot client
24
+ */
25
+ onLoad?(client: RecipleClient<true>): void | Promise<void>;
26
+ /**
27
+ * Action when unloading this module
28
+ * @param reason Unload reason
29
+ * @param client Bot client
30
+ */
31
+ onUnload?(reason: unknown, client: RecipleClient<true>): void | Promise<void>;
32
+ }
33
+ export interface RecipleModuleOptions<M = unknown> {
34
+ client: RecipleClient;
35
+ script: RecipleScript;
36
+ filePath?: string;
37
+ metadata?: M;
38
+ }
39
+ export declare class RecipleModule<M = unknown> {
40
+ readonly id: string;
41
+ readonly client: RecipleClient;
42
+ readonly commands: AnyCommandBuilder[];
43
+ readonly script: RecipleScript;
44
+ readonly filePath?: string;
45
+ metadata?: M;
46
+ get displayName(): string;
47
+ constructor(options: RecipleModuleOptions<M>);
48
+ start(): Promise<boolean>;
49
+ load(resolveCommands?: boolean): Promise<void>;
50
+ unload(reason?: any): Promise<void>;
51
+ registerSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
52
+ unregisterSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
53
+ updateSlashCommands(...guilds: RestOrArray<GuildResolvable>): Promise<void>;
54
+ resolveCommands(): AnyCommandBuilder[];
55
+ toString(): string;
56
+ }
@@ -1,4 +1,4 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, MessageCommandData } from '../../types/builders';
2
2
  import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
3
3
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
4
4
  import { MessageCommandOptionManager } from '../managers/MessageCommandOptionManager';
@@ -53,20 +53,20 @@ export interface MessageCommandValidatedOption {
53
53
  /**
54
54
  * Halt data for message command
55
55
  */
56
- export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.MessageCommand, T>;
56
+ export declare type MessageCommandHaltData<T = unknown> = CommandHaltData<CommandType.MessageCommand, T>;
57
57
  /**
58
58
  * Message command halt function
59
59
  */
60
- export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.MessageCommand, T>;
60
+ export declare type MessageCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.MessageCommand, T>;
61
61
  /**
62
62
  * Message command execute function
63
63
  */
64
- export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.MessageCommand, T>;
64
+ export declare type MessageCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.MessageCommand, T>;
65
65
  /**
66
66
  * Reciple builder for message command
67
67
  */
68
68
  export declare class MessageCommandBuilder<T = unknown> implements SharedCommandBuilderProperties<T> {
69
- readonly type = CommandBuilderType.MessageCommand;
69
+ readonly type = CommandType.MessageCommand;
70
70
  name: string;
71
71
  description: string;
72
72
  cooldown: number;
@@ -1,4 +1,4 @@
1
- import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder, SlashCommandData, AnySlashCommandOptionData, AnySlashCommandOptionBuilder } from '../../types/builders';
1
+ import { CommandType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties, AnySlashCommandBuilder, SlashCommandData, AnySlashCommandOptionData, AnySlashCommandOptionBuilder } from '../../types/builders';
2
2
  import { BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
3
3
  import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, SlashCommandRoleOption, SlashCommandAttachmentOption, SlashCommandMentionableOption, SlashCommandStringOption, SlashCommandIntegerOption, SlashCommandNumberOption, SharedSlashCommandOptions } from 'discord.js';
4
4
  /**
@@ -17,15 +17,15 @@ export interface SlashCommandExecuteData<T = unknown> extends BaseCommandExecute
17
17
  /**
18
18
  * Slash command halt data
19
19
  */
20
- export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandBuilderType.SlashCommand, T>;
20
+ export declare type SlashCommandHaltData<T = unknown> = CommandHaltData<CommandType.SlashCommand, T>;
21
21
  /**
22
22
  * Slash command halt function
23
23
  */
24
- export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandBuilderType.SlashCommand, T>;
24
+ export declare type SlashCommandHaltFunction<T = unknown> = CommandHaltFunction<CommandType.SlashCommand, T>;
25
25
  /**
26
26
  * Slash command execute function
27
27
  */
28
- export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandBuilderType.SlashCommand, T>;
28
+ export declare type SlashCommandExecuteFunction<T = unknown> = CommandExecuteFunction<CommandType.SlashCommand, T>;
29
29
  export declare type SlashCommandSubcommandsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addBooleanOption' | 'addUserOption' | 'addChannelOption' | 'addRoleOption' | 'addAttachmentOption' | 'addMentionableOption' | 'addStringOption' | 'addIntegerOption' | 'addNumberOption'>;
30
30
  export declare type SlashCommandOptionsOnlyBuilder<T = unknown> = Omit<SlashCommandBuilder<T>, 'addSubcommand' | 'addSubcommandGroup'>;
31
31
  export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder {
@@ -45,7 +45,7 @@ export interface SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandB
45
45
  * Reciple builder for slash command
46
46
  */
47
47
  export declare class SlashCommandBuilder<T = unknown> extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties<T> {
48
- readonly type = CommandBuilderType.SlashCommand;
48
+ readonly type = CommandType.SlashCommand;
49
49
  cooldown: number;
50
50
  requiredBotPermissions: PermissionResolvable[];
51
51
  requiredMemberPermissions: PermissionResolvable[];
@@ -1,20 +1,53 @@
1
- import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
1
+ import { ApplicationCommand, ApplicationCommandData, ContextMenuCommandBuilder, GuildResolvable, RestOrArray, RESTPostAPIApplicationCommandsJSONBody, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
2
2
  import { AnySlashCommandBuilder } from '../../types/builders';
3
3
  import { RecipleClient } from '../RecipleClient';
4
4
  export declare type ApplicationCommandBuilder = AnySlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
5
  export declare class ApplicationCommandManager {
6
6
  readonly client: RecipleClient;
7
- get commands(): import("discord.js").ApplicationCommandManager<ApplicationCommand<{
8
- guild: GuildResolvable;
9
- }>, {
10
- guild: GuildResolvable;
11
- }, null> | undefined;
7
+ get commands(): (DiscordJsSlashCommandBuilder | import("../builders/SlashCommandBuilder").SlashCommandOptionsOnlyBuilder<unknown> | import("../builders/SlashCommandBuilder").SlashCommandSubcommandsOnlyBuilder<unknown> | ContextMenuCommandBuilder | import("discord.js").UserApplicationCommandData | import("discord.js").MessageApplicationCommandData | import("discord.js").ChatInputApplicationCommandData)[];
8
+ get size(): number;
12
9
  constructor(client: RecipleClient);
13
- set(commands: (ApplicationCommandBuilder | ApplicationCommandData)[], guilds?: GuildResolvable[]): Promise<void>;
14
- add(command: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
15
- remove(command: string | ApplicationCommand, guilds?: GuildResolvable[]): Promise<void>;
16
- edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, guilds?: GuildResolvable[]): Promise<void>;
10
+ /**
11
+ * Sets application commands globally or in guilds
12
+ * @param commands Application commands
13
+ * @param guilds set only to guilds
14
+ */
15
+ set(commands: (ApplicationCommandBuilder | ApplicationCommandData)[], ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
16
+ /**
17
+ * Add command globally or in guilds
18
+ * @param command Application command
19
+ * @param guilds add only in guilds
20
+ */
21
+ add(command: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
22
+ /**
23
+ * Remove application command globally or in guilds
24
+ * @param command id of application commmand or ApplicationCommand class
25
+ * @param guilds Remove from guilds
26
+ */
27
+ remove(command: string | ApplicationCommand, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
28
+ /**
29
+ * Edit application command globally or in guilds
30
+ * @param command id of application command or ApplicationCommand class
31
+ * @param newCommand new application command data
32
+ * @param guilds Edit only from guilds
33
+ */
34
+ edit(command: string | ApplicationCommand, newCommand: ApplicationCommandBuilder | ApplicationCommandData, ...guilds: RestOrArray<GuildResolvable>): Promise<void>;
35
+ /**
36
+ * Get application command from cache by application command data, builder, id, or name globally or from guid
37
+ * @param command application command data, builder, id, or name
38
+ * @param guild get command from guild
39
+ */
17
40
  get(command: ApplicationCommandData | ApplicationCommandBuilder | string, guild?: GuildResolvable): ApplicationCommand | undefined;
41
+ /**
42
+ * Fetch application command by id globally or from guild
43
+ * @param commandId command id
44
+ * @param guild fetch from guild
45
+ */
18
46
  fetch(commandId: string, guild?: GuildResolvable): Promise<ApplicationCommand>;
47
+ /**
48
+ * Parse application command builders to command data
49
+ * @param commands Application command builders
50
+ * @param setPermissions set slash commands permissions
51
+ */
19
52
  protected parseCommands(commands: (ApplicationCommandData | ApplicationCommandBuilder | RESTPostAPIApplicationCommandsJSONBody)[], setPermissions?: boolean): (ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody)[];
20
53
  }