Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(Client): Move client initialization code#11184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vakiliner wants to merge8 commits intodiscordjs:main
base:main
Choose a base branch
Loading
fromvakiliner:patch-1
Open
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Migrating back to READY.js
  • Loading branch information
@vakiliner
vakiliner committedOct 19, 2025
commit4ab11b158e086509dfb514c907342442242f1ba9
30 changes: 1 addition & 29 deletionspackages/discord.js/src/client/Client.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ 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 DownExpand Up@@ -45,8 +44,6 @@ const BeforeReadyWhitelist = [
GatewayDispatchEvents.GuildMemberRemove,
];

let ClientUser;

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

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;
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@@ -400,7 +372,7 @@ class Client extends BaseClient {
}

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

if (this.status === Status.WaitingForGuilds && WaitingForGuildEvents.includes(packet.t)) {
Expand Down
31 changes: 31 additions & 0 deletionspackages/discord.js/src/client/websocket/handlers/READY.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
'use strict';

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

let ClientUser;

module.exports = async (client, { d: data }, shardId) => {
if (client.user) {
client.user._patch(data.user);
} else {
ClientUser ??= require('../../../structures/ClientUser.js').ClientUser;
client.user = new ClientUser(client, data.user);
client.users.cache.set(client.user.id, client.user);
}

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

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

client.status = Status.WaitingForGuilds;
await client._checkReady();
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,7 @@ 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

[8]ページ先頭

©2009-2025 Movatter.jp