Skip to content
This repository was archived by the owner on Dec 24, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/commands/commands/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/commands/commands/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
`);
Expand Down
5 changes: 4 additions & 1 deletion src/commands/commands/unload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
3 changes: 2 additions & 1 deletion src/providers/sqlite-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
3 changes: 2 additions & 1 deletion src/providers/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down