reciple 6.0.0-dev.2 → 6.0.0-dev.21

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 (48) 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 +19 -22
  5. package/dist/{cjs → lib}/reciple/classes/RecipleConfig.js +10 -10
  6. package/dist/lib/reciple/classes/RecipleModule.js +94 -0
  7. package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +325 -0
  8. package/dist/{cjs → lib}/reciple/classes/builders/MessageCommandOptionBuilder.js +35 -13
  9. package/dist/{cjs → lib}/reciple/classes/builders/SlashCommandBuilder.js +42 -15
  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 +7 -5
  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 +60 -26
  29. package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +15 -7
  30. package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +20 -10
  31. package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +43 -10
  32. package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +2 -2
  33. package/dist/types/reciple/classes/managers/{ClientCommandManager.d.ts → CommandManager.d.ts} +6 -7
  34. package/dist/types/reciple/classes/managers/ModuleManager.d.ts +49 -0
  35. package/dist/types/reciple/types/builders.d.ts +8 -8
  36. package/dist/types/reciple/types/commands.d.ts +16 -16
  37. package/dist/types/reciple/types/paramOptions.d.ts +79 -18
  38. package/dist/types/reciple/util.d.ts +11 -0
  39. package/package.json +28 -21
  40. package/resource/reciple.yml +25 -22
  41. package/dist/cjs/bin.js +0 -50
  42. package/dist/cjs/reciple/classes/builders/MessageCommandBuilder.js +0 -242
  43. package/dist/cjs/reciple/classes/managers/ClientModuleManager.js +0 -193
  44. package/dist/cjs/reciple/types/builders.js +0 -11
  45. package/dist/cjs/reciple/util.js +0 -32
  46. package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +0 -79
  47. package/dist/types/reciple/logger.d.ts +0 -8
  48. package/docs/README.md +0 -1
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import { RecipleClient } from './reciple/classes/RecipleClient.js';
3
+ import { RecipleConfig } from './reciple/classes/RecipleConfig.js';
4
+ import { rawVersion } from './reciple/version.js';
5
+ import { existsSync, mkdirSync, readdirSync } from 'fs';
6
+ import { cwd, flags } from './reciple/flags.js';
7
+ import { input } from 'fallout-utility';
8
+ import { path } from './reciple/util.js';
9
+ import chalk from 'chalk';
10
+ import 'dotenv/config';
11
+ import { inspect } from 'util';
12
+ const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
13
+ const configPath = path.join(cwd, 'reciple.yml');
14
+ if (!existsSync(cwd))
15
+ 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 (ask.toString().toLowerCase() !== 'y')
19
+ process.exit(0);
20
+ }
21
+ let configParser;
22
+ try {
23
+ configParser = new RecipleConfig(flags.config ?? configPath).parseConfig();
24
+ }
25
+ catch (err) {
26
+ console.error(`${chalk.bold.red('Config Error')}: ${inspect(err)}`);
27
+ process.exit(1);
28
+ }
29
+ const config = configParser.getConfig();
30
+ const client = new RecipleClient({ config: config, cwd, ...config.client });
31
+ /**
32
+ * Start
33
+ */
34
+ if (!client.isClientLogsSilent)
35
+ client.logger.info('Starting Reciple client v' + rawVersion);
36
+ client.addCommandListeners();
37
+ await client.modules.startModules({
38
+ modules: await client.modules.resolveModuleFiles({
39
+ files: await client.modules.getModulePaths({
40
+ filter: file => file.endsWith('.js') || file.endsWith('.cjs') || file.endsWith('.mjs'),
41
+ }),
42
+ }),
43
+ });
44
+ client.on('ready', async () => {
45
+ await client.modules.loadModules();
46
+ const unloadModulesAndStopProcess = async (signal) => {
47
+ await client.modules.unloadModules({ reason: 'ProcessExit' });
48
+ client.logger.warn(`Exitting process${signal === 'SIGINT' ? ': keyboard interrupt' : signal === 'SIGTERM' ? ': terminate' : signal}`);
49
+ process.exit();
50
+ };
51
+ process.once('SIGINT', signal => unloadModulesAndStopProcess(signal));
52
+ process.once('SIGTERM', signal => unloadModulesAndStopProcess(signal));
53
+ if (!client.isClientLogsSilent)
54
+ client.logger.log(`Loaded ${client.commands.slashCommands.size} slash commands`, `Loaded ${client.commands.messageCommands.size} message commands`);
55
+ if (client.config.commands.slashCommand.registerCommands && (client.config.commands.slashCommand.allowRegisterEmptyCommandList || client.applicationCommands.size)) {
56
+ await client.commands.registerApplicationCommands();
57
+ }
58
+ if (!client.isClientLogsSilent)
59
+ client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
60
+ client.on('cacheSweep', () => client.cooldowns.clean());
61
+ });
62
+ client.login(config.token).catch(err => {
63
+ if (!client.isClientLogsSilent)
64
+ client.logger.error(err);
65
+ });
@@ -0,0 +1 @@
1
+ export * from './index.js';
@@ -14,21 +14,22 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
18
- __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
19
- __exportStar(require("./reciple/classes/builders/SlashCommandBuilder"), exports);
20
- __exportStar(require("./reciple/classes/managers/ApplicationCommandManager"), exports);
21
- __exportStar(require("./reciple/classes/managers/CommandCooldownManager"), exports);
22
- __exportStar(require("./reciple/classes/managers/ClientCommandManager"), exports);
23
- __exportStar(require("./reciple/classes/managers/ClientModuleManager"), exports);
24
- __exportStar(require("./reciple/classes/managers/MessageCommandOptionManager"), exports);
25
- __exportStar(require("./reciple/classes/RecipleClient"), exports);
26
- __exportStar(require("./reciple/classes/RecipleConfig"), exports);
27
- __exportStar(require("./reciple/types/builders"), exports);
28
- __exportStar(require("./reciple/types/commands"), exports);
29
- __exportStar(require("./reciple/types/paramOptions"), exports);
17
+ __exportStar(require("./reciple/classes/builders/MessageCommandBuilder.js"), exports);
18
+ __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder.js"), exports);
19
+ __exportStar(require("./reciple/classes/builders/SlashCommandBuilder.js"), exports);
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
+ __exportStar(require("./reciple/classes/managers/CommandCooldownManager.js"), exports);
24
+ __exportStar(require("./reciple/classes/managers/MessageCommandOptionManager.js"), exports);
25
+ __exportStar(require("./reciple/classes/RecipleClient.js"), exports);
26
+ __exportStar(require("./reciple/classes/RecipleConfig.js"), exports);
27
+ __exportStar(require("./reciple/classes/RecipleModule.js"), exports);
28
+ __exportStar(require("./reciple/types/builders.js"), exports);
29
+ __exportStar(require("./reciple/types/commands.js"), exports);
30
+ __exportStar(require("./reciple/types/builders.js"), exports);
31
+ __exportStar(require("./reciple/types/builders.js"), exports);
30
32
  __exportStar(require("./reciple/flags"), exports);
