forked from Galactic/galactic-bot
Fixed shard IPC not working properly
This commit is contained in:
parent
601f7628b3
commit
5c61eb12e2
2
@types/Shared.d.ts
vendored
2
@types/Shared.d.ts
vendored
@ -38,7 +38,7 @@ export type IPCMessage = {
|
|||||||
respawnDelay: number,
|
respawnDelay: number,
|
||||||
timeout: number
|
timeout: number
|
||||||
},
|
},
|
||||||
_mEval?: string,
|
_mEval?: boolean,
|
||||||
_mEvalResult?: boolean
|
_mEvalResult?: boolean
|
||||||
_logger?: boolean,
|
_logger?: boolean,
|
||||||
_api?: boolean,
|
_api?: boolean,
|
||||||
|
@ -269,10 +269,8 @@ class DiscordClient extends Client
|
|||||||
script = `(${script})(this, ${JSON.stringify(options.context)})`;
|
script = `(${script})(this, ${JSON.stringify(options.context)})`;
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
{
|
{
|
||||||
if (!process.send)
|
|
||||||
return reject(new Error('No parent process'));
|
|
||||||
this.#evals.set(script as string, { resolve, reject });
|
this.#evals.set(script as string, { resolve, reject });
|
||||||
process.send({ _mEval: true, script, debug: options.debug || process.env.NODE_ENV === 'development' });
|
this.#intercom.send('mEval', { script, debug: options.debug ?? process.env.NODE_ENV === 'development' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class Controller extends EventEmitter
|
|||||||
// this.logger.debug(`New message from ${shard ? `${message._api ? 'api-' : ''}shard ${shard.id}`: 'manager'}: ${inspect(message)}`);
|
// this.logger.debug(`New message from ${shard ? `${message._api ? 'api-' : ''}shard ${shard.id}`: 'manager'}: ${inspect(message)}`);
|
||||||
|
|
||||||
if (message._mEval)
|
if (message._mEval)
|
||||||
return this.eval(shard, { script: message._mEval, debug: message.debug || false });
|
return this.eval(shard, { script: message.script!, debug: message.debug || false });
|
||||||
if (message._commands)
|
if (message._commands)
|
||||||
return this.#slashCommandManager._handleMessage(message as CommandsDef);
|
return this.#slashCommandManager._handleMessage(message as CommandsDef);
|
||||||
if (message._api)
|
if (message._api)
|
||||||
|
@ -55,7 +55,8 @@ class Shard extends EventEmitter
|
|||||||
|
|
||||||
this.#env = {
|
this.#env = {
|
||||||
...process.env,
|
...process.env,
|
||||||
SHARDING_MANAGER: true,
|
SHARDING_MANAGER: true, // IMPORTANT, SHARD IPC WILL BREAK IF MISSING
|
||||||
|
SHARDING_MANAGER_MODE: 'process', // IMPORTANT, SHARD IPC WILL BREAK IF MISSING
|
||||||
SHARD_ID: this.#id,
|
SHARD_ID: this.#id,
|
||||||
SHARD_COUNT: options.totalShards,
|
SHARD_COUNT: options.totalShards,
|
||||||
DISCORD_TOKEN: options.token
|
DISCORD_TOKEN: options.token
|
||||||
|
Loading…
Reference in New Issue
Block a user