reciple 10.0.14 → 10.0.16

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 (26) hide show
  1. package/dist/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.108.0}/helpers/decorate.mjs +1 -1
  2. package/dist/bin/commands/start.mjs +23 -23
  3. package/dist/bin/commands/start.mjs.map +1 -1
  4. package/dist/bin/commands/startSharding.mjs +18 -18
  5. package/dist/bin/commands/startSharding.mjs.map +1 -1
  6. package/dist/classes/cli/CLI.mjs +1 -1
  7. package/dist/classes/cli/ConfigReader.mjs +11 -5
  8. package/dist/classes/cli/ConfigReader.mjs.map +1 -1
  9. package/dist/classes/client/ModuleLoader.mjs +18 -18
  10. package/dist/classes/client/ModuleLoader.mjs.map +1 -1
  11. package/dist/classes/managers/ModuleManager.mjs +1 -1
  12. package/dist/classes/modules/PostconditionModule.mjs +1 -1
  13. package/dist/classes/modules/PreconditionModule.mjs +1 -1
  14. package/dist/classes/modules/commands/ContextMenuCommandModule.mjs +1 -1
  15. package/dist/classes/modules/commands/MessageCommandModule.mjs +1 -1
  16. package/dist/classes/modules/commands/SlashCommandModule.mjs +1 -1
  17. package/dist/classes/templates/ModuleTemplateBuilder.mjs +19 -19
  18. package/dist/classes/templates/ModuleTemplateBuilder.mjs.map +1 -1
  19. package/dist/classes/templates/TemplateBuilder.mjs +2 -2
  20. package/dist/classes/templates/TemplateBuilder.mjs.map +1 -1
  21. package/dist/classes/validation/BaseModuleValidator.d.mts +10 -10
  22. package/dist/classes/validation/CommandModuleValidator.d.mts +17 -17
  23. package/dist/classes/validation/PostconditionModule.d.mts +9 -9
  24. package/dist/classes/validation/PreconditionModule.d.mts +8 -8
  25. package/dist/package.mjs +7 -7
  26. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
1
+ //#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
2
2
  function __decorate(decorators, target, key, desc) {
3
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -20,17 +20,17 @@ var StartSubcommand = class extends CLISubcommand {
20
20
  const flags = this.subcommand.opts();
21
21
  await this.cli.setCurrentDirectory(this.subcommand.args[0]);
22
22
  const { client, config, build: buildConfig } = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
23
- const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
23
+ const logger$1 = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
24
24
  let token = flags.token || config.token || "";
25
25
  token = resolveEnvProtocol(token) || token;
26
26
  function handleProcessError(err) {
27
- logger.error(err);
27
+ logger$1.error(err);
28
28
  process.exit(1);
29
29
  }
30
30
  process.once("uncaughtException", handleProcessError);
31
31
  process.once("unhandledRejection", handleProcessError);
32
- process.on("warning", (warn) => logger.warn(warn));
33
- logger.log(colors.magenta(`⚡ Initializing reciple!`));
32
+ process.on("warning", (warn) => logger$1.warn(warn));
33
+ logger$1.log(colors.magenta(`⚡ Initializing reciple!`));
34
34
  if (flags.build) {
35
35
  let plugins = buildConfig.plugins ? Array.isArray(buildConfig.plugins) ? buildConfig.plugins : [buildConfig.plugins] : [];
36
36
  plugins.push(CLI.createTsdownLogger());
@@ -41,7 +41,7 @@ var StartSubcommand = class extends CLISubcommand {
41
41
  });
42
42
  }
43
43
  Object.assign(client, {
44
- logger,
44
+ logger: logger$1,
45
45
  cli: this.cli,
46
46
  config
47
47
  });
@@ -51,12 +51,12 @@ var StartSubcommand = class extends CLISubcommand {
51
51
  eventListeners: new EventListeners()
52
52
  });
53
53
  Reflect.set(global, "useClient", () => client);
54
- Reflect.set(global, "useLogger", () => logger);
54
+ Reflect.set(global, "useLogger", () => logger$1);
55
55
  EventListeners.registerLoggerEventListeners(client);
56
- logger.log(colors.green(`📦 Version Info:`));
57
- logger.log(` ├─ ${colors.cyan(`reciple`)}\t\t${colors.yellow(`${this.cli.version}`)}`);
58
- logger.log(` ├─ ${colors.cyan(`@reciple/core`)}\t${colors.yellow(`${Client.version}`)}`);
59
- logger.log(` └─ ${colors.cyan(`discord.js`)}\t${colors.yellow(`${version}`)}`);
56
+ logger$1.log(colors.green(`📦 Version Info:`));
57
+ logger$1.log(` ├─ ${colors.cyan(`reciple`)}\t\t${colors.yellow(`${this.cli.version}`)}`);
58
+ logger$1.log(` ├─ ${colors.cyan(`@reciple/core`)}\t${colors.yellow(`${Client.version}`)}`);
59
+ logger$1.log(` └─ ${colors.cyan(`discord.js`)}\t${colors.yellow(`${version}`)}`);
60
60
  const modules = await client.moduleLoader.findModules();
61
61
  Object.assign(client, {
62
62
  _onBeforeLogin: async () => {
@@ -64,14 +64,14 @@ var StartSubcommand = class extends CLISubcommand {
64
64
  client.once("clientReady", async () => {
65
65
  if (!client.isReady()) return;
66
66
  EventListeners.registerCommandsEventListeners(client);
67
- logger.debug(`Client is ready!`);
67
+ logger$1.debug(`Client is ready!`);
68
68
  process.removeListener("uncaughtException", handleProcessError);
69
69
  process.removeListener("unhandledRejection", handleProcessError);
70
70
  const notEnabledModules = modules.length - enabledModules.length;
71
- logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, "module")} ${Format.plural(enabledModules.length, "is", "are")} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ""}`));
71
+ logger$1.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, "module")} ${Format.plural(enabledModules.length, "is", "are")} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ""}`));
72
72
  const readyModules = await client.modules.readyModules();
73
73
  const notReadyModules = readyModules.length - enabledModules.length;
74
- logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, "module")} ${Format.plural(readyModules.length, "is", "are")} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ""}`));
74
+ logger$1.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, "module")} ${Format.plural(readyModules.length, "is", "are")} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ""}`));
75
75
  await client.commands.registerApplicationCommands({
76
76
  ...config.applicationCommandsRegister,
77
77
  commands: client.commands.applicationCommands
@@ -82,21 +82,21 @@ var StartSubcommand = class extends CLISubcommand {
82
82
  message: client.commands.cache.filter((c) => c.type === CommandType.Message).size,
83
83
  slash: client.commands.cache.filter((c) => c.type === CommandType.Slash).size
84
84
  };
85
- logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);
86
- logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, "module")}.`);
87
- logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, "command")}.`);
88
- logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, "command")}.`);
89
- logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, "command")}.`);
90
- logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, "precondition")}.`);
91
- logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, "postcondition")}.`);
85
+ logger$1.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);
86
+ logger$1.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, "module")}.`);
87
+ logger$1.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, "command")}.`);
88
+ logger$1.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, "command")}.`);
89
+ logger$1.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, "command")}.`);
90
+ logger$1.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, "precondition")}.`);
91
+ logger$1.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, "postcondition")}.`);
92
92
  });
93
93
  client.eventListeners.registerProcessExitEvents(async (signal) => RuntimeEnvironment.handleExitSignal(client, signal));
94
94
  },
95
- _onBeforeDestroy: async (client) => {
96
- await client.modules.disableModules();
95
+ _onBeforeDestroy: async (client$1) => {
96
+ await client$1.modules.disableModules();
97
97
  }
98
98
  });
99
- logger.debug(`Logging in...`);
99
+ logger$1.debug(`Logging in...`);
100
100
  await client.login(token);
101
101
  }