31
- __exportStar(require("./reciple/logger"), exports);
32
- __exportStar(require("./reciple/permissions"), exports);
33
- __exportStar(require("./reciple/util"), exports);
34
- __exportStar(require("./reciple/version"), exports);
33
+ __exportStar(require("./reciple/permissions.js"), exports);
34
+ __exportStar(require("./reciple/util.js"), exports);
35
+ __exportStar(require("./reciple/version.js"), exports);
@@ -1,26 +1,22 @@
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.RecipleClient = void 0;
7
- const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
8
4
  const discord_js_1 = require("discord.js");
5
+ const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
9
6
  const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
10
7
  const commands_1 = require("../types/commands");
11
8
  const CommandCooldownManager_1 = require("./managers/CommandCooldownManager");
12
9
  const permissions_1 = require("../permissions");
13
10
  const MessageCommandOptionManager_1 = require("./managers/MessageCommandOptionManager");
14
11
  const ApplicationCommandManager_1 = require("./managers/ApplicationCommandManager");
12
+ const CommandManager_1 = require("./managers/CommandManager");
15
13
  const builders_1 = require("../types/builders");
16
- const ClientCommandManager_1 = require("./managers/ClientCommandManager");
17
- const ClientModuleManager_1 = require("./managers/ClientModuleManager");
14
+ const ModuleManager_1 = require("./managers/ModuleManager");
18
15
  const RecipleConfig_1 = require("./RecipleConfig");
