revert: chore: deprecate client options presence (#10426)

Revert "chore: deprecate client options presence (#10419)"

This reverts commit 8f97d2bacf.
This commit is contained in:
Almeida
2024-08-06 19:21:10 +01:00
committed by GitHub
parent f623e7a315
commit 5c90b7f716
3 changed files with 1 additions and 18 deletions

View File

@@ -32,7 +32,6 @@ const Status = require('../util/Status');
const Sweepers = require('../util/Sweepers'); const Sweepers = require('../util/Sweepers');
let deprecationEmittedForPremiumStickerPacks = false; let deprecationEmittedForPremiumStickerPacks = false;
let deprecationEmittedForClientPresence = false;
/** /**
* The main hub for interacting with the Discord API, and the starting point for any bot. * The main hub for interacting with the Discord API, and the starting point for any bot.
@@ -140,7 +139,7 @@ class Client extends BaseClient {
* @private * @private
* @type {ClientPresence} * @type {ClientPresence}
*/ */
this.presence = new ClientPresence(this, this.options.ws.presence ?? this.options.presence); this.presence = new ClientPresence(this, this.options.presence);
Object.defineProperty(this, 'token', { writable: true }); Object.defineProperty(this, 'token', { writable: true });
if (!this.token && 'DISCORD_TOKEN' in process.env) { if (!this.token && 'DISCORD_TOKEN' in process.env) {
@@ -220,15 +219,6 @@ class Client extends BaseClient {
this.emit(Events.Debug, `Provided token: ${this._censoredToken}`); this.emit(Events.Debug, `Provided token: ${this._censoredToken}`);
if (this.options.presence) { if (this.options.presence) {
if (!deprecationEmittedForClientPresence) {
process.emitWarning(
'ClientOptions#presence is deprecated and will be removed. Use ClientOptions#ws#presence instead.',
'DeprecationWarning',
);
deprecationEmittedForClientPresence = true;
}
this.options.ws.presence = this.presence._parse(this.options.presence); this.options.ws.presence = this.presence._parse(this.options.presence);
} }
@@ -557,9 +547,6 @@ class Client extends BaseClient {
if (typeof options.ws !== 'object' || options.ws === null) { if (typeof options.ws !== 'object' || options.ws === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws', 'an object'); throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws', 'an object');
} }
if (typeof options.ws.presence !== 'object' || options.ws.presence === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws.presence', 'an object');
}
if (typeof options.rest !== 'object' || options.rest === null) { if (typeof options.rest !== 'object' || options.rest === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'rest', 'an object'); throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'rest', 'an object');
} }

View File

@@ -91,7 +91,6 @@ const { version } = require('../../package.json');
* only set this if you know what you are doing</warn> * only set this if you know what you are doing</warn>
* @property {BuildStrategyFunction} [buildStrategy] Builds the strategy to use for sharding * @property {BuildStrategyFunction} [buildStrategy] Builds the strategy to use for sharding
* @property {IdentifyThrottlerFunction} [buildIdentifyThrottler] Builds the identify throttler to use for sharding * @property {IdentifyThrottlerFunction} [buildIdentifyThrottler] Builds the identify throttler to use for sharding
* @property {PresenceData} [presence={}] Presence data to use upon login
*/ */
/** /**

View File

@@ -181,7 +181,6 @@ import {
APISelectMenuDefaultValue, APISelectMenuDefaultValue,
SelectMenuDefaultValueType, SelectMenuDefaultValueType,
InviteType, InviteType,
GatewayPresenceUpdateData,
} from 'discord-api-types/v10'; } from 'discord-api-types/v10';
import { ChildProcess } from 'node:child_process'; import { ChildProcess } from 'node:child_process';
import { EventEmitter } from 'node:events'; import { EventEmitter } from 'node:events';
@@ -5305,7 +5304,6 @@ export interface ClientOptions {
allowedMentions?: MessageMentionOptions; allowedMentions?: MessageMentionOptions;
partials?: readonly Partials[]; partials?: readonly Partials[];
failIfNotExists?: boolean; failIfNotExists?: boolean;
/** @deprecated Use {@link ClientOptions.ws.presence} instead */
presence?: PresenceData; presence?: PresenceData;
intents: BitFieldResolvable<GatewayIntentsString, number>; intents: BitFieldResolvable<GatewayIntentsString, number>;
waitGuildTimeout?: number; waitGuildTimeout?: number;
@@ -6878,7 +6876,6 @@ export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions,
export interface WebSocketOptions { export interface WebSocketOptions {
large_threshold?: number; large_threshold?: number;
version?: number; version?: number;
presence?: GatewayPresenceUpdateData;
buildStrategy?(manager: WSWebSocketManager): IShardingStrategy; buildStrategy?(manager: WSWebSocketManager): IShardingStrategy;
buildIdentifyThrottler?(manager: WSWebSocketManager): Awaitable<IIdentifyThrottler>; buildIdentifyThrottler?(manager: WSWebSocketManager): Awaitable<IIdentifyThrottler>;
} }