mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
feat: Add message to send resume event to shard (#9626)
* fix(WebSocketManager): Fix not ready after reconnect * fix(WebSocketManager): Move fixes from Ready to Resume * fix: undo changes * feat: Add message to send resume event to shard --------- Co-authored-by: GrapeColor <grapecolor@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -367,6 +367,12 @@ class Shard extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shard has resumed
|
||||||
|
if (message._resume) {
|
||||||
|
this.ready = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Shard is requesting a property fetch
|
// Shard is requesting a property fetch
|
||||||
if (message._sFetchProp) {
|
if (message._sFetchProp) {
|
||||||
const resp = { _sFetchProp: message._sFetchProp, _sFetchPropShard: message._sFetchPropShard };
|
const resp = { _sFetchProp: message._sFetchProp, _sFetchPropShard: message._sFetchPropShard };
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ class ShardClientUtil {
|
|||||||
client.on(Events.ShardReconnecting, () => {
|
client.on(Events.ShardReconnecting, () => {
|
||||||
process.send({ _reconnecting: true });
|
process.send({ _reconnecting: true });
|
||||||
});
|
});
|
||||||
|
client.on(Events.ShardResume, () => {
|
||||||
|
process.send({ _resume: true });
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'worker':
|
case 'worker':
|
||||||
this.parentPort = require('node:worker_threads').parentPort;
|
this.parentPort = require('node:worker_threads').parentPort;
|
||||||
@@ -55,6 +58,9 @@ class ShardClientUtil {
|
|||||||
client.on(Events.ShardReconnecting, () => {
|
client.on(Events.ShardReconnecting, () => {
|
||||||
this.parentPort.postMessage({ _reconnecting: true });
|
this.parentPort.postMessage({ _reconnecting: true });
|
||||||
});
|
});
|
||||||
|
client.on(Events.ShardResume, () => {
|
||||||
|
this.parentPort.postMessage({ _resume: true });
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user