diff --git a/src/commands/commands/load.js b/src/commands/commands/load.js index 247c88c21..e84d9c49b 100644 --- a/src/commands/commands/load.js +++ b/src/commands/commands/load.js @@ -51,7 +51,8 @@ module.exports = class LoadCommandCommand extends Command { if(this.client.shard) { try { await this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id}) { + const ids = [${this.client.shard.ids.join(',')}]; + if(!this.shard.ids.some(id => ids.includes(id))) { const cmdPath = this.registry.resolveCommandPath('${command.groupID}', '${command.name}'); delete require.cache[cmdPath]; this.registry.registerCommand(require(cmdPath)); diff --git a/src/commands/commands/reload.js b/src/commands/commands/reload.js index bdb12c726..ec0cc2e5d 100644 --- a/src/commands/commands/reload.js +++ b/src/commands/commands/reload.js @@ -37,7 +37,8 @@ module.exports = class ReloadCommandCommand extends Command { if(this.client.shard) { try { await this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id}) { + const ids = [${this.client.shard.ids.join(',')}]; + if(!this.shard.ids.some(id => ids.includes(id))) { this.registry.${isCmd ? 'commands' : 'groups'}.get('${isCmd ? cmdOrGrp.name : cmdOrGrp.id}').reload(); } `); diff --git a/src/commands/commands/unload.js b/src/commands/commands/unload.js index c4ba04e06..c51dae9d5 100644 --- a/src/commands/commands/unload.js +++ b/src/commands/commands/unload.js @@ -33,7 +33,10 @@ module.exports = class UnloadCommandCommand extends Command { if(this.client.shard) { try { await this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id}) this.registry.commands.get('${args.command.name}').unload(); + const ids = [${this.client.shard.ids.join(',')}]; + if(!this.shard.ids.some(id => ids.includes(id))) { + this.registry.commands.get('${args.command.name}').unload(); + } `); } catch(err) { this.client.emit('warn', `Error when broadcasting command unload to other shards`); diff --git a/src/providers/sqlite-sync.js b/src/providers/sqlite-sync.js index fd4b16974..cdc1beb55 100644 --- a/src/providers/sqlite-sync.js +++ b/src/providers/sqlite-sync.js @@ -224,7 +224,8 @@ class SyncSQLiteProvider extends SettingProvider { key = JSON.stringify(key); val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined'; this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id} && this.provider && this.provider.settings) { + const ids = [${this.client.shard.ids.join(',')}]; + if(!this.shard.ids.some(id => ids.includes(id)) && this.provider && this.provider.settings) { let global = this.provider.settings.get('global'); if(!global) { global = {}; diff --git a/src/providers/sqlite.js b/src/providers/sqlite.js index c81af1912..a2dd4b7e7 100644 --- a/src/providers/sqlite.js +++ b/src/providers/sqlite.js @@ -234,7 +234,8 @@ class SQLiteProvider extends SettingProvider { key = JSON.stringify(key); val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined'; this.client.shard.broadcastEval(` - if(this.shard.id !== ${this.client.shard.id} && this.provider && this.provider.settings) { + const ids = [${this.client.shard.ids.join(',')}]; + if(!this.shard.ids.some(id => ids.includes(id)) && this.provider && this.provider.settings) { let global = this.provider.settings.get('global'); if(!global) { global = {};