mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor!: fix several issues with /ws incorporation (#10556)
BREAKING CHANGE: `Client#ping` is nullable now
This commit is contained in:
@@ -105,14 +105,6 @@ class Client extends BaseClient {
|
||||
*/
|
||||
this.actions = new ActionsManager(this);
|
||||
|
||||
/**
|
||||
* Shard helpers for the client (only if the process was spawned from a {@link ShardingManager})
|
||||
* @type {?ShardClientUtil}
|
||||
*/
|
||||
this.shard = process.env.SHARDING_MANAGER
|
||||
? ShardClientUtil.singleton(this, process.env.SHARDING_MANAGER_MODE)
|
||||
: null;
|
||||
|
||||
/**
|
||||
* The user manager of this client
|
||||
* @type {UserManager}
|
||||
@@ -170,6 +162,14 @@ class Client extends BaseClient {
|
||||
*/
|
||||
this.ws = new WebSocketManager(wsOptions);
|
||||
|
||||
/**
|
||||
* Shard helpers for the client (only if the process was spawned from a {@link ShardingManager})
|
||||
* @type {?ShardClientUtil}
|
||||
*/
|
||||
this.shard = process.env.SHARDING_MANAGER
|
||||
? ShardClientUtil.singleton(this, process.env.SHARDING_MANAGER_MODE)
|
||||
: null;
|
||||
|
||||
/**
|
||||
* The voice manager of the client
|
||||
* @type {ClientVoiceManager}
|
||||
@@ -414,12 +414,11 @@ class Client extends BaseClient {
|
||||
|
||||
/**
|
||||
* The average ping of all WebSocketShards
|
||||
* @type {number}
|
||||
* @type {?number}
|
||||
* @readonly
|
||||
*/
|
||||
get ping() {
|
||||
const sum = this.pings.reduce((a, b) => a + b, 0);
|
||||
return sum / this.pings.size;
|
||||
return this.pings.size ? this.pings.reduce((a, b) => a + b, 0) / this.pings.size : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,25 +12,8 @@
|
||||
* @property {'TokenMissing'} TokenMissing
|
||||
* @property {'ApplicationCommandPermissionsTokenMissing'} ApplicationCommandPermissionsTokenMissing
|
||||
|
||||
* @property {'WSCloseRequested'} WSCloseRequested
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'WSConnectionExists'} WSConnectionExists
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'WSNotOpen'} WSNotOpen
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ManagerDestroyed'} ManagerDestroyed
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'BitFieldInvalid'} BitFieldInvalid
|
||||
|
||||
* @property {'ShardingInvalid'} ShardingInvalid
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ShardingRequired'} ShardingRequired
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'InvalidIntents'} InvalidIntents
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'DisallowedIntents'} DisallowedIntents
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ShardingNoShards'} ShardingNoShards
|
||||
* @property {'ShardingInProcess'} ShardingInProcess
|
||||
* @property {'ShardingInvalidEvalBroadcast'} ShardingInvalidEvalBroadcast
|
||||
@@ -49,30 +32,10 @@
|
||||
|
||||
* @property {'InviteOptionsMissingChannel'} InviteOptionsMissingChannel
|
||||
|
||||
* @property {'ButtonLabel'} ButtonLabel
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ButtonURL'} ButtonURL
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ButtonCustomId'} ButtonCustomId
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'SelectMenuCustomId'} SelectMenuCustomId
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'SelectMenuPlaceholder'} SelectMenuPlaceholder
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'SelectOptionLabel'} SelectOptionLabel
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'SelectOptionValue'} SelectOptionValue
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'SelectOptionDescription'} SelectOptionDescription
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'InteractionCollectorError'} InteractionCollectorError
|
||||
|
||||
* @property {'FileNotFound'} FileNotFound
|
||||
|
||||
* @property {'UserBannerNotFetched'} UserBannerNotFetched
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'UserNoDMChannel'} UserNoDMChannel
|
||||
|
||||
* @property {'VoiceNotStageChannel'} VoiceNotStageChannel
|
||||
@@ -82,19 +45,11 @@
|
||||
|
||||
* @property {'ReqResourceType'} ReqResourceType
|
||||
|
||||
* @property {'ImageFormat'} ImageFormat
|
||||
* <warn>This property is deprecated.</warn>
|
||||
* @property {'ImageSize'} ImageSize
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'MessageBulkDeleteType'} MessageBulkDeleteType
|
||||
* @property {'MessageContentType'} MessageContentType
|
||||
* @property {'MessageNonceRequired'} MessageNonceRequired
|
||||
* @property {'MessageNonceType'} MessageNonceType
|
||||
|
||||
* @property {'SplitMaxLen'} SplitMaxLen
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'BanResolveId'} BanResolveId
|
||||
* @property {'FetchBanResolveId'} FetchBanResolveId
|
||||
|
||||
@@ -128,16 +83,11 @@
|
||||
* @property {'EmojiType'} EmojiType
|
||||
* @property {'EmojiManaged'} EmojiManaged
|
||||
* @property {'MissingManageGuildExpressionsPermission'} MissingManageGuildExpressionsPermission
|
||||
* @property {'MissingManageEmojisAndStickersPermission'} MissingManageEmojisAndStickersPermission
|
||||
* <warn>This property is deprecated. Use `MissingManageGuildExpressionsPermission` instead.</warn>
|
||||
*
|
||||
* @property {'NotGuildSticker'} NotGuildSticker
|
||||
|
||||
* @property {'ReactionResolveUser'} ReactionResolveUser
|
||||
|
||||
* @property {'VanityURL'} VanityURL
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'InviteResolveCode'} InviteResolveCode
|
||||
|
||||
* @property {'InviteNotFound'} InviteNotFound
|
||||
@@ -152,8 +102,6 @@
|
||||
|
||||
* @property {'InteractionAlreadyReplied'} InteractionAlreadyReplied
|
||||
* @property {'InteractionNotReplied'} InteractionNotReplied
|
||||
* @property {'InteractionEphemeralReplied'} InteractionEphemeralReplied
|
||||
* <warn>This property is deprecated.</warn>
|
||||
|
||||
* @property {'CommandInteractionOptionNotFound'} CommandInteractionOptionNotFound
|
||||
* @property {'CommandInteractionOptionType'} CommandInteractionOptionType
|
||||
@@ -192,17 +140,8 @@ const keys = [
|
||||
'TokenMissing',
|
||||
'ApplicationCommandPermissionsTokenMissing',
|
||||
|
||||
'WSCloseRequested',
|
||||
'WSConnectionExists',
|
||||
'WSNotOpen',
|
||||
'ManagerDestroyed',
|
||||
|
||||
'BitFieldInvalid',
|
||||
|
||||
'ShardingInvalid',
|
||||
'ShardingRequired',
|
||||
'InvalidIntents',
|
||||
'DisallowedIntents',
|
||||
'ShardingNoShards',
|
||||
'ShardingInProcess',
|
||||
'ShardingInvalidEvalBroadcast',
|
||||
@@ -221,21 +160,10 @@ const keys = [
|
||||
|
||||
'InviteOptionsMissingChannel',
|
||||
|
||||
'ButtonLabel',
|
||||
'ButtonURL',
|
||||
'ButtonCustomId',
|
||||
|
||||
'SelectMenuCustomId',
|
||||
'SelectMenuPlaceholder',
|
||||
'SelectOptionLabel',
|
||||
'SelectOptionValue',
|
||||
'SelectOptionDescription',
|
||||
|
||||
'InteractionCollectorError',
|
||||
|
||||
'FileNotFound',
|
||||
|
||||
'UserBannerNotFetched',
|
||||
'UserNoDMChannel',
|
||||
|
||||
'VoiceNotStageChannel',
|
||||
@@ -245,16 +173,11 @@ const keys = [
|
||||
|
||||
'ReqResourceType',
|
||||
|
||||
'ImageFormat',
|
||||
'ImageSize',
|
||||
|
||||
'MessageBulkDeleteType',
|
||||
'MessageContentType',
|
||||
'MessageNonceRequired',
|
||||
'MessageNonceType',
|
||||
|
||||
'SplitMaxLen',
|
||||
|
||||
'BanResolveId',
|
||||
'FetchBanResolveId',
|
||||
|
||||
@@ -288,14 +211,11 @@ const keys = [
|
||||
'EmojiType',
|
||||
'EmojiManaged',
|
||||
'MissingManageGuildExpressionsPermission',
|
||||
'MissingManageEmojisAndStickersPermission',
|
||||
|
||||
'NotGuildSticker',
|
||||
|
||||
'ReactionResolveUser',
|
||||
|
||||
'VanityURL',
|
||||
|
||||
'InviteResolveCode',
|
||||
|
||||
'InviteNotFound',
|
||||
@@ -310,7 +230,6 @@ const keys = [
|
||||
|
||||
'InteractionAlreadyReplied',
|
||||
'InteractionNotReplied',
|
||||
'InteractionEphemeralReplied',
|
||||
|
||||
'CommandInteractionOptionNotFound',
|
||||
'CommandInteractionOptionType',
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -985,7 +985,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
public guilds: GuildManager;
|
||||
public lastPingTimestamp: number;
|
||||
public options: Omit<ClientOptions, 'intents'> & { intents: IntentsBitField };
|
||||
public get ping(): number;
|
||||
public get ping(): number | null;
|
||||
public get readyAt(): If<Ready, Date>;
|
||||
public readyTimestamp: If<Ready, number>;
|
||||
public sweepers: Sweepers;
|
||||
|
||||
Reference in New Issue
Block a user