102
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"start.mjs","names":["DiscordJsVersion"],"sources":["../../../src/bin/commands/start.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { Logger } from '@prtty/print';\nimport { Format, resolveEnvProtocol } from '@reciple/utils';\nimport { Client, CommandType } from '@reciple/core';\nimport { ModuleLoader } from '../../classes/client/ModuleLoader.js';\nimport { ModuleManager } from '../../classes/managers/ModuleManager.js';\nimport { version as DiscordJsVersion } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\nimport { RuntimeEnvironment } from '../../classes/cli/RuntimeEnvironment.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { colors } from '@prtty/prtty';\n\nexport default class StartSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('start')\n .description('Start the reciple client')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<StartSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { client, config, build: buildConfig } = await configReader.read();\n\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n function handleProcessError(err: unknown) {\n logger.error(err);\n process.exit(1);\n }\n\n process.once('uncaughtException', handleProcessError);\n process.once('unhandledRejection', handleProcessError);\n process.on('warning', warn => logger.warn(warn));\n\n logger.log(colors.magenta(`⚡ Initializing reciple!`));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n Object.assign(client, {\n logger,\n cli: this.cli,\n config\n });\n\n Object.assign(client, {\n modules: new ModuleManager(client),\n moduleLoader: new ModuleLoader(client),\n eventListeners: new EventListeners()\n });\n\n Reflect.set(global, 'useClient', () => client);\n Reflect.set(global, 'useLogger', () => logger);\n\n EventListeners.registerLoggerEventListeners(client);\n\n logger.log(colors.green(`📦 Version Info:`));\n logger.log(` ├─ ${colors.cyan(`reciple`)}\\t\\t${colors.yellow(`${this.cli.version}`)}`);\n logger.log(` ├─ ${colors.cyan(`@reciple/core`)}\\t${colors.yellow(`${Client.version}`)}`);\n logger.log(` └─ ${colors.cyan(`discord.js`)}\\t${colors.yellow(`${DiscordJsVersion}`)}`);\n\n const modules = await client.moduleLoader.findModules();\n\n Object.assign(client, {\n _onBeforeLogin: async() => {\n const enabledModules = await client.modules.enableModules({ modules });\n\n client.once('clientReady', async() => {\n if (!client.isReady()) return;\n\n EventListeners.registerCommandsEventListeners(client);\n\n logger.debug(`Client is ready!`);\n process.removeListener('uncaughtException', handleProcessError);\n process.removeListener('unhandledRejection', handleProcessError);\n\n const notEnabledModules = modules.length - enabledModules.length;\n logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, 'module')} ${Format.plural(enabledModules.length, 'is', 'are')} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ''}`));\n\n const readyModules = await client.modules.readyModules();\n const notReadyModules = readyModules.length - enabledModules.length;\n\n logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, 'module')} ${Format.plural(readyModules.length, 'is', 'are')} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ''}`));\n\n await client.commands.registerApplicationCommands({\n ...config.applicationCommandsRegister,\n commands: client.commands.applicationCommands,\n });\n\n process.stdin.resume();\n\n const commands = {\n contextMenus: client.commands.cache.filter(c => c.type === CommandType.ContextMenu).size,\n message: client.commands.cache.filter(c => c.type === CommandType.Message).size,\n slash: client.commands.cache.filter(c => c.type === CommandType.Slash).size\n };\n\n logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);\n logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, 'module')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, 'precondition')}.`);\n logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, 'postcondition')}.`);\n });\n\n client.eventListeners.registerProcessExitEvents(async signal => RuntimeEnvironment.handleExitSignal(client, signal));\n },\n _onBeforeDestroy: async (client: Client) => {\n await client.modules.disableModules();\n }\n })\n\n logger.debug(`Logging in...`);\n await client.login(token);\n }\n}\n\nexport namespace StartSubcommand {\n export interface Flags {\n token?: string;\n build?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,2BAA2B,CACvC,SAAS,aAAa,qCAAqC,CAC3D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAA6B;AAE3D,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAO3D,MAAM,EAAE,QAAQ,QAAQ,OAAO,gBAAgB,MAL1B,IAAI,aACrB,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAEiE,MAAM;EAExE,MAAM,SAAS,OAAO,kBAAkB,SAAS,KAAK,IAAI,SAAS,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO;EAEvH,IAAI,QAAQ,MAAM,SAAS,OAAO,SAAS;AACvC,UAAQ,mBAAmB,MAAM,IAAI;EAEzC,SAAS,mBAAmB,KAAc;AACtC,UAAO,MAAM,IAAI;AACjB,WAAQ,KAAK,EAAE;;AAGnB,UAAQ,KAAK,qBAAqB,mBAAmB;AACrD,UAAQ,KAAK,sBAAsB,mBAAmB;AACtD,UAAQ,GAAG,YAAW,SAAQ,OAAO,KAAK,KAAK,CAAC;AAEhD,SAAO,IAAI,OAAO,QAAQ,0BAA0B,CAAC;AAErD,MAAI,MAAM,OAAO;GACb,IAAI,U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AAI,cAAc,OAAO,MAAM,SAAS,QAAQ,gBAAgB,CAAC,CAAC,WAAW,OAAO,OAAO,SAAS,SAAS,UAAU,CAAC,GAAG;AAClI,YAAO,IAAI,cAAc,OAAO,MAAM,SAAS,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,OAAO,SAAS,OAAO,UAAU,CAAC,GAAG;AAC5H,YAAO,IAAI,cAAc,OAAO,MAAM,OAAO,cAAc,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,cAAc,MAAM,MAAM,eAAe,CAAC,GAAG;AACpK,YAAO,IAAI,cAAc,OAAO,MAAM,OAAO,eAAe,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,eAAe,MAAM,MAAM,gBAAgB,CAAC,GAAG;MACzK;AAEF,WAAO,eAAe,0BAA0B,OAAM,WAAU,mBAAmB,iBAAiB,QAAQ,OAAO,CAAC;;GAExH,kBAAkB,OAAO,WAAmB;AACxC,UAAM,OAAO,QAAQ,gBAAgB;;GAE5C,CAAC;AAEF,SAAO,MAAM,gBAAgB;AAC7B,QAAM,OAAO,MAAM,MAAM"}
1
+ {"version":3,"file":"start.mjs","names":["logger","DiscordJsVersion","client"],"sources":["../../../src/bin/commands/start.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport { Logger } from '@prtty/print';\nimport { Format, resolveEnvProtocol } from '@reciple/utils';\nimport { Client, CommandType } from '@reciple/core';\nimport { ModuleLoader } from '../../classes/client/ModuleLoader.js';\nimport { ModuleManager } from '../../classes/managers/ModuleManager.js';\nimport { version as DiscordJsVersion } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\nimport { RuntimeEnvironment } from '../../classes/cli/RuntimeEnvironment.js';\nimport { build } from 'tsdown';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { colors } from '@prtty/prtty';\n\nexport default class StartSubcommand extends CLISubcommand {\n public subcommand: Command = new Command('start')\n .description('Start the reciple client')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n const flags = this.subcommand.opts<StartSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { client, config, build: buildConfig } = await configReader.read();\n\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n function handleProcessError(err: unknown) {\n logger.error(err);\n process.exit(1);\n }\n\n process.once('uncaughtException', handleProcessError);\n process.once('unhandledRejection', handleProcessError);\n process.on('warning', warn => logger.warn(warn));\n\n logger.log(colors.magenta(`⚡ Initializing reciple!`));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n Object.assign(client, {\n logger,\n cli: this.cli,\n config\n });\n\n Object.assign(client, {\n modules: new ModuleManager(client),\n moduleLoader: new ModuleLoader(client),\n eventListeners: new EventListeners()\n });\n\n Reflect.set(global, 'useClient', () => client);\n Reflect.set(global, 'useLogger', () => logger);\n\n EventListeners.registerLoggerEventListeners(client);\n\n logger.log(colors.green(`📦 Version Info:`));\n logger.log(` ├─ ${colors.cyan(`reciple`)}\\t\\t${colors.yellow(`${this.cli.version}`)}`);\n logger.log(` ├─ ${colors.cyan(`@reciple/core`)}\\t${colors.yellow(`${Client.version}`)}`);\n logger.log(` └─ ${colors.cyan(`discord.js`)}\\t${colors.yellow(`${DiscordJsVersion}`)}`);\n\n const modules = await client.moduleLoader.findModules();\n\n Object.assign(client, {\n _onBeforeLogin: async() => {\n const enabledModules = await client.modules.enableModules({ modules });\n\n client.once('clientReady', async() => {\n if (!client.isReady()) return;\n\n EventListeners.registerCommandsEventListeners(client);\n\n logger.debug(`Client is ready!`);\n process.removeListener('uncaughtException', handleProcessError);\n process.removeListener('unhandledRejection', handleProcessError);\n\n const notEnabledModules = modules.length - enabledModules.length;\n logger.log(colors.green(`✅ ${enabledModules.length} ${Format.plural(enabledModules.length, 'module')} ${Format.plural(enabledModules.length, 'is', 'are')} enabled.${notEnabledModules > 0 ? colors.red(` (${notEnabledModules} not enabled)`) : ''}`));\n\n const readyModules = await client.modules.readyModules();\n const notReadyModules = readyModules.length - enabledModules.length;\n\n logger.log(colors.green(`✅ ${readyModules.length} ${Format.plural(readyModules.length, 'module')} ${Format.plural(readyModules.length, 'is', 'are')} ready.${notReadyModules > 0 ? colors.red(` (${notReadyModules} not ready)`) : ''}`));\n\n await client.commands.registerApplicationCommands({\n ...config.applicationCommandsRegister,\n commands: client.commands.applicationCommands,\n });\n\n process.stdin.resume();\n\n const commands = {\n contextMenus: client.commands.cache.filter(c => c.type === CommandType.ContextMenu).size,\n message: client.commands.cache.filter(c => c.type === CommandType.Message).size,\n slash: client.commands.cache.filter(c => c.type === CommandType.Slash).size\n };\n\n logger.log(`🔑 Logged in as ${colors.bold(colors.cyan(client.user.displayName))} ${colors.magenta(`(${client.user.id})`)}`);\n logger.log(` ├─ Loaded ${colors.green(modules.length.toLocaleString())} ${Format.plural(modules.length, 'module')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.contextMenus.toLocaleString())} context menu ${Format.plural(commands.contextMenus, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.message.toLocaleString())} message ${Format.plural(commands.message, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(commands.slash.toLocaleString())} slash ${Format.plural(commands.slash, 'command')}.`);\n logger.log(` ├─ Loaded ${colors.green(client.preconditions.cache.size.toLocaleString())} global ${Format.plural(client.preconditions.cache.size, 'precondition')}.`);\n logger.log(` └─ Loaded ${colors.green(client.postconditions.cache.size.toLocaleString())} global ${Format.plural(client.postconditions.cache.size, 'postcondition')}.`);\n });\n\n client.eventListeners.registerProcessExitEvents(async signal => RuntimeEnvironment.handleExitSignal(client, signal));\n },\n _onBeforeDestroy: async (client: Client) => {\n await client.modules.disableModules();\n }\n })\n\n logger.debug(`Logging in...`);\n await client.login(token);\n }\n}\n\nexport namespace StartSubcommand {\n export interface Flags {\n token?: string;\n build?: boolean;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAqB,kBAArB,cAA6C,cAAc;CACvD,AAAO,aAAsB,IAAI,QAAQ,QAAQ,CAC5C,YAAY,2BAA2B,CACvC,SAAS,aAAa,qCAAqC,CAC3D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;EAClC,MAAM,QAAQ,KAAK,WAAW,MAA6B;AAE3D,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAO3D,MAAM,EAAE,QAAQ,QAAQ,OAAO,gBAAgB,MAL1B,IAAI,aACrB,MAAM,aAAa,MAAM,IACtB,aAAa,qBAAqB,KAAK,CAC7C,CAEiE,MAAM;EAExE,MAAMA,WAAS,OAAO,kBAAkB,SAAS,KAAK,IAAI,SAAS,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM,OAAO,OAAO;EAEvH,IAAI,QAAQ,MAAM,SAAS,OAAO,SAAS;AACvC,UAAQ,mBAAmB,MAAM,IAAI;EAEzC,SAAS,mBAAmB,KAAc;AACtC,YAAO,MAAM,IAAI;AACjB,WAAQ,KAAK,EAAE;;AAGnB,UAAQ,KAAK,qBAAqB,mBAAmB;AACrD,UAAQ,KAAK,sBAAsB,mBAAmB;AACtD,UAAQ,GAAG,YAAW,SAAQA,SAAO,KAAK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SAAS,aAAa,gBAAgB,CAAC,CAAC,gBAAgB,OAAO,OAAO,SAAS,cAAc,UAAU,CAAC,GAAG;AACjJ,cAAO,IAAI,cAAc,OAAO,MAAM,SAAS,QAAQ,gBAAgB,CAAC,CAAC,WAAW,OAAO,OAAO,SAAS,SAAS,UAAU,CAAC,GAAG;AAClI,cAAO,IAAI,cAAc,OAAO,MAAM,SAAS,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,OAAO,SAAS,OAAO,UAAU,CAAC,GAAG;AAC5H,cAAO,IAAI,cAAc,OAAO,MAAM,OAAO,cAAc,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,cAAc,MAAM,MAAM,eAAe,CAAC,GAAG;AACpK,cAAO,IAAI,cAAc,OAAO,MAAM,OAAO,eAAe,MAAM,KAAK,gBAAgB,CAAC,CAAC,UAAU,OAAO,OAAO,OAAO,eAAe,MAAM,MAAM,gBAAgB,CAAC,GAAG;MACzK;AAEF,WAAO,eAAe,0BAA0B,OAAM,WAAU,mBAAmB,iBAAiB,QAAQ,OAAO,CAAC;;GAExH,kBAAkB,OAAO,aAAmB;AACxC,UAAMC,SAAO,QAAQ,gBAAgB;;GAE5C,CAAC;AAEF,WAAO,MAAM,gBAAgB;AAC7B,QAAM,OAAO,MAAM,MAAM"}
@@ -25,18 +25,18 @@ var StartShardingSubcommand = class extends CLISubcommand {
25
25
  ...CLI.stringifyFlags(flags, this.command)
26
26
  ];
27
27
  const { config, build: buildConfig, sharding } = await new ConfigReader(await ConfigReader.find() ?? ConfigReader.createConfigFilename("js")).read();
28
- const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
29
- logger.label = "ShardingManager";
28
+ const logger$1 = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);
29
+ logger$1.label = "ShardingManager";
30
30
  let token = flags.token || config.token || "";
