refactor: Deprecate ready event in favor of clientReady (#10969)

* refactor: deprecate ready event

* refactor: tweak message

Co-Authored-By: Vlad Frangu <me@vladfrangu.dev>

* Update packages/discord.js/src/client/websocket/WebSocketManager.js

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

* chore: disable max-len

---------

Co-authored-by: Vlad Frangu <me@vladfrangu.dev>
Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Jiralite
2025-07-13 21:32:22 +01:00
committed by GitHub
parent d4f742e99e
commit 82378fc2e8
3 changed files with 22 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ const Status = require('../../util/Status');
const WebSocketShardEvents = require('../../util/WebSocketShardEvents'); const WebSocketShardEvents = require('../../util/WebSocketShardEvents');
let zlib; let zlib;
let deprecationEmitted = false;
try { try {
zlib = require('zlib-sync'); zlib = require('zlib-sync');
@@ -379,6 +380,22 @@ class WebSocketManager extends EventEmitter {
/** /**
* Emitted when the client becomes ready to start working. * Emitted when the client becomes ready to start working.
* @event Client#ready * @event Client#ready
* @deprecated Use {@link Client#event:clientReady} instead.
* @param {Client} client The client
*/
if (this.client.emit('ready', this.client) && !deprecationEmitted) {
deprecationEmitted = true;
process.emitWarning(
// eslint-disable-next-line max-len
'The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.',
'DeprecationWarning',
);
}
/**
* Emitted when the client becomes ready to start working.
* @event Client#clientReady
* @param {Client} client The client * @param {Client} client The client
*/ */
this.client.emit(Events.ClientReady, this.client); this.client.emit(Events.ClientReady, this.client);

View File

@@ -12,7 +12,7 @@
* @property {string} ChannelDelete channelDelete * @property {string} ChannelDelete channelDelete
* @property {string} ChannelPinsUpdate channelPinsUpdate * @property {string} ChannelPinsUpdate channelPinsUpdate
* @property {string} ChannelUpdate channelUpdate * @property {string} ChannelUpdate channelUpdate
* @property {string} ClientReady ready * @property {string} ClientReady clientReady
* @property {string} Debug debug * @property {string} Debug debug
* @property {string} EntitlementCreate entitlementCreate * @property {string} EntitlementCreate entitlementCreate
* @property {string} EntitlementUpdate entitlementUpdate * @property {string} EntitlementUpdate entitlementUpdate
@@ -108,7 +108,7 @@ module.exports = {
ChannelDelete: 'channelDelete', ChannelDelete: 'channelDelete',
ChannelPinsUpdate: 'channelPinsUpdate', ChannelPinsUpdate: 'channelPinsUpdate',
ChannelUpdate: 'channelUpdate', ChannelUpdate: 'channelUpdate',
ClientReady: 'ready', ClientReady: 'clientReady',
Debug: 'debug', Debug: 'debug',
EntitlementCreate: 'entitlementCreate', EntitlementCreate: 'entitlementCreate',
EntitlementUpdate: 'entitlementUpdate', EntitlementUpdate: 'entitlementUpdate',

View File

@@ -5790,6 +5790,7 @@ export interface ClientEvents {
oldChannel: DMChannel | NonThreadGuildBasedChannel, oldChannel: DMChannel | NonThreadGuildBasedChannel,
newChannel: DMChannel | NonThreadGuildBasedChannel, newChannel: DMChannel | NonThreadGuildBasedChannel,
]; ];
clientReady: [client: Client<true>];
debug: [message: string]; debug: [message: string];
warn: [message: string]; warn: [message: string];
emojiCreate: [emoji: GuildEmoji]; emojiCreate: [emoji: GuildEmoji];
@@ -5850,6 +5851,7 @@ export interface ClientEvents {
newMessage: OmitPartialGroupDMChannel<Message>, newMessage: OmitPartialGroupDMChannel<Message>,
]; ];
presenceUpdate: [oldPresence: Presence | null, newPresence: Presence]; presenceUpdate: [oldPresence: Presence | null, newPresence: Presence];
/** @deprecated Use {@link ClientEvents.ClientReady} instead. */
ready: [client: Client<true>]; ready: [client: Client<true>];
invalidated: []; invalidated: [];
roleCreate: [role: Role]; roleCreate: [role: Role];
@@ -6035,7 +6037,7 @@ export enum Events {
AutoModerationRuleCreate = 'autoModerationRuleCreate', AutoModerationRuleCreate = 'autoModerationRuleCreate',
AutoModerationRuleDelete = 'autoModerationRuleDelete', AutoModerationRuleDelete = 'autoModerationRuleDelete',
AutoModerationRuleUpdate = 'autoModerationRuleUpdate', AutoModerationRuleUpdate = 'autoModerationRuleUpdate',
ClientReady = 'ready', ClientReady = 'clientReady',
EntitlementCreate = 'entitlementCreate', EntitlementCreate = 'entitlementCreate',
EntitlementDelete = 'entitlementDelete', EntitlementDelete = 'entitlementDelete',
EntitlementUpdate = 'entitlementUpdate', EntitlementUpdate = 'entitlementUpdate',