Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
11 changes: 1 addition & 10 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,6 @@ class Client extends BaseClient {
);
this.ws.on(WebSocketShardEvents.Dispatch, this._handlePacket.bind(this));

this.ws.on(WebSocketShardEvents.Ready, async data => {
for (const guild of data.guilds) {
this.expectedGuilds.add(guild.id);
}

this.status = Status.WaitingForGuilds;
await this._checkReady();
});

this.ws.on(WebSocketShardEvents.HeartbeatComplete, ({ heartbeatAt, latency }, shardId) => {
this.emit(Events.Debug, `[WS => Shard ${shardId}] Heartbeat acknowledged, latency of ${latency}ms.`);
this.lastPingTimestamps.set(shardId, heartbeatAt);
Expand All @@ -381,7 +372,7 @@ class Client extends BaseClient {
}

if (PacketHandlers[packet.t]) {
PacketHandlers[packet.t](this, packet, shardId);
await PacketHandlers[packet.t](this, packet, shardId);
}

if (this.status === Status.WaitingForGuilds && WaitingForGuildEvents.includes(packet.t)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';

const { ClientApplication } = require('../../../structures/ClientApplication.js');
const { Status } = require('../../../util/Status.js');

let ClientUser;

module.exports = (client, { d: data }, shardId) => {
module.exports = async (client, { d: data }, shardId) => {
if (client.user) {
client.user._patch(data.user);
} else {
Expand All @@ -14,6 +15,7 @@ module.exports = (client, { d: data }, shardId) => {
}

for (const guild of data.guilds) {
client.expectedGuilds.add(guild.id);
guild.shardId = shardId;
client.guilds._add(guild);
}
Expand All @@ -23,4 +25,7 @@ module.exports = (client, { d: data }, shardId) => {
} else {
client.application = new ClientApplication(client, data.application);
}

client.status = Status.WaitingForGuilds;
await client._checkReady();
};