Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
21 changes: 20 additions & 1 deletion packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { ChannelManager } = require('../managers/ChannelManager.js');
const { GuildManager } = require('../managers/GuildManager.js');
const { UserManager } = require('../managers/UserManager.js');
const { ShardClientUtil } = require('../sharding/ShardClientUtil.js');
const { ClientApplication } = require('../structures/ClientApplication.js');
const { ClientPresence } = require('../structures/ClientPresence.js');
const { GuildPreview } = require('../structures/GuildPreview.js');
const { GuildTemplate } = require('../structures/GuildTemplate.js');
Expand Down Expand Up @@ -44,6 +45,8 @@ const BeforeReadyWhitelist = [
GatewayDispatchEvents.GuildMemberRemove,
];

let ClientUser;

/**
* The main hub for interacting with the Discord API, and the starting point for any bot.
*
Expand Down Expand Up @@ -346,9 +349,25 @@ class Client extends BaseClient {
);
this.ws.on(WebSocketShardEvents.Dispatch, this._handlePacket.bind(this));

this.ws.on(WebSocketShardEvents.Ready, async data => {
this.ws.on(WebSocketShardEvents.Ready, async (data, shardId) => {
if (this.user) {
this.user._patch(data.user);
} else {
ClientUser ??= require('../structures/ClientUser.js').ClientUser;
this.user = new ClientUser(this, data.user);
this.users.cache.set(this.user.id, this.user);
}

for (const guild of data.guilds) {
this.expectedGuilds.add(guild.id);
guild.shardId = shardId;
this.guilds._add(guild);
}

if (this.application) {
this.application._patch(data.application);
} else {
this.application = new ClientApplication(this, data.application);
}

this.status = Status.WaitingForGuilds;
Expand Down
26 changes: 0 additions & 26 deletions packages/discord.js/src/client/websocket/handlers/READY.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/discord.js/src/client/websocket/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const PacketHandlers = Object.fromEntries([
['MESSAGE_REACTION_REMOVE_EMOJI', require('./MESSAGE_REACTION_REMOVE_EMOJI.js')],
['MESSAGE_UPDATE', require('./MESSAGE_UPDATE.js')],
['PRESENCE_UPDATE', require('./PRESENCE_UPDATE.js')],
['READY', require('./READY.js')],
['SOUNDBOARD_SOUNDS', require('./SOUNDBOARD_SOUNDS.js')],
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE.js')],
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE.js')],
Expand Down