Skip to content

Commit

Permalink
feat: add resume event in shard (#9650)
Browse files Browse the repository at this point in the history
Co-authored-by: GrapeColor <grapecolor@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 7, 2023
1 parent cf8012c commit a73d54e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/discord.js/src/sharding/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ class Shard extends EventEmitter {
// Shard has resumed
if (message._resume) {
this.ready = true;
/**
* Emitted upon the shard's {@link Client#event:shardResume} event.
* @event Shard#resume
*/
this.emit(ShardEvents.Resume);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/src/util/ShardEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @property {string} Message message
* @property {string} Ready ready
* @property {string} Reconnecting reconnecting
* @property {string} Resume resume
* @property {string} Spawn spawn
*/

Expand All @@ -23,5 +24,6 @@ module.exports = {
Message: 'message',
Ready: 'ready',
Reconnecting: 'reconnecting',
Resume: 'resume',
Spawn: 'spawn',
};
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,7 @@ export interface ShardEventTypes {
message: [message: any];
ready: [];
reconnecting: [];
resume: [];
spawn: [process: ChildProcess | Worker];
}

Expand Down Expand Up @@ -5038,6 +5039,7 @@ export enum ShardEvents {
Message = 'message',
Ready = 'ready',
Reconnecting = 'reconnecting',
Resume = 'resume',
Spawn = 'spawn',
}

Expand Down

0 comments on commit a73d54e

Please sign in to comment.