Skip to content

Commit

Permalink
fix: use correct prop
Browse files Browse the repository at this point in the history
  • Loading branch information
didinele committed Jul 31, 2024
1 parent b0024eb commit 91f79f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class Client extends BaseClient {
* @private
* @type {ClientPresence}
*/
this.presence = new ClientPresence(this, this.options.presence);
this.presence = new ClientPresence(this, this.options.ws.presence ?? this.options.presence);

Object.defineProperty(this, 'token', { writable: true });
if (!this.token && 'DISCORD_TOKEN' in process.env) {
Expand Down Expand Up @@ -222,14 +222,14 @@ class Client extends BaseClient {
if (this.options.presence) {
if (!deprecationEmittedForClientPresence) {
process.emitWarning(
'ClientOptions#presence is deprecated and will be removed. Use ClientOptions#ws#initialPresence instead.',
'ClientOptions#presence is deprecated and will be removed. Use ClientOptions#ws#presence instead.',
'DeprecationWarning',
);

deprecationEmittedForClientPresence = true;
}

this.options.ws.initialPresence = this.presence._parse(this.options.presence);
this.options.ws.presence = this.presence._parse(this.options.presence);
}

this.emit(Events.Debug, 'Preparing to connect to the gateway...');
Expand Down Expand Up @@ -557,11 +557,8 @@ class Client extends BaseClient {
if (typeof options.ws !== 'object' || options.ws === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws', 'an object');
}
if (
typeof options.ws === 'object' &&
(typeof options.ws.initialPresence !== 'object' || options.ws.initialPresence === null)
) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws.initialPresence', 'an object');
if (typeof options.ws.initialPresence !== 'object' || options.ws.initialPresence === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'ws.presence', 'an object');
}
if (typeof options.rest !== 'object' || options.rest === null) {
throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'rest', 'an object');
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/util/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const { version } = require('../../package.json');
* only set this if you know what you are doing</warn>
* @property {BuildStrategyFunction} [buildStrategy] Builds the strategy to use for sharding
* @property {IdentifyThrottlerFunction} [buildIdentifyThrottler] Builds the identify throttler to use for sharding
* @property {PresenceData} [initialPresence={}] Presence data to use upon login
* @property {PresenceData} [presence={}] Presence data to use upon login
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5305,7 +5305,7 @@ export interface ClientOptions {
allowedMentions?: MessageMentionOptions;
partials?: readonly Partials[];
failIfNotExists?: boolean;
/** @deprecated Use {@link ClientOptions.ws.initialPresence} instead */
/** @deprecated Use {@link ClientOptions.ws.presence} instead */
presence?: PresenceData;
intents: BitFieldResolvable<GatewayIntentsString, number>;
waitGuildTimeout?: number;
Expand Down Expand Up @@ -6878,7 +6878,7 @@ export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions,
export interface WebSocketOptions {
large_threshold?: number;
version?: number;
initialPresence?: GatewayPresenceUpdateData;
presence?: GatewayPresenceUpdateData;
buildStrategy?(manager: WSWebSocketManager): IShardingStrategy;
buildIdentifyThrottler?(manager: WSWebSocketManager): Awaitable<IIdentifyThrottler>;
}
Expand Down

0 comments on commit 91f79f4

Please sign in to comment.