19
16
  const fallout_utility_1 = require("fallout-utility");
20
- const logger_1 = require("../logger");
21
- const version_1 = require("../version");
17
+ const util_1 = require("../util");
18
+ const version_js_1 = require("../version.js");
22
19
  const flags_1 = require("../flags");
23
- const path_1 = __importDefault(require("path"));
24
20
  class RecipleClient extends discord_js_1.Client {
25
21
  /**
26
22
  * @param options Client options
@@ -28,18 +24,19 @@ class RecipleClient extends discord_js_1.Client {
28
24
  constructor(options) {
29
25
  super(options);
30
26
  this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
31
- this.commands = new ClientCommandManager_1.ClientCommandManager({
27
+ this.commands = new CommandManager_1.CommandManager({
32
28
  client: this,
33
29
  });
34
30
  this.cooldowns = new CommandCooldownManager_1.CommandCooldownManager();
35
- this.modules = new ClientModuleManager_1.ClientModuleManager({
31
+ this.modules = new ModuleManager_1.ModuleManager({
36
32
  client: this,
37
33
  });
38
- this.version = version_1.version;
39
- this.logger = (0, logger_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
34
+ this.version = version_js_1.version;
35
+ this.logger = (0, util_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
40
36
  this.config = { ...this.config, ...(options.config ?? {}) };
41
37
  if (this.config.fileLogging.enabled)
42
- this.logger.logFile(path_1.default.join(flags_1.cwd, this.config.fileLogging.logFilePath ?? 'logs/latest.log'), false);
38
+ this.logger.logFile(util_1.path.join(flags_1.cwd, this.config.fileLogging.logFilePath ?? 'logs/latest.log'), false);
39
+ this.cwd = options.cwd ?? process.cwd();
43
40
  this.applicationCommands = new ApplicationCommandManager_1.ApplicationCommandManager(this);
44
41
  }
45
42
  get isClientLogsSilent() {
@@ -68,7 +65,7 @@ class RecipleClient extends discord_js_1.Client {
68
65
  return;
69
66
  if (!this.config.commands.slashCommand.acceptRepliedInteractions && (interaction.replied || interaction.deferred))
70
67
  return;
71
- const command = this.commands.get(interaction.commandName, builders_1.CommandBuilderType.SlashCommand);
68
+ const command = this.commands.get(interaction.commandName, builders_1.CommandType.SlashCommand);
72
69
  if (!command)
73
70
  return;
74
71
  const executeData = {
@@ -97,7 +94,7 @@ class RecipleClient extends discord_js_1.Client {
97
94
  command: command.name,
98
95
  channel: interaction.channel ?? undefined,
99
96
  guild: interaction.guild,
100
- type: builders_1.CommandBuilderType.SlashCommand,
97
+ type: builders_1.CommandType.SlashCommand,
101
98
  };
102
99
  if (this.config.commands.slashCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
103
100
  this.cooldowns.add({
@@ -135,10 +132,10 @@ class RecipleClient extends discord_js_1.Client {
135
132
  const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.commands.messageCommand.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
136
133
  if (!parseCommand || !parseCommand?.command)
137
134
  return;
138
- const command = this.commands.get(parseCommand.command, builders_1.CommandBuilderType.MessageCommand);
135
+ const command = this.commands.get(parseCommand.command, builders_1.CommandType.MessageCommand);
139
136
  if (!command)
140
137
  return;
141
- const commandOptions = await (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
138
+ const commandOptions = await MessageCommandBuilder_1.MessageCommandBuilder.validateOptions(command, parseCommand);
142
139
  const executeData = {
143
140
  message: message,
144
141
  options: commandOptions,
@@ -189,7 +186,7 @@ class RecipleClient extends discord_js_1.Client {
189
186
  command: command.name,
190
187
  channel: message.channel,
191
188
  guild: message.guild,
192
- type: builders_1.CommandBuilderType.MessageCommand,
189
+ type: builders_1.CommandType.MessageCommand,
193
190
  };
194
191
  if (this.config.commands.messageCommand.enableCooldown && command.cooldown && !this.cooldowns.isCooledDown(userCooldown)) {
195
192
  this.cooldowns.add({
@@ -234,7 +231,7 @@ class RecipleClient extends discord_js_1.Client {
234
231
  async _haltCommand(command, haltData) {
235
232
  try {
236
233
  const haltResolved = (command.halt
237
- ? await Promise.resolve(command.type == builders_1.CommandBuilderType.SlashCommand ? command.halt(haltData) : command.halt(haltData)).catch(err => {
234
+ ? await Promise.resolve(command.type == builders_1.CommandType.SlashCommand ? command.halt(haltData) : command.halt(haltData)).catch(err => {
238
235
  console.log(err);
239
236
  })
240
237
  : false) || false;
@@ -251,7 +248,7 @@ class RecipleClient extends discord_js_1.Client {
251
248
  }
252
249
  async _executeCommand(command, executeData) {
253
250
  try {
254
- await Promise.resolve(command.type === builders_1.CommandBuilderType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
251
+ await Promise.resolve(command.type === builders_1.CommandType.SlashCommand ? command.execute(executeData) : command.execute(executeData))
255
252
  .then(() => this.emit('recipleCommandExecute', executeData))
256
253
  .catch(async (err) => !(await this._haltCommand(command, {
257
254
  executeData: executeData,
@@ -279,7 +276,7 @@ class RecipleClient extends discord_js_1.Client {
279
276
  */
280
277
  async _commandExecuteError(err, command) {
281
278
  if (!this.isClientLogsSilent) {
282
- this.logger.error(`An error occured executing ${command.builder.type == builders_1.CommandBuilderType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
279
+ this.logger.error(`An error occured executing ${command.builder.type == builders_1.CommandType.MessageCommand ? 'message' : 'slash'} command "${command.builder.name}"`);
283
280
  this.logger.error(err);
284
281
  }
285
282
  if (!err || !command)
@@ -8,7 +8,7 @@ const fs_1 = require("fs");
8
8
  const version_1 = require("../version");
9
9
  const fallout_utility_1 = require("fallout-utility");
10
10
  const flags_1 = require("../flags");
11
- const path_1 = __importDefault(require("path"));
11
+ const util_1 = require("../util");
12
12
  const yaml_1 = __importDefault(require("yaml"));
13
13
  /**
14
14
  * Create/parse reciple config
@@ -19,7 +19,7 @@ class RecipleConfig {
19
19
  */
20
20
  constructor(configPath) {
21
21
  this.config = RecipleConfig.getDefaultConfig();
22
- this.configPath = path_1.default.join(flags_1.cwd, 'reciple.yml');
22
+ this.configPath = util_1.path.join(process.cwd(), 'reciple.yml');
23
23
  if (!configPath)
24
24
  throw new Error('Config path is not defined');
25
25
  this.configPath = configPath;
@@ -62,17 +62,17 @@ class RecipleConfig {
62
62
  }
63
63
  /**
64
64
  * Parse token from config
65
- * @param askIfNull Ask for token if the token is null/undefined
65
+ * @param askIfEmpty Ask for token if the token is undefined
66
66
  */
67
- parseToken(askIfNull = true) {
68
- let token = flags_1.token || this.config?.token || null;
67
+ parseToken(askIfEmpty = true) {
68
+ let token = flags_1.token || this.config?.token || undefined;
69
69
  if (!token)
70
- return token || (askIfNull ? this._askToken() : null);
70
+ return token || (askIfEmpty ? this._askToken() : null);
71
71
  const envToken = token.toString().split(':');
72
72
  if (envToken.length === 2 && envToken[0].toLocaleLowerCase() === 'env' && envToken[1]) {
73
- token = process.env[envToken[1]] || null;
73
+ token = process.env[envToken[1]] || undefined;
74
74
  }
75
- return token || (askIfNull ? this._askToken() : null);
75
+ return token || (askIfEmpty == null ? this._askToken() : null);
76
76
  }
77
77
  /**
78
78
  * Check if the config version is supported
@@ -98,9 +98,9 @@ class RecipleConfig {
98
98
  */
99
99
  static getDefaultConfig() {
100
100
  if (!(0, fs_1.existsSync)(this.defaultConfigPath))
101
- throw new Error('Default config file does not exists.');
101
+ throw new Error(`Default config file does not exists: ${this.defaultConfigPath}`);
102
102
  return yaml_1.default.parse((0, fs_1.readFileSync)(this.defaultConfigPath, 'utf-8'));
103
103
  }
104
104
  }
105
105
  exports.RecipleConfig = RecipleConfig;
106
- RecipleConfig.defaultConfigPath = path_1.default.join(__dirname, '../../../../resource/reciple.yml');
106
+ RecipleConfig.defaultConfigPath = util_1.path.join(__dirname, '../../../../resource/reciple.yml');
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecipleModule = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const discord_js_1 = require("discord.js");
6
+ const builders_1 = require("../types/builders");
7
+ const util_1 = require("../util");
8
+ const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
9
+ const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
10
+ class RecipleModule {
11
+ constructor(options) {
12
+ this.commands = [];
13
+ this.id = (0, crypto_1.randomUUID)();
14
+ this.client = options.client;
15
+ this.script = options.script;
16
+ this.filePath = options.filePath;
17
+ this.metadata = options.metadata;
18
+ }
19
+ get displayName() {
20
+ return this.filePath ?? this.id;
21
+ }
22
+ async start() {
23
+ return Promise.resolve(this.script.onStart(this.client));
24
+ }
25
+ async load(resolveCommands = true) {
26
+ if (typeof this.script.onLoad === 'function')
27
+ await this.script.onLoad(this.client);
28
+ if (resolveCommands)
29
+ this.resolveCommands();
30
+ }
31
+ async unload(reason) {
32
+ if (typeof this.script.onUnload === 'function')
33
+ await this.script.onUnload(reason, this.client);
34
+ }
35
+ async registerSlashCommands(...guilds) {
36
+ for (const command of this.commands) {
37
+ if (command.type !== builders_1.CommandType.SlashCommand)
38
+ continue;
39
+ await this.client.applicationCommands.add(command, (0, discord_js_1.normalizeArray)(guilds));
40
+ }
41
+ }
42
+ async unregisterSlashCommands(...guilds) {
43
+ for (const builder of this.commands) {
44
+ if (builder.type !== builders_1.CommandType.SlashCommand)
45
+ continue;
46
+ if ((0, discord_js_1.normalizeArray)(guilds).length) {
47
+ for (const guild of (0, discord_js_1.normalizeArray)(guilds)) {
48
+ const command = this.client.applicationCommands.get(builder, guild);
49
+ if (command)
50
+ await this.client.applicationCommands.remove(command, guild);
51
+ }
52
+ continue;
53
+ }
54
+ const command = this.client.applicationCommands.get(builder);
55
+ if (command)
56
+ await this.client.applicationCommands.remove(command);
57
+ }
58
+ }
59
+ async updateSlashCommands(...guilds) {
60
+ for (const builder of this.commands) {
61
+ if (builder.type !== builders_1.CommandType.SlashCommand)
62
+ continue;
63
+ if ((0, discord_js_1.normalizeArray)(guilds).length) {
64
+ for (const guild of (0, discord_js_1.normalizeArray)(guilds)) {
65
+ const command = this.client.applicationCommands.get(builder, guild);
66
+ if (command)
67
+ await this.client.applicationCommands.edit(command, builder, guild);
68
+ }
69
+ continue;
70
+ }
71
+ const command = this.client.applicationCommands.get(builder);
72
+ if (command)
73
+ await this.client.applicationCommands.edit(command, builder);
74
+ }
75
+ }
76
+ resolveCommands() {
77
+ if (!Array.isArray(this.script?.commands))
78
+ return this.commands;
79
+ for (const command of this.script.commands) {
80
+ if (command?.type !== builders_1.CommandType.SlashCommand && command?.type !== builders_1.CommandType.MessageCommand)
81
+ continue;
82
+ const builder = command.type === builders_1.CommandType.SlashCommand ? SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command) : MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command);
83
+ if (!(0, util_1.validateCommandBuilder)(builder))
84
+ throw new Error('Invalid command builder, no name or contains option(s) without name');
85
+ this.commands.push(builder);
86
+ }
87
+ this.client.commands.add(this.commands);
88
+ return this.commands;
89
+ }
90
+ toString() {
91
+ return this.displayName;
92
+ }
93
+ }
94
+ exports.RecipleModule = RecipleModule;