31
31
  token = resolveEnvProtocol(token) || token;
32
- logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));
32
+ logger$1.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));
33
33
  const processErrorLogger = (err) => {
34
- logger?.error(err);
34
+ logger$1?.error(err);
35
35
  process.exit(1);
36
36
  };
37
37
  process.once("uncaughtException", processErrorLogger);
38
38
  process.once("unhandledRejection", processErrorLogger);
39
- process.on("warning", (warn) => logger.warn(warn));
39
+ process.on("warning", (warn) => logger$1.warn(warn));
40
40
  if (flags.build) {
41
41
  let plugins = buildConfig.plugins ? Array.isArray(buildConfig.plugins) ? buildConfig.plugins : [buildConfig.plugins] : [];
42
42
  plugins.push(CLI.createTsdownLogger());
@@ -47,10 +47,10 @@ var StartShardingSubcommand = class extends CLISubcommand {
47
47
  });
48
48
  }
49
49
  if (!sharding) {
50
- logger.error("Sharding is not enabled in the config file");
50
+ logger$1.error("Sharding is not enabled in the config file");
51
51
  process.exit(1);
52
52
  }
53
- Reflect.set(global, "useLogger", () => logger);
53
+ Reflect.set(global, "useLogger", () => logger$1);
54
54
  const eventListeners = new EventListeners();
55
55
  const manager = new ShardingManager(CLI.bin, {
56
56
  ...sharding,
@@ -58,25 +58,25 @@ var StartShardingSubcommand = class extends CLISubcommand {
58
58
  shardArgs
59
59
  });
60
60
  manager.on("shardCreate", (shard) => {
61
- logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));
61
+ logger$1.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));
62
62
  shard.on("ready", () => {
63
- logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));
63
+ logger$1.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));
64
64
  if (process.env.RECIPLE_FIRST_SHARD === "true") process.env.RECIPLE_FIRST_SHARD = "false";
65
65
  });
66
66
  shard.on("reconnecting", () => {
67
- logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));
67
+ logger$1.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));
68
68
  });
69
69
  shard.on("resume", () => {
70
- logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));
70
+ logger$1.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));
71
71
  });
72
72
  shard.on("disconnect", () => {
73
- logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));
73
+ logger$1.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));
74
74
  });
75
75
  shard.on("death", () => {
76
- logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);
76
+ logger$1.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);
77
77
  });
78
78
  shard.on("error", (error) => {
79
- logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);
79
+ logger$1.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);
80
80
  });
81
81
  shard.on("message", (message) => {});
82
82
  });
@@ -85,14 +85,14 @@ var StartShardingSubcommand = class extends CLISubcommand {
85
85
  await manager.spawn();
86
86
  }
87
87
  destroyShardingManager(manager) {
88
- const logger = useLogger();
88
+ const logger$1 = useLogger();
89
89
  manager.shards.map((s) => {
90
- logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));
90
+ logger$1.log(colors.magenta(`🚧 Destroying shard ${s.id}`));
91
91
  if (s.process) s.process.kill();
92
92
  else s.kill();
93
- logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));
93
+ logger$1.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));
94
94
  });
95
- logger.log(colors.magenta(`🚨 Destroyed all shards`));
95
+ logger$1.log(colors.magenta(`🚨 Destroyed all shards`));
96
96
  setTimeout(() => process.exit(0), 500);
97
97
  }
98
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"startSharding.mjs","names":[],"sources":["../../../src/bin/commands/startSharding.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport type { StartSubcommand } from './start.js';\nimport { Logger } from '@prtty/print';\nimport { resolveEnvProtocol } from '@reciple/utils';\nimport { colors } from '@prtty/prtty';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { build } from 'tsdown';\nimport { ShardingManager } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\n\nexport default class StartShardingSubcommand extends CLISubcommand {\n public parent?: string = 'start';\n\n public subcommand: Command = new Command('sharding')\n .description('Start the reciple client in sharding mode')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n process.env.RECIPLE_SHARDING = 'true';\n process.env.RECIPLE_FIRST_SHARD = 'true';\n\n const recipleFlags = this.cli.getFlags();\n const flags = this.subcommand.opts<ShardingSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const shardArgs: string[] = [\n ...CLI.stringifyFlags(recipleFlags, this.cli.command),\n 'start',\n ...CLI.stringifyFlags(flags, this.command)\n ];\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { config, build: buildConfig, sharding } = await configReader.read();\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n logger.label = 'ShardingManager';\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));\n\n const processErrorLogger = (err: any) => {\n logger?.error(err);\n process.exit(1);\n };\n\n process.once('uncaughtException', processErrorLogger);\n process.once('unhandledRejection', processErrorLogger);\n process.on('warning', warn => logger.warn(warn));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n if (!sharding) {\n logger.error('Sharding is not enabled in the config file');\n process.exit(1);\n }\n\n Reflect.set(global, 'useLogger', () => logger);\n\n const eventListeners = new EventListeners();\n const manager = new ShardingManager(CLI.bin, {\n ...sharding,\n token: token,\n shardArgs\n });\n\n manager.on('shardCreate', shard => {\n logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));\n\n shard.on('ready', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));\n\n if (process.env.RECIPLE_FIRST_SHARD === 'true') {\n process.env.RECIPLE_FIRST_SHARD = 'false';\n }\n });\n\n shard.on('reconnecting', () => {\n logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));\n });\n\n shard.on('resume', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));\n });\n\n shard.on('disconnect', () => {\n logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));\n });\n\n shard.on('death', () => {\n logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);\n });\n\n shard.on('error', error => {\n logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);\n });\n\n shard.on('message', message => {\n // TODO: Handle shard messages\n });\n });\n\n eventListeners.registerProcessExitEvents(signal => this.destroyShardingManager(manager));\n process.stdin.resume();\n\n await manager.spawn();\n }\n\n public destroyShardingManager(manager: ShardingManager): void {\n const logger = useLogger();\n\n manager.shards.map(s => {\n logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));\n\n if (s.process) {\n s.process.kill();\n } else {\n s.kill();\n }\n\n logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));\n });\n\n logger.log(colors.magenta(`🚨 Destroyed all shards`));\n setTimeout(() => process.exit(0), 500);\n }\n}\n\nexport namespace ShardingSubcommand {\n export interface Flags extends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;AACvB,WAAO,MAAM,WAAW,OAAO,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,yBAAyB,MAAM;KACxF;AAEF,SAAM,GAAG,YAAW,YAAW,GAE7B;IACJ;AAEF,iBAAe,2BAA0B,WAAU,KAAK,uBAAuB,QAAQ,CAAC;AACxF,UAAQ,MAAM,QAAQ;AAEtB,QAAM,QAAQ,OAAO;;CAGzB,AAAO,uBAAuB,SAAgC;EAC1D,MAAM,SAAS,WAAW;AAE1B,UAAQ,OAAO,KAAI,MAAK;AACpB,UAAO,IAAI,OAAO,QAAQ,uBAAuB,EAAE,KAAK,CAAC;AAEzD,OAAI,EAAE,QACF,GAAE,QAAQ,MAAM;OAEhB,GAAE,MAAM;AAGZ,UAAO,IAAI,OAAO,QAAQ,sBAAsB,EAAE,KAAK,CAAC;IAC1D;AAEF,SAAO,IAAI,OAAO,QAAQ,0BAA0B,CAAC;AACrD,mBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI"}
1
+ {"version":3,"file":"startSharding.mjs","names":["logger"],"sources":["../../../src/bin/commands/startSharding.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { CLISubcommand } from '../../classes/cli/CLISubcommand.js';\nimport { ConfigReader } from '../../classes/cli/ConfigReader.js';\nimport type { StartSubcommand } from './start.js';\nimport { Logger } from '@prtty/print';\nimport { resolveEnvProtocol } from '@reciple/utils';\nimport { colors } from '@prtty/prtty';\nimport { CLI } from '../../classes/cli/CLI.js';\nimport { build } from 'tsdown';\nimport { ShardingManager } from 'discord.js';\nimport { EventListeners } from '../../classes/client/EventListeners.js';\n\nexport default class StartShardingSubcommand extends CLISubcommand {\n public parent?: string = 'start';\n\n public subcommand: Command = new Command('sharding')\n .description('Start the reciple client in sharding mode')\n .argument('[project]', 'The root directory of your project')\n .option('-t, --token <DiscordToken>', 'Set your Discord Bot token')\n .option('-b, --build', 'Build the modules before starting the client')\n .allowUnknownOption(true);\n\n public async execute(): Promise<void> {\n process.env.RECIPLE_SHARDING = 'true';\n process.env.RECIPLE_FIRST_SHARD = 'true';\n\n const recipleFlags = this.cli.getFlags();\n const flags = this.subcommand.opts<ShardingSubcommand.Flags>();\n\n await this.cli.setCurrentDirectory(this.subcommand.args[0]);\n\n const shardArgs: string[] = [\n ...CLI.stringifyFlags(recipleFlags, this.cli.command),\n 'start',\n ...CLI.stringifyFlags(flags, this.command)\n ];\n\n const configReader = new ConfigReader(\n await ConfigReader.find()\n ?? ConfigReader.createConfigFilename('js')\n );\n\n const { config, build: buildConfig, sharding } = await configReader.read();\n const logger = config.logger instanceof Logger ? this.cli.logger = config.logger : this.cli.logger.clone(config.logger);\n\n logger.label = 'ShardingManager';\n\n let token = flags.token || config.token || '';\n token = resolveEnvProtocol(token) || token;\n\n logger.log(colors.magenta(`⚡ Initializing reciple sharding manager!`));\n\n const processErrorLogger = (err: any) => {\n logger?.error(err);\n process.exit(1);\n };\n\n process.once('uncaughtException', processErrorLogger);\n process.once('unhandledRejection', processErrorLogger);\n process.on('warning', warn => logger.warn(warn));\n\n if (flags.build) {\n let plugins = buildConfig.plugins\n ? Array.isArray(buildConfig.plugins)\n ? buildConfig.plugins\n : [buildConfig.plugins]\n : [];\n\n plugins.push(CLI.createTsdownLogger());\n\n await build({\n ...buildConfig,\n logLevel: 'silent',\n plugins,\n });\n }\n\n if (!sharding) {\n logger.error('Sharding is not enabled in the config file');\n process.exit(1);\n }\n\n Reflect.set(global, 'useLogger', () => logger);\n\n const eventListeners = new EventListeners();\n const manager = new ShardingManager(CLI.bin, {\n ...sharding,\n token: token,\n shardArgs\n });\n\n manager.on('shardCreate', shard => {\n logger.log(colors.magenta(`🚀 Launched shard ${colors.green(String(shard.id))}`));\n\n shard.on('ready', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} is ready!`));\n\n if (process.env.RECIPLE_FIRST_SHARD === 'true') {\n process.env.RECIPLE_FIRST_SHARD = 'false';\n }\n });\n\n shard.on('reconnecting', () => {\n logger.log(colors.magenta(`🔄 Shard ${colors.green(String(shard.id))} is reconnecting...`));\n });\n\n shard.on('resume', () => {\n logger.log(colors.magenta(`✅ Shard ${colors.green(String(shard.id))} has resumed!`));\n });\n\n shard.on('disconnect', () => {\n logger.log(colors.magenta(`🛑 Shard ${colors.green(String(shard.id))} is disconnected!`));\n });\n\n shard.on('death', () => {\n logger.error(`🛑 Shard ${colors.green(String(shard.id))} has died!`);\n });\n\n shard.on('error', error => {\n logger.error(`❌ Shard ${colors.green(String(shard.id))} encountered an error:`, error);\n });\n\n shard.on('message', message => {\n // TODO: Handle shard messages\n });\n });\n\n eventListeners.registerProcessExitEvents(signal => this.destroyShardingManager(manager));\n process.stdin.resume();\n\n await manager.spawn();\n }\n\n public destroyShardingManager(manager: ShardingManager): void {\n const logger = useLogger();\n\n manager.shards.map(s => {\n logger.log(colors.magenta(`🚧 Destroying shard ${s.id}`));\n\n if (s.process) {\n s.process.kill();\n } else {\n s.kill();\n }\n\n logger.log(colors.magenta(`🛑 Destroyed shard ${s.id}`));\n });\n\n logger.log(colors.magenta(`🚨 Destroyed all shards`));\n setTimeout(() => process.exit(0), 500);\n }\n}\n\nexport namespace ShardingSubcommand {\n export interface Flags extends StartSubcommand.Flags {}\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAqB,0BAArB,cAAqD,cAAc;CAC/D,AAAO,SAAkB;CAEzB,AAAO,aAAsB,IAAI,QAAQ,WAAW,CAC/C,YAAY,4CAA4C,CACxD,SAAS,aAAa,qCAAqC,CAC3D,OAAO,8BAA8B,6BAA6B,CAClE,OAAO,eAAe,+CAA+C,CACrE,mBAAmB,KAAK;CAE7B,MAAa,UAAyB;AAClC,UAAQ,IAAI,mBAAmB;AAC/B,UAAQ,IAAI,sBAAsB;EAElC,MAAM,eAAe,KAAK,IAAI,UAAU;EACxC,MAAM,QAAQ,KAAK,WAAW,MAAgC;AAE9D,QAAM,KAAK,IAAI,oBAAoB,KAAK,WAAW,KAAK,GAAG;EAE3D,MAAM,YAAsB;GACxB,GAAG,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AAC;IAC1D;AAEF,WAAO,IAAI,OAAO,QAAQ,0BAA0B,CAAC;AACrD,mBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI"}
@@ -94,7 +94,7 @@ var CLI = class {
94
94
  (function(_CLI) {
95
95
  _CLI.root = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../../");
96
96
  _CLI.bin = path.join(CLI.root, "dist/bin/reciple.mjs");
97
- _CLI.version = "10.0.14";
97
+ _CLI.version = "10.0.16";
98
98
  function stringifyFlags(flags, command, ignored = []) {
99
99
  let arr = [];
100
100
  for (const [key, value] of Object.entries(flags)) {
@@ -31,11 +31,17 @@ var ConfigReader = class ConfigReader {
31
31
  }
32
32
  async read(options) {
33
33
  let module;
34
- if (RuntimeEnvironment.get() === "node") module = await createJiti(path.resolve(path.dirname(this.filepath))).import(`./${path.basename(this.filepath)}`, {
35
- default: true,
36
- ...options
37
- });
38
- else module = await import(`file://${path.resolve(this.filepath)}`);
34
+ switch (RuntimeEnvironment.get()) {
35
+ case "bun":
36
+ module = await import(`file://${path.resolve(this.filepath)}`);
37
+ break;
38
+ case "deno":
39
+ case "node":
40
+ default: module = await createJiti(path.resolve(path.dirname(this.filepath))).import(`./${path.basename(this.filepath)}`, {
41
+ default: true,
42
+ ...options
43
+ });
44
+ }
39
45
  if (!module || !module.client) throw new RecipleError(`exported client is not an instance of ${colors.cyan("Client")} from ${colors.green("\"@reciple/core\"")}.`);
40
46
  this._client = module.client;
41
47
  this._config = module.config ?? null;
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigReader.mjs","names":[],"sources":["../../../src/classes/cli/ConfigReader.ts"],"sourcesContent":["import type { ModuleLoader } from '../client/ModuleLoader.js';\nimport type { ModuleManager } from '../managers/ModuleManager.js';\nimport type { EventListeners } from '../client/EventListeners.js';\nimport type { Logger } from '@prtty/print';\nimport { CLI } from './CLI.js';\nimport { Client, RecipleError, type Config } from '@reciple/core';\nimport type { BuildConfig } from '../../helpers/types.js';\nimport type { UserConfig as TsdownConfig } from 'tsdown';\nimport path from 'node:path';\nimport { mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { resolveTSConfig } from 'pkg-types';\nimport { colors } from '@prtty/prtty';\nimport type { ShardingManagerOptions } from 'discord.js';\nimport { createJiti, type JitiResolveOptions } from 'jiti';\nimport { RuntimeEnvironment } from './RuntimeEnvironment.js';\n\ndeclare module \"@reciple/core\" {\n interface Config {\n token?: string;\n modules?: ModuleLoader.Config;\n logger?: Logger|Logger.Options;\n }\n\n interface Client {\n readonly modules: ModuleManager;\n readonly moduleLoader: ModuleLoader;\n readonly eventListeners: EventListeners;\n readonly cli: CLI;\n logger: Logger;\n }\n}\n\nexport class ConfigReader {\n private _client: Client|null = null;\n private _config: Config|null = null;\n private _build: BuildConfig|null = null;\n private _sharding: ShardingManagerOptions|null = null;\n\n get client() {\n if (!this._client) throw new RecipleError('client is not yet loaded from config.');\n return this._client;\n }\n\n get config() {\n return this._config ?? {};\n }\n\n get build() {\n return ConfigReader.normalizeTsdownConfig({\n overrides: this._build ?? {}\n });\n }\n\n get sharding() {\n return this._sharding;\n }\n\n constructor(public readonly filepath: string) {}\n\n public async read(options?: JitiResolveOptions): Promise<ConfigReader> {\n let module: ConfigReader.ModuleData;\n\n if (RuntimeEnvironment.get() === 'node') {\n const jiti = createJiti(path.resolve(path.dirname(this.filepath)));\n module = await jiti.import<ConfigReader.ModuleData>(`./${path.basename(this.filepath)}`, {\n default: true,\n ...options\n });\n } else {\n module = await import(`file://${path.resolve(this.filepath)}`);\n }\n\n if (!module || !module.client) {\n throw new RecipleError(`exported client is not an instance of ${colors.cyan('Client')} from ${colors.green('\"@reciple/core\"')}.`);\n }\n\n this._client = module.client;\n this._config = module.config ?? null;\n this._build = module.build ?? null;\n this._sharding = module.sharding ?? null;\n\n return this;\n }\n\n public async create(options: Omit<ConfigReader.CreateOptions, 'path'>): Promise<ConfigReader> {\n const exists = await ConfigReader.exists(this.filepath);\n\n if (exists && options.throwIfExists === true) {\n throw new RecipleError(`Config file already exists at ${colors.green(path.relative(process.cwd(), this.filepath))}.`);\n }\n\n if (!exists || exists && options.overwrite !== false) {\n await mkdir(path.dirname(this.filepath), { recursive: true });\n await writeFile(this.filepath, await ConfigReader.getDefaultContent(options.type));\n }\n\n return options.readOptions !== false ? this.read(options.readOptions) : this;\n }\n\n public static async exists(file: string): Promise<boolean> {\n return await stat(file).then(s => s.isFile()).catch(() => false);\n }\n\n public static async create(options: ConfigReader.CreateOptions): Promise<ConfigReader> {\n return new ConfigReader(options.path).create(options);\n }\n\n public static async find(options?: ConfigReader.FindOptions): Promise<string|null> {\n const filenames = ConfigReader.configFilenames.filter(f => !options?.lang || f.endsWith(options.lang));\n const directories = options?.directories ?? ['.', '.config'];\n\n for (const directory of directories) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats?.isDirectory()) continue;\n\n const file = (await readdir(directory)).find(f => filenames.includes(f));\n if (file) return path.join(directory, file);\n }\n\n return null;\n }\n}\n\nexport namespace ConfigReader {\n export interface ModuleData {\n client: Client;\n config?: Config;\n build?: BuildConfig;\n sharding?: ShardingManagerOptions;\n }\n\n export interface CreateOptions {\n path: string;\n overwrite?: boolean;\n throwIfExists?: boolean;\n type: LangType;\n readOptions?: JitiResolveOptions|false;\n }\n\n export interface FindOptions {\n lang?: LangType;\n directories?: string[];\n }\n\n export async function getProjectLang(cwd: string): Promise<LangType> {\n const hasTsConfig = !!await resolveTSConfig(cwd, { try: true });\n const configLangIsTypescript = !!(await ConfigReader.find({\n directories: [cwd, path.join(cwd, '.config')],\n lang: 'ts'\n }));\n\n return hasTsConfig || configLangIsTypescript ? 'ts' : 'js';\n }\n\n export type LangType = 'ts'|'js';\n\n export const defaultConfigPath = {\n ts: path.join(CLI.root, 'assets/config', `reciple.config.ts`),\n js: path.join(CLI.root, 'assets/config', `reciple.config.js`)\n };\n\n export async function getDefaultContent(type: LangType): Promise<string> {\n const filepath = ConfigReader.defaultConfigPath[type];\n const content = await readFile(filepath, 'utf-8');\n return content;\n }\n\n export const configFilenames = [\n 'reciple.config.ts',\n 'reciple.config.mts',\n 'reciple.config.js',\n 'reciple.config.mjs'\n ];\n\n export function createConfigFilename(type: LangType, esm: boolean = false): string {\n return `reciple.config.${esm ? 'm' : ''}${type}`;\n }\n\n export function normalizeTsdownConfig({ type, overrides }: { type?: LangType; overrides?: BuildConfig; } = {}): TsdownConfig {\n return {\n entry: [`./src/**/*.{ts,tsx,js,jsx}`],\n outDir: './modules',\n tsconfig: `./${type ?? 'ts'}config.json`,\n external: [],\n noExternal: [],\n sourcemap: true,\n treeshake: true,\n clean: true,\n ...overrides,\n watch: false,\n platform: 'node',\n format: 'esm',\n unbundle: true,\n skipNodeModulesBundle: true\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAgCA,IAAa,eAAb,MAAa,aAAa;CACtB,AAAQ,UAAuB;CAC/B,AAAQ,UAAuB;CAC/B,AAAQ,SAA2B;CACnC,AAAQ,YAAyC;CAEjD,IAAI,SAAS;AACT,MAAI,CAAC,KAAK,QAAS,OAAM,IAAI,aAAa,wCAAwC;AAClF,SAAO,KAAK;;CAGhB,IAAI,SAAS;AACT,SAAO,KAAK,WAAW,EAAE;;CAG7B,IAAI,QAAQ;AACR,SAAO,aAAa,sBAAsB,EACtC,WAAW,KAAK,UAAU,EAAE,EAC/B,CAAC;;CAGN,IAAI,WAAW;AACX,SAAO,KAAK;;CAGhB,YAAY,AAAgB,UAAkB;EAAlB;;CAE5B,MAAa,KAAK,SAAqD;EACnE,IAAI;AAEJ,MAAI,mBAAmB,KAAK,KAAK,OAE7B,UAAS,MADI,WAAW,KAAK,QAAQ,KAAK,QAAQ,KAAK,SAAS,CAAC,CAAC,CAC9C,OAAgC,KAAK,KAAK,SAAS,KAAK,SAAS,IAAI;GACrF,SAAS;GACT,GAAG;GACN,CAAC;MAEF,UAAS,MAAM,OAAO,UAAU,KAAK,QAAQ,KAAK,SAAS;AAG/D,MAAI,CAAC,UAAU,CAAC,OAAO,OACnB,OAAM,I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AU,SAAS,EAAE,CAAC;AACxE,OAAI,KAAM,QAAO,KAAK,KAAK,WAAW,KAAK;;AAG/C,SAAO;;;;CAyBJ,eAAe,eAAe,KAAgC;EACjE,MAAM,cAAc,CAAC,CAAC,MAAM,gBAAgB,KAAK,EAAE,KAAK,MAAM,CAAC;EAC/D,MAAM,yBAAyB,CAAC,CAAE,MAAM,aAAa,KAAK;GACtD,aAAa,CAAC,KAAK,KAAK,KAAK,KAAK,UAAU,CAAC;GAC7C,MAAM;GACT,CAAC;AAEF,SAAO,eAAe,yBAAyB,OAAO;;;mCAKzB;EAC7B,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAC7D,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAChE;CAEM,eAAe,kBAAkB,MAAiC;EACrE,MAAM,WAAW,aAAa,kBAAkB;AAEhD,SADgB,MAAM,SAAS,UAAU,QAAQ;;;iCAItB;EAC3B;EACA;EACA;EACA;EACH;CAEM,SAAS,qBAAqB,MAAgB,MAAe,OAAe;AAC/E,SAAO,kBAAkB,MAAM,MAAM,KAAK;;;CAGvC,SAAS,sBAAsB,EAAE,MAAM,cAA6D,EAAE,EAAgB;AACzH,SAAO;GACH,OAAO,CAAC,6BAA6B;GACrC,QAAQ;GACR,UAAU,KAAK,QAAQ,KAAK;GAC5B,UAAU,EAAE;GACZ,YAAY,EAAE;GACd,WAAW;GACX,WAAW;GACX,OAAO;GACP,GAAG;GACH,OAAO;GACP,UAAU;GACV,QAAQ;GACR,UAAU;GACV,uBAAuB;GAC1B"}
1
+ {"version":3,"file":"ConfigReader.mjs","names":[],"sources":["../../../src/classes/cli/ConfigReader.ts"],"sourcesContent":["import type { ModuleLoader } from '../client/ModuleLoader.js';\nimport type { ModuleManager } from '../managers/ModuleManager.js';\nimport type { EventListeners } from '../client/EventListeners.js';\nimport type { Logger } from '@prtty/print';\nimport { CLI } from './CLI.js';\nimport { Client, RecipleError, type Config } from '@reciple/core';\nimport type { BuildConfig } from '../../helpers/types.js';\nimport type { UserConfig as TsdownConfig } from 'tsdown';\nimport path from 'node:path';\nimport { mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';\nimport { resolveTSConfig } from 'pkg-types';\nimport { colors } from '@prtty/prtty';\nimport type { ShardingManagerOptions } from 'discord.js';\nimport { createJiti, type JitiResolveOptions } from 'jiti';\nimport { RuntimeEnvironment } from './RuntimeEnvironment.js';\n\ndeclare module \"@reciple/core\" {\n interface Config {\n token?: string;\n modules?: ModuleLoader.Config;\n logger?: Logger|Logger.Options;\n }\n\n interface Client {\n readonly modules: ModuleManager;\n readonly moduleLoader: ModuleLoader;\n readonly eventListeners: EventListeners;\n readonly cli: CLI;\n logger: Logger;\n }\n}\n\nexport class ConfigReader {\n private _client: Client|null = null;\n private _config: Config|null = null;\n private _build: BuildConfig|null = null;\n private _sharding: ShardingManagerOptions|null = null;\n\n get client() {\n if (!this._client) throw new RecipleError('client is not yet loaded from config.');\n return this._client;\n }\n\n get config() {\n return this._config ?? {};\n }\n\n get build() {\n return ConfigReader.normalizeTsdownConfig({\n overrides: this._build ?? {}\n });\n }\n\n get sharding() {\n return this._sharding;\n }\n\n constructor(public readonly filepath: string) {}\n\n public async read(options?: JitiResolveOptions): Promise<ConfigReader> {\n let module: ConfigReader.ModuleData;\n\n const runtime = RuntimeEnvironment.get();\n switch (runtime) {\n case 'bun':\n module = await import(`file://${path.resolve(this.filepath)}`);\n break;\n case 'deno':\n case 'node':\n default:\n const jiti = createJiti(path.resolve(path.dirname(this.filepath)));\n module = await jiti.import<ConfigReader.ModuleData>(`./${path.basename(this.filepath)}`, {\n default: true,\n ...options\n });\n }\n\n if (!module || !module.client) {\n throw new RecipleError(`exported client is not an instance of ${colors.cyan('Client')} from ${colors.green('\"@reciple/core\"')}.`);\n }\n\n this._client = module.client;\n this._config = module.config ?? null;\n this._build = module.build ?? null;\n this._sharding = module.sharding ?? null;\n\n return this;\n }\n\n public async create(options: Omit<ConfigReader.CreateOptions, 'path'>): Promise<ConfigReader> {\n const exists = await ConfigReader.exists(this.filepath);\n\n if (exists && options.throwIfExists === true) {\n throw new RecipleError(`Config file already exists at ${colors.green(path.relative(process.cwd(), this.filepath))}.`);\n }\n\n if (!exists || exists && options.overwrite !== false) {\n await mkdir(path.dirname(this.filepath), { recursive: true });\n await writeFile(this.filepath, await ConfigReader.getDefaultContent(options.type));\n }\n\n return options.readOptions !== false ? this.read(options.readOptions) : this;\n }\n\n public static async exists(file: string): Promise<boolean> {\n return await stat(file).then(s => s.isFile()).catch(() => false);\n }\n\n public static async create(options: ConfigReader.CreateOptions): Promise<ConfigReader> {\n return new ConfigReader(options.path).create(options);\n }\n\n public static async find(options?: ConfigReader.FindOptions): Promise<string|null> {\n const filenames = ConfigReader.configFilenames.filter(f => !options?.lang || f.endsWith(options.lang));\n const directories = options?.directories ?? ['.', '.config'];\n\n for (const directory of directories) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats?.isDirectory()) continue;\n\n const file = (await readdir(directory)).find(f => filenames.includes(f));\n if (file) return path.join(directory, file);\n }\n\n return null;\n }\n}\n\nexport namespace ConfigReader {\n export interface ModuleData {\n client: Client;\n config?: Config;\n build?: BuildConfig;\n sharding?: ShardingManagerOptions;\n }\n\n export interface CreateOptions {\n path: string;\n overwrite?: boolean;\n throwIfExists?: boolean;\n type: LangType;\n readOptions?: JitiResolveOptions|false;\n }\n\n export interface FindOptions {\n lang?: LangType;\n directories?: string[];\n }\n\n export async function getProjectLang(cwd: string): Promise<LangType> {\n const hasTsConfig = !!await resolveTSConfig(cwd, { try: true });\n const configLangIsTypescript = !!(await ConfigReader.find({\n directories: [cwd, path.join(cwd, '.config')],\n lang: 'ts'\n }));\n\n return hasTsConfig || configLangIsTypescript ? 'ts' : 'js';\n }\n\n export type LangType = 'ts'|'js';\n\n export const defaultConfigPath = {\n ts: path.join(CLI.root, 'assets/config', `reciple.config.ts`),\n js: path.join(CLI.root, 'assets/config', `reciple.config.js`)\n };\n\n export async function getDefaultContent(type: LangType): Promise<string> {\n const filepath = ConfigReader.defaultConfigPath[type];\n const content = await readFile(filepath, 'utf-8');\n return content;\n }\n\n export const configFilenames = [\n 'reciple.config.ts',\n 'reciple.config.mts',\n 'reciple.config.js',\n 'reciple.config.mjs'\n ];\n\n export function createConfigFilename(type: LangType, esm: boolean = false): string {\n return `reciple.config.${esm ? 'm' : ''}${type}`;\n }\n\n export function normalizeTsdownConfig({ type, overrides }: { type?: LangType; overrides?: BuildConfig; } = {}): TsdownConfig {\n return {\n entry: [`./src/**/*.{ts,tsx,js,jsx}`],\n outDir: './modules',\n tsconfig: `./${type ?? 'ts'}config.json`,\n external: [],\n noExternal: [],\n sourcemap: true,\n treeshake: true,\n clean: true,\n ...overrides,\n watch: false,\n platform: 'node',\n format: 'esm',\n unbundle: true,\n skipNodeModulesBundle: true\n };\n }\n}\n"],"mappings":";;;;;;;;;;AAgCA,IAAa,eAAb,MAAa,aAAa;CACtB,AAAQ,UAAuB;CAC/B,AAAQ,UAAuB;CAC/B,AAAQ,SAA2B;CACnC,AAAQ,YAAyC;CAEjD,IAAI,SAAS;AACT,MAAI,CAAC,KAAK,QAAS,OAAM,IAAI,aAAa,wCAAwC;AAClF,SAAO,KAAK;;CAGhB,IAAI,SAAS;AACT,SAAO,KAAK,WAAW,EAAE;;CAG7B,IAAI,QAAQ;AACR,SAAO,aAAa,sBAAsB,EACtC,WAAW,KAAK,UAAU,EAAE,EAC/B,CAAC;;CAGN,IAAI,WAAW;AACX,SAAO,KAAK;;CAGhB,YAAY,AAAgB,UAAkB;EAAlB;;CAE5B,MAAa,KAAK,SAAqD;EACnE,IAAI;AAGJ,UADgB,mBAAmB,KAAK,EACxC;GACI,KAAK;AACD,aAAS,MAAM,OAAO,UAAU,KAAK,QAAQ,KAAK,SAAS;AAC3D;GACJ,KAAK;GACL,KAAK;GACL,QAEI,UAAS,MADI,WAAW,KAAK,QAAQ,KAAK,QAAQ,KAAK,SAAS,CAAC,CAAC,CAC9C,OA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AI,EAFU,MAAM,KAAK,UAAU,CAAC,YAAY,OAAU,GAE9C,aAAa,CAAE;GAE3B,MAAM,QAAQ,MAAM,QAAQ,UAAU,EAAE,MAAK,MAAK,UAAU,SAAS,EAAE,CAAC;AACxE,OAAI,KAAM,QAAO,KAAK,KAAK,WAAW,KAAK;;AAG/C,SAAO;;;;CAyBJ,eAAe,eAAe,KAAgC;EACjE,MAAM,cAAc,CAAC,CAAC,MAAM,gBAAgB,KAAK,EAAE,KAAK,MAAM,CAAC;EAC/D,MAAM,yBAAyB,CAAC,CAAE,MAAM,aAAa,KAAK;GACtD,aAAa,CAAC,KAAK,KAAK,KAAK,KAAK,UAAU,CAAC;GAC7C,MAAM;GACT,CAAC;AAEF,SAAO,eAAe,yBAAyB,OAAO;;;mCAKzB;EAC7B,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAC7D,IAAI,KAAK,KAAK,IAAI,MAAM,iBAAiB,oBAAoB;EAChE;CAEM,eAAe,kBAAkB,MAAiC;EACrE,MAAM,WAAW,aAAa,kBAAkB;AAEhD,SADgB,MAAM,SAAS,UAAU,QAAQ;;;iCAItB;EAC3B;EACA;EACA;EACA;EACH;CAEM,SAAS,qBAAqB,MAAgB,MAAe,OAAe;AAC/E,SAAO,kBAAkB,MAAM,MAAM,KAAK;;;CAGvC,SAAS,sBAAsB,EAAE,MAAM,cAA6D,EAAE,EAAgB;AACzH,SAAO;GACH,OAAO,CAAC,6BAA6B;GACrC,QAAQ;GACR,UAAU,KAAK,QAAQ,KAAK;GAC5B,UAAU,EAAE;GACZ,YAAY,EAAE;GACd,WAAW;GACX,WAAW;GACX,OAAO;GACP,GAAG;GACH,OAAO;GACP,UAAU;GACV,QAAQ;GACR,UAAU;GACV,uBAAuB;GAC1B"}
@@ -11,14 +11,14 @@ import { CommandModuleValidator } from "../validation/CommandModuleValidator.mjs
11
11
  import { EventModuleValidator } from "../validation/EventModuleValidator.mjs";
12
12
  import { PreconditionModuleValidator } from "../validation/PreconditionModule.mjs";
13
13
  import { PostconditionModuleValidator } from "../validation/PostconditionModule.mjs";
14
- import path$1 from "node:path";
14
+ import path from "node:path";
15
15
  import { recursiveDefaults } from "@reciple/utils";
16
16
  import { mkdir, readdir, stat } from "node:fs/promises";
17
17
  import { colors } from "@prtty/prtty";
18
18
  import { CommandType, RecipleError } from "@reciple/core";
19
19
  import "discord.js";
20
20
  import micromatch from "micromatch";
21
- import { globby as globby$1, isDynamicPattern } from "globby";
21
+ import { globby, isDynamicPattern } from "globby";
22
22
  import { EventEmitter } from "node:events";
23
23
 
24
24
  //#region src/classes/client/ModuleLoader.ts
@@ -33,19 +33,19 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
33
33
  const modulePaths = await ModuleLoader.scanForModulePaths(this.client.config?.modules);
34
34
  const modules = [];
35
35
  this.emit("modulesResolving", modulePaths);
36
- for (const path of modulePaths) try {
37
- this.emit("moduleResolving", path);
38
- const resolved = await ModuleLoader.resolveModuleFromPath(path);
36
+ for (const path$1 of modulePaths) try {
37
+ this.emit("moduleResolving", path$1);
38
+ const resolved = await ModuleLoader.resolveModuleFromPath(path$1);
39
39
  Object.assign(resolved, {
40
40
  client: this.client,
41
- __$filepath: path
41
+ __$filepath: path$1
42
42
  });
43
43
  modules.push(resolved);
44
44
  this.emit("moduleResolved", resolved);
45
45
  } catch (error) {
46
46
  if (ignoreErrors) continue;
47
47
  this.emitOrThrow("moduleResolveError", new RecipleError({
48
- message: `Failed to load module: ${colors.cyan(path)}`,
48
+ message: `Failed to load module: ${colors.cyan(path$1)}`,
49
49
  cause: error
50
50
  }));
51
51
  }
@@ -58,7 +58,7 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
58
58
  let directories = [];
59
59
  for (const directory of config?.directories ?? []) {
60
60
  if (isDynamicPattern(directory, { cwd })) {
61
- const matches = await globby$1(directory, {
61
+ const matches = await globby(directory, {
62
62
  cwd,
63
63
  ignore: config?.ignore,
64
64
  onlyDirectories: true,
@@ -68,7 +68,7 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
68
68
  scanned.push(...matches);
69
69
  continue;
70
70
  }
71
- scanned.push(path$1.join(cwd, directory));
71
+ scanned.push(path.join(cwd, directory));
72
72
  }
73
73
  for (const directory of scanned) {
74
74
  if (!await stat(directory).catch(() => void 0) && config?.createDirectories !== false) await mkdir(directory, { recursive: true });
@@ -86,7 +86,7 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
86
86
  matchBase: true,
87
87
  dot: true
88
88
  });
89
- files = files.map((f) => path$1.join(directory, f));
89
+ files = files.map((f) => path.join(directory, f));
90
90
  for (const file of files) {
91
91
  if (config?.filter ? !await config?.filter(file) : ModuleLoader.fileTypes.every((type) => !file.endsWith(`.${type}`))) continue;
92
92
  modules.push(file);
@@ -97,7 +97,7 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
97
97
  }
98
98
  static async resolveModuleFromPath(filepath, options) {
99
99
  if (!await stat(filepath).catch(() => void 0)) throw new RecipleError(`Module not found: ${filepath}`);
100
- const data = recursiveDefaults(await import(`file://${path$1.resolve(options?.cwd ?? process.cwd(), filepath)}`));
100
+ const data = recursiveDefaults(await import(`file://${path.resolve(options?.cwd ?? process.cwd(), filepath)}`));
101
101
  if (BaseModule.isModule(data)) return data;
102
102
  if (data && "moduleType" in data) switch (data?.moduleType) {
103
103
  case ModuleType.Command:
@@ -125,10 +125,10 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
125
125
  return BaseModule.from(data);
126
126
  }
127
127
  static async resolveSourceDirectories(options) {
128
- const dir = path$1.isAbsolute(options.baseUrl) ? options.baseUrl : path$1.resolve(path$1.join(options.cwd ?? process.cwd(), options.baseUrl));
129
- const root = path$1.resolve(path$1.join(dir, options.rootDir));
130
- const out = path$1.resolve(path$1.join(dir, options.outDir));
131
- return options.directories.map((directory) => path$1.resolve(directory).replace(out, root));
128
+ const dir = path.isAbsolute(options.baseUrl) ? options.baseUrl : path.resolve(path.join(options.cwd ?? process.cwd(), options.baseUrl));
129
+ const root = path.resolve(path.join(dir, options.rootDir));
130
+ const out = path.resolve(path.join(dir, options.outDir));
131
+ return options.directories.map((directory) => path.resolve(directory).replace(out, root));
132
132
  }
133
133
  emitOrThrow(event, error) {
134
134
  if (this.client.listenerCount(event) > 0) return this.emit(event, error);
@@ -136,15 +136,15 @@ var ModuleLoader = class ModuleLoader extends EventEmitter {
136
136
  }
137
137
  };
138
138
  (function(_ModuleLoader) {
139
- let globby = _ModuleLoader.globby = null;
139
+ let globby$1 = _ModuleLoader.globby = null;
140
140
  _ModuleLoader.fileTypes = [
141
141
  "js",
142
142
  "mjs",
143
143
  "jsx"
144
144
  ];
145
145
  async function getGlobby() {
146
- if (globby) return globby;
147
- return globby = await import("globby");
146
+ if (globby$1) return globby$1;
147
+ return globby$1 = await import("globby");
148
148
  }
149
149
  _ModuleLoader.getGlobby = getGlobby;
150
150
  })(ModuleLoader || (ModuleLoader = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"ModuleLoader.mjs","names":["globby","path"],"sources":["../../../src/classes/client/ModuleLoader.ts"],"sourcesContent":["import { type Awaitable } from 'discord.js';\nimport path from 'node:path';\nimport { mkdir, readdir, stat } from 'node:fs/promises';\nimport micromatch from 'micromatch';\nimport { globby, isDynamicPattern } from 'globby';\nimport { CommandType, RecipleError, type Client } from '@reciple/core';\nimport type { AnyModule, AnyModuleData } from '../../helpers/types.js';\nimport { recursiveDefaults } from '@reciple/utils';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { BaseModuleValidator } from '../validation/BaseModuleValidator.js';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { PostconditionModule } from '../modules/PostconditionModule.js';\nimport { PreconditionModule } from '../modules/PreconditionModule.js';\nimport { EventModule } from '../modules/events/EventModule.js';\nimport { MessageCommandModule } from '../modules/commands/MessageCommandModule.js';\nimport { SlashCommandModule } from '../modules/commands/SlashCommandModule.js';\nimport { ContextMenuCommandModule } from '../modules/commands/ContextMenuCommandModule.js';\nimport { CommandModuleValidator } from '../validation/CommandModuleValidator.js';\nimport { EventModuleValidator } from '../validation/EventModuleValidator.js';\nimport { PreconditionModuleValidator } from '../validation/PreconditionModule.js';\nimport { PostconditionModuleValidator } from '../validation/PostconditionModule.js';\nimport type { Logger } from '@prtty/print';\nimport { EventEmitter } from 'node:events';\nimport { colors } from '@prtty/prtty';\n\nexport class ModuleLoader extends EventEmitter<ModuleLoader.Events> {\n public readonly logger: Logger;\n\n constructor(public readonly client: Client) {\n super();\n\n this.logger = this.client.logger.clone({\n label: 'ModuleLoader'\n });\n }\n\n public async findModules(ignoreErrors: boolean = false): Promise<AnyModule[]> {\n const modulePaths = await ModuleLoader.scanForModulePaths(this.client.config?.modules);\n const modules: AnyModule[] = [];\n\n this.emit('modulesResolving', modulePaths);\n\n for (const path of modulePaths) {\n try {\n this.emit('moduleResolving', path);\n const resolved = await ModuleLoader.resolveModuleFromPath(path);\n\n Object.assign(resolved, { client: this.client, __$filepath: path });\n modules.push(resolved);\n\n this.emit('moduleResolved', resolved);\n } catch (error) {\n if (ignoreErrors) continue;\n\n this.emitOrThrow('moduleResolveError', new RecipleError({\n message: `Failed to load module: ${colors.cyan(path)}`,\n cause: error\n }));\n }\n }\n\n this.emit('modulesResolved', modules);\n return modules;\n }\n\n public static async scanForDirectories(config?: Pick<ModuleLoader.Config, 'directories'|'ignore'> & { cwd?: string; createDirectories?: boolean; }) {\n const cwd = config?.cwd ?? process.cwd();\n\n let scanned: string[] = [];\n let directories: string[] = [];\n\n for (const directory of config?.directories ?? []) {\n if (isDynamicPattern(directory, { cwd })) {\n const matches = await globby(directory, {\n cwd,\n ignore: config?.ignore,\n onlyDirectories: true,\n baseNameMatch: true,\n absolute: true\n });\n\n scanned.push(...matches);\n continue;\n }\n\n scanned.push(path.join(cwd, directory));\n }\n\n for (const directory of scanned) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats && config?.createDirectories !== false) {\n await mkdir(directory, { recursive: true });\n }\n\n directories.push(directory);\n }\n\n return directories;\n }\n\n public static async scanForModulePaths(config?: ModuleLoader.Config & { cwd?: string; createDirectories?: boolean; }): Promise<string[]> {\n const directories = await ModuleLoader.scanForDirectories(config);\n\n let modules: string[] = [];\n\n for (const directory of directories) {\n let files = await readdir(directory);\n\n if (config?.ignore?.length) {\n files = micromatch.not(files, config.ignore, {\n cwd: directory,\n matchBase: true,\n dot: true\n });\n }\n\n files = files.map(f => path.join(directory, f));\n\n for (const file of files) {\n if (config?.filter ? !(await config?.filter(file)) : ModuleLoader.fileTypes.every(type => !file.endsWith(`.${type}`))) continue;\n modules.push(file);\n }\n }\n\n if (config?.sort) modules.sort(config.sort);\n\n return modules;\n }\n\n public static async resolveModuleFromPath(filepath: string, options?: { cwd?: string; }): Promise<AnyModule> {\n const stats = await stat(filepath).catch(() => undefined);\n if (!stats) throw new RecipleError(`Module not found: ${filepath}`);\n\n const data = recursiveDefaults<AnyModule|AnyModuleData|undefined>(await import(`file://${path.resolve(options?.cwd ?? process.cwd(), filepath)}`));\n if (BaseModule.isModule(data)) return data;\n\n if (data && 'moduleType' in data) {\n switch (data?.moduleType) {\n case ModuleType.Command:\n CommandModuleValidator.isValid(data);\n switch (data.type) {\n case CommandType.Message: return MessageCommandModule.from(data);\n case CommandType.Slash: return SlashCommandModule.from(data);\n case CommandType.ContextMenu: return ContextMenuCommandModule.from(data);\n default: throw new RecipleError(`Unknown command type from module: ${colors.cyan(filepath)}`);\n }\n case ModuleType.Event:\n EventModuleValidator.isValid(data);\n return EventModule.from(data);\n case ModuleType.Precondition:\n PreconditionModuleValidator.isValid(data);\n return PreconditionModule.from(data);\n case ModuleType.Postcondition:\n PostconditionModuleValidator.isValid(data);\n return PostconditionModule.from(data);\n default:\n BaseModuleValidator.isValid(data);\n return BaseModule.from(data);\n }\n }\n\n BaseModuleValidator.isValid(data);\n return BaseModule.from(data);\n }\n\n public static async resolveSourceDirectories(options: ModuleLoader.ResolveSourceDirectoryOptions): Promise<string[]> {\n const dir = path.isAbsolute(options.baseUrl) ? options.baseUrl : path.resolve(path.join(options.cwd ?? process.cwd(), options.baseUrl));\n\n const root = path.resolve(path.join(dir, options.rootDir));\n const out = path.resolve(path.join(dir, options.outDir));\n\n return options.directories.map(directory => path.resolve(directory).replace(out, root));\n }\n\n private emitOrThrow<K extends keyof Pick<ModuleLoader.Events, 'moduleResolveError'>>(event: K, error: RecipleError) {\n if (this.client.listenerCount(event) > 0) {\n // @ts-expect-error\n return this.emit(event, error);\n }\n\n throw error;\n }\n}\n\nexport namespace ModuleLoader {\n export let globby: typeof import('globby')|null = null;\n\n export const fileTypes = [\n 'js',\n 'mjs',\n 'jsx'\n ];\n\n export interface Config {\n directories?: string[];\n ignore?: string[];\n filter?: (filepath: string) => Awaitable<boolean>;\n sort?: (a: string, b: string) => number;\n }\n\n export interface Events {\n moduleResolveError: [error: RecipleError];\n moduleResolved: [module: AnyModule];\n moduleResolving: [filepath: string];\n modulesResolved: [modules: AnyModule[]];\n modulesResolving: [files: string[]];\n }\n\n export interface ResolveSourceDirectoryOptions {\n directories: string[];\n baseUrl: string;\n rootDir: string;\n outDir: string;\n cwd?: string;\n }\n\n export async function getGlobby(): Promise<typeof import('globby')> {\n if (globby) return globby;\n\n return globby = await import('globby');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAb,MAAa,qBAAqB,aAAkC;CAChE,AAAgB;CAEhB,YAAY,AAAgB,QAAgB;AACxC,SAAO;EADiB;AAGxB,OAAK,SAAS,KAAK,OAAO,OAAO,MAAM,EACnC,OAAO,gBACV,CAAC;;CAGN,MAAa,YAAY,eAAwB,OAA6B;EAC1E,MAAM,cAAc,MAAM,aAAa,mBAAmB,KAAK,OAAO,QAAQ,QAAQ;EACtF,MAAM,UAAuB,EAAE;AAE/B,OAAK,KAAK,oBAAoB,YAAY;AAE1C,OAAK,MAAM,QAAQ,YACf,KAAI;AACA,QAAK,KAAK,mBAAmB,KAAK;GAClC,MAAM,WAAW,MAAM,aAAa,sBAAsB,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K;;AAIxC,sBAAoB,QAAQ,KAAK;AACjC,SAAO,WAAW,KAAK,KAAK;;CAGhC,aAAoB,yBAAyB,SAAwE;EACjH,MAAM,MAAMA,OAAK,WAAW,QAAQ,QAAQ,GAAG,QAAQ,UAAUA,OAAK,QAAQA,OAAK,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,QAAQ,QAAQ,CAAC;EAEvI,MAAM,OAAOA,OAAK,QAAQA,OAAK,KAAK,KAAK,QAAQ,QAAQ,CAAC;EAC1D,MAAM,MAAMA,OAAK,QAAQA,OAAK,KAAK,KAAK,QAAQ,OAAO,CAAC;AAExD,SAAO,QAAQ,YAAY,KAAI,cAAaA,OAAK,QAAQ,UAAU,CAAC,QAAQ,KAAK,KAAK,CAAC;;CAG3F,AAAQ,YAA6E,OAAU,OAAqB;AAChH,MAAI,KAAK,OAAO,cAAc,MAAM,GAAG,EAEnC,QAAO,KAAK,KAAK,OAAO,MAAM;AAGlC,QAAM;;;;CAKH,IAAI,gCAAuC;2BAEzB;EACrB;EACA;EACA;EACH;CAyBM,eAAe,YAA8C;AAChE,MAAI,OAAQ,QAAO;AAEnB,SAAO,SAAS,MAAM,OAAO"}
1
+ {"version":3,"file":"ModuleLoader.mjs","names":["path","globby"],"sources":["../../../src/classes/client/ModuleLoader.ts"],"sourcesContent":["import { type Awaitable } from 'discord.js';\nimport path from 'node:path';\nimport { mkdir, readdir, stat } from 'node:fs/promises';\nimport micromatch from 'micromatch';\nimport { globby, isDynamicPattern } from 'globby';\nimport { CommandType, RecipleError, type Client } from '@reciple/core';\nimport type { AnyModule, AnyModuleData } from '../../helpers/types.js';\nimport { recursiveDefaults } from '@reciple/utils';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { BaseModuleValidator } from '../validation/BaseModuleValidator.js';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { PostconditionModule } from '../modules/PostconditionModule.js';\nimport { PreconditionModule } from '../modules/PreconditionModule.js';\nimport { EventModule } from '../modules/events/EventModule.js';\nimport { MessageCommandModule } from '../modules/commands/MessageCommandModule.js';\nimport { SlashCommandModule } from '../modules/commands/SlashCommandModule.js';\nimport { ContextMenuCommandModule } from '../modules/commands/ContextMenuCommandModule.js';\nimport { CommandModuleValidator } from '../validation/CommandModuleValidator.js';\nimport { EventModuleValidator } from '../validation/EventModuleValidator.js';\nimport { PreconditionModuleValidator } from '../validation/PreconditionModule.js';\nimport { PostconditionModuleValidator } from '../validation/PostconditionModule.js';\nimport type { Logger } from '@prtty/print';\nimport { EventEmitter } from 'node:events';\nimport { colors } from '@prtty/prtty';\n\nexport class ModuleLoader extends EventEmitter<ModuleLoader.Events> {\n public readonly logger: Logger;\n\n constructor(public readonly client: Client) {\n super();\n\n this.logger = this.client.logger.clone({\n label: 'ModuleLoader'\n });\n }\n\n public async findModules(ignoreErrors: boolean = false): Promise<AnyModule[]> {\n const modulePaths = await ModuleLoader.scanForModulePaths(this.client.config?.modules);\n const modules: AnyModule[] = [];\n\n this.emit('modulesResolving', modulePaths);\n\n for (const path of modulePaths) {\n try {\n this.emit('moduleResolving', path);\n const resolved = await ModuleLoader.resolveModuleFromPath(path);\n\n Object.assign(resolved, { client: this.client, __$filepath: path });\n modules.push(resolved);\n\n this.emit('moduleResolved', resolved);\n } catch (error) {\n if (ignoreErrors) continue;\n\n this.emitOrThrow('moduleResolveError', new RecipleError({\n message: `Failed to load module: ${colors.cyan(path)}`,\n cause: error\n }));\n }\n }\n\n this.emit('modulesResolved', modules);\n return modules;\n }\n\n public static async scanForDirectories(config?: Pick<ModuleLoader.Config, 'directories'|'ignore'> & { cwd?: string; createDirectories?: boolean; }) {\n const cwd = config?.cwd ?? process.cwd();\n\n let scanned: string[] = [];\n let directories: string[] = [];\n\n for (const directory of config?.directories ?? []) {\n if (isDynamicPattern(directory, { cwd })) {\n const matches = await globby(directory, {\n cwd,\n ignore: config?.ignore,\n onlyDirectories: true,\n baseNameMatch: true,\n absolute: true\n });\n\n scanned.push(...matches);\n continue;\n }\n\n scanned.push(path.join(cwd, directory));\n }\n\n for (const directory of scanned) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats && config?.createDirectories !== false) {\n await mkdir(directory, { recursive: true });\n }\n\n directories.push(directory);\n }\n\n return directories;\n }\n\n public static async scanForModulePaths(config?: ModuleLoader.Config & { cwd?: string; createDirectories?: boolean; }): Promise<string[]> {\n const directories = await ModuleLoader.scanForDirectories(config);\n\n let modules: string[] = [];\n\n for (const directory of directories) {\n let files = await readdir(directory);\n\n if (config?.ignore?.length) {\n files = micromatch.not(files, config.ignore, {\n cwd: directory,\n matchBase: true,\n dot: true\n });\n }\n\n files = files.map(f => path.join(directory, f));\n\n for (const file of files) {\n if (config?.filter ? !(await config?.filter(file)) : ModuleLoader.fileTypes.every(type => !file.endsWith(`.${type}`))) continue;\n modules.push(file);\n }\n }\n\n if (config?.sort) modules.sort(config.sort);\n\n return modules;\n }\n\n public static async resolveModuleFromPath(filepath: string, options?: { cwd?: string; }): Promise<AnyModule> {\n const stats = await stat(filepath).catch(() => undefined);\n if (!stats) throw new RecipleError(`Module not found: ${filepath}`);\n\n const data = recursiveDefaults<AnyModule|AnyModuleData|undefined>(await import(`file://${path.resolve(options?.cwd ?? process.cwd(), filepath)}`));\n if (BaseModule.isModule(data)) return data;\n\n if (data && 'moduleType' in data) {\n switch (data?.moduleType) {\n case ModuleType.Command:\n CommandModuleValidator.isValid(data);\n switch (data.type) {\n case CommandType.Message: return MessageCommandModule.from(data);\n case CommandType.Slash: return SlashCommandModule.from(data);\n case CommandType.ContextMenu: return ContextMenuCommandModule.from(data);\n default: throw new RecipleError(`Unknown command type from module: ${colors.cyan(filepath)}`);\n }\n case ModuleType.Event:\n EventModuleValidator.isValid(data);\n return EventModule.from(data);\n case ModuleType.Precondition:\n PreconditionModuleValidator.isValid(data);\n return PreconditionModule.from(data);\n case ModuleType.Postcondition:\n PostconditionModuleValidator.isValid(data);\n return PostconditionModule.from(data);\n default:\n BaseModuleValidator.isValid(data);\n return BaseModule.from(data);\n }\n }\n\n BaseModuleValidator.isValid(data);\n return BaseModule.from(data);\n }\n\n public static async resolveSourceDirectories(options: ModuleLoader.ResolveSourceDirectoryOptions): Promise<string[]> {\n const dir = path.isAbsolute(options.baseUrl) ? options.baseUrl : path.resolve(path.join(options.cwd ?? process.cwd(), options.baseUrl));\n\n const root = path.resolve(path.join(dir, options.rootDir));\n const out = path.resolve(path.join(dir, options.outDir));\n\n return options.directories.map(directory => path.resolve(directory).replace(out, root));\n }\n\n private emitOrThrow<K extends keyof Pick<ModuleLoader.Events, 'moduleResolveError'>>(event: K, error: RecipleError) {\n if (this.client.listenerCount(event) > 0) {\n // @ts-expect-error\n return this.emit(event, error);\n }\n\n throw error;\n }\n}\n\nexport namespace ModuleLoader {\n export let globby: typeof import('globby')|null = null;\n\n export const fileTypes = [\n 'js',\n 'mjs',\n 'jsx'\n ];\n\n export interface Config {\n directories?: string[];\n ignore?: string[];\n filter?: (filepath: string) => Awaitable<boolean>;\n sort?: (a: string, b: string) => number;\n }\n\n export interface Events {\n moduleResolveError: [error: RecipleError];\n moduleResolved: [module: AnyModule];\n moduleResolving: [filepath: string];\n modulesResolved: [modules: AnyModule[]];\n modulesResolving: [files: string[]];\n }\n\n export interface ResolveSourceDirectoryOptions {\n directories: string[];\n baseUrl: string;\n rootDir: string;\n outDir: string;\n cwd?: string;\n }\n\n export async function getGlobby(): Promise<typeof import('globby')> {\n if (globby) return globby;\n\n return globby = await import('globby');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAb,MAAa,qBAAqB,aAAkC;CAChE,AAAgB;CAEhB,YAAY,AAAgB,QAAgB;AACxC,SAAO;EADiB;AAGxB,OAAK,SAAS,KAAK,OAAO,OAAO,MAAM,EACnC,OAAO,gBACV,CAAC;;CAGN,MAAa,YAAY,eAAwB,OAA6B;EAC1E,MAAM,cAAc,MAAM,aAAa,mBAAmB,KAAK,OAAO,QAAQ,QAAQ;EACtF,MAAM,UAAuB,EAA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AAK;GACxC,KAAK,WAAW;AACZ,iCAA6B,QAAQ,KAAK;AAC1C,WAAO,oBAAoB,KAAK,KAAK;GACzC;AACI,wBAAoB,QAAQ,KAAK;AACjC,WAAO,WAAW,KAAK,KAAK;;AAIxC,sBAAoB,QAAQ,KAAK;AACjC,SAAO,WAAW,KAAK,KAAK;;CAGhC,aAAoB,yBAAyB,SAAwE;EACjH,MAAM,MAAM,KAAK,WAAW,QAAQ,QAAQ,GAAG,QAAQ,UAAU,KAAK,QAAQ,KAAK,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,QAAQ,QAAQ,CAAC;EAEvI,MAAM,OAAO,KAAK,QAAQ,KAAK,KAAK,KAAK,QAAQ,QAAQ,CAAC;EAC1D,MAAM,MAAM,KAAK,QAAQ,KAAK,KAAK,KAAK,QAAQ,OAAO,CAAC;AAExD,SAAO,QAAQ,YAAY,KAAI,cAAa,KAAK,QAAQ,UAAU,CAAC,QAAQ,KAAK,KAAK,CAAC;;CAG3F,AAAQ,YAA6E,OAAU,OAAqB;AAChH,MAAI,KAAK,OAAO,cAAc,MAAM,GAAG,EAEnC,QAAO,KAAK,KAAK,OAAO,MAAM;AAGlC,QAAM;;;;CAKH,IAAIC,kCAAuC;2BAEzB;EACrB;EACA;EACA;EACH;CAyBM,eAAe,YAA8C;AAChE,MAAIA,SAAQ,QAAOA;AAEnB,SAAO,WAAS,MAAM,OAAO"}
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "../modules/BaseModule.mjs";
2
2
  import { ModuleType } from "../../helpers/constants.mjs";
3
- import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { BaseManager, RecipleError } from "@reciple/core";
5
5
  import { mix } from "ts-mixer";
6
6
  import { EventEmitter } from "node:events";
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "./BaseModule.mjs";
2
2
  import { ModuleType } from "../../helpers/constants.mjs";
3
- import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { CommandPostcondition } from "@reciple/core";
5
5
  import { hasMixin, mix } from "ts-mixer";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "./BaseModule.mjs";
2
2
  import { ModuleType } from "../../helpers/constants.mjs";
3
- import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { CommandPrecondition } from "@reciple/core";
5
5
  import { hasMixin, mix } from "ts-mixer";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "../BaseModule.mjs";
2
2
  import { ModuleType } from "../../../helpers/constants.mjs";
3
- import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { ContextMenuCommand } from "@reciple/core";
5
5
  import { DiscordSnowflake } from "@sapphire/snowflake";
6
6
  import { hasMixin, mix } from "ts-mixer";
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "../BaseModule.mjs";
2
2
  import { ModuleType } from "../../../helpers/constants.mjs";
3
- import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { MessageCommand, MessageCommandBuilder } from "@reciple/core";
5
5
  import { DiscordSnowflake } from "@sapphire/snowflake";
6
6
  import { hasMixin, mix } from "ts-mixer";
@@ -1,6 +1,6 @@
1
1
  import { BaseModule } from "../BaseModule.mjs";
2
2
  import { ModuleType } from "../../../helpers/constants.mjs";
3
- import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
3
+ import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs";
4
4
  import { SlashCommand } from "@reciple/core";
5
5
  import { DiscordSnowflake } from "@sapphire/snowflake";
6
6
  import { hasMixin, mix } from "ts-mixer";