Skip to content

Commit

Permalink
fix: setting presence via ws.presence
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Aug 4, 2024
1 parent 590ef12 commit b3c860e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Client extends BaseClient {
this.rest.setToken(token);
this.emit(Events.Debug, `Provided token: ${this._censoredToken}`);

if (this.options.presence) {
if (this.options.presence && Object.keys(this.options.presence).length > 0) {
if (!deprecationEmittedForClientPresence) {
process.emitWarning(
'ClientOptions#presence is deprecated and will be removed. Use ClientOptions#ws#presence instead.',
Expand All @@ -230,6 +230,8 @@ class Client extends BaseClient {
}

this.options.ws.presence = this.presence._parse(this.options.presence);
} else if (this.options.ws.presence) {
this.options.ws.presence = this.presence._parse(this.options.ws.presence);
}

this.emit(Events.Debug, 'Preparing to connect to the gateway...');
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} [presence={}] Presence data to use upon login
* @property {PresenceData} [presence] Presence data to use upon login
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6878,7 +6878,7 @@ export interface WebhookMessageCreateOptions extends Omit<MessageCreateOptions,
export interface WebSocketOptions {
large_threshold?: number;
version?: number;
presence?: GatewayPresenceUpdateData;
presence?: PresenceData;
buildStrategy?(manager: WSWebSocketManager): IShardingStrategy;
buildIdentifyThrottler?(manager: WSWebSocketManager): Awaitable<IIdentifyThrottler>;
}
Expand Down

0 comments on commit b3c860e

Please sign in to comment.