reciple 5.5.1 → 5.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/bin.js CHANGED
@@ -34,7 +34,7 @@ const client = new RecipleClient_1.RecipleClient({ config: config, ...config.cli
34
34
  if (config.fileLogging.clientLogs)
35
35
  client.logger.info('Starting Reciple client v' + version_1.rawVersion);
36
36
  (async () => {
37
- await client.startModules((0, discord_js_1.normalizeArray)(config.modulesFolder));
37
+ await client.startModules((0, discord_js_1.normalizeArray)([config.modulesFolder]));
38
38
  client.on('ready', async () => {
39
39
  if (client.isClientLogsEnabled())
40
40
  client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
@@ -63,15 +63,25 @@ class RecipleClient extends discord_js_1.Client {
63
63
  */
64
64
  async loadModules() {
65
65
  for (const m in this.modules) {
66
- const module_ = this.modules[m];
67
- if (typeof module_.script?.onLoad === 'function') {
68
- await Promise.resolve(module_.script.onLoad(this)).catch(err => {
69
- if (this.isClientLogsEnabled()) {
70
- this.logger.error(`Error loading ${module_.info.filename ?? 'unknown module'}:`);
71
- this.logger.error(err);
72
- }
73
- this.modules = this.modules.filter((_r, i) => i.toString() !== m.toString());
74
- });
66
+ const index = (m);
67
+ const module_ = this.modules[index];
68
+ try {
69
+ if (typeof module_.script?.onLoad === 'function') {
70
+ await Promise.resolve(module_.script.onLoad(this)).catch(err => {
71
+ if (this.isClientLogsEnabled()) {
72
+ this.logger.error(`Error loading ${module_.info.filename ?? 'unknown module'}:`);
73
+ this.logger.error(err);
74
+ }
75
+ this.modules.splice(index);
76
+ });
77
+ }
78
+ }
79
+ catch (err) {
80
+ if (this.isClientLogsEnabled()) {
81
+ this.logger.error(`Error loading ${module_.info.filename ?? 'unknown module'}:`);
82
+ this.logger.error(err);
83
+ }
84
+ this.modules.splice(index);
75
85
  }
76
86
  if (module_.script?.commands && Array.isArray(module_.script?.commands)) {
77
87
  for (const command of module_.script.commands) {
@@ -87,7 +97,7 @@ class RecipleClient extends discord_js_1.Client {
87
97
  if (this.config.commands.slashCommand.registerCommands) {
88
98
  await (0, registerApplicationCommands_1.registerApplicationCommands)({
89
99
  client: this,
90
- commands: [...Object.values(this.commands.slashCommands), ...this.additionalApplicationCommands],
100
+ commands: [...this.commands.slashCommands.toJSON(), ...this.additionalApplicationCommands],
91
101
  guilds: this.config.commands.slashCommand.guilds
92
102
  });
93
103
  }
@@ -122,7 +132,7 @@ class RecipleClient extends discord_js_1.Client {
122
132
  if (registerCommands)
123
133
  await (0, registerApplicationCommands_1.registerApplicationCommands)({
124
134
  client: this,
125
- commands: [...Object.values(this.commands.slashCommands), ...this.additionalApplicationCommands],
135
+ commands: [...this.commands.slashCommands.toJSON(), ...this.additionalApplicationCommands],
126
136
  guilds: this.config.commands.slashCommand.guilds
127
137
  });
128
138
  }
@@ -58,6 +58,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
58
58
  }
59
59
  setRequiredMemberPermissions(...permissions) {
60
60
  this.requiredMemberPermissions = (0, discord_js_1.normalizeArray)(permissions);
61
+ this.setDefaultMemberPermissions(new discord_js_1.PermissionsBitField(this.requiredMemberPermissions).toArray().map(perm => discord_js_1.PermissionsBitField.resolve(perm)).reduce((prev, curr) => prev | curr));
61
62
  return this;
62
63
  }
63
64
  setHalt(halt) {
@@ -59,7 +59,7 @@ async function getModules(client, folder) {
59
59
  module_ = reqMod?.default !== undefined ? reqMod.default : reqMod;
60
60
  if (typeof module_ !== 'object')
61
61
  throw new Error(`Module ${modulePath} is not an object`);
62
- if (!client.config.disableVersionCheck && !module_?.versions.length)
62
+ if (!client.config.disableVersionCheck && !module_?.versions?.length)
63
63
  throw new Error(`${modulePath} does not have supported versions.`);
64
64
  const versions = (0, discord_js_1.normalizeArray)([module_.versions]);
65
65
  if (!client.config.disableVersionCheck && !versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
@@ -9,11 +9,10 @@ const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
9
9
  */
10
10
  async function registerApplicationCommands(options) {
11
11
  const client = options.client;
12
- const guilds = (0, discord_js_1.normalizeArray)(options.guilds);
13
- const commands = Object.values(options.commands ?? client.commands.slashCommands).map(cmd => {
14
- if (typeof cmd?.toJSON == 'undefined')
15
- return cmd;
16
- cmd = cmd;
12
+ const guilds = (0, discord_js_1.normalizeArray)([options.guilds]);
13
+ const commands = options.commands ?? client.commands.slashCommands.toJSON().map(cmd => {
14
+ if (cmd?.toJSON === undefined)
15
+ return (cmd);
17
16
  if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && client.config.commands.slashCommand.setRequiredPermissions) {
18
17
  const permissions = client.config.commands.slashCommand.permissions.enabled
19
18
  ? client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions
@@ -23,7 +22,7 @@ async function registerApplicationCommands(options) {
23
22
  if (client.isClientLogsEnabled())
24
23
  client.logger.debug(`Set required permissions for ${cmd.name}`);
25
24
  }
26
- client.commands.slashCommands.set(cmd.name, cmd);
25
+ console.log(cmd);
27
26
  }
28
27
  return cmd.toJSON();
29
28
  }) ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "5.5.1",
3
+ "version": "5.5.3",
4
4
  "bin": "dist/cjs/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "dist/cjs/index.js",
@@ -56,7 +56,7 @@
56
56
  "@discordjs/docgen": "^0.12.1",
57
57
  "@types/node": "^18.7.18",
58
58
  "@types/semver": "^7.3.12",
59
- "discord.js": "^14.3.0",
59
+ "discord.js": "^14.4.0",
60
60
  "rimraf": "^3.0.2",
61
61
  "typedoc-plugin-discord-types": "^1.0.2",
62
62
  "typedoc-plugin-djs-links": "^1.2.0",