mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
feat(Presence): add clientStatus (#3056)
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
const { ActivityFlags, Endpoints } = require('../util/Constants');
|
const { ActivityFlags, Endpoints } = require('../util/Constants');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status of this presence:
|
||||||
|
*
|
||||||
|
* * **`online`** - user is online
|
||||||
|
* * **`idle`** - user is AFK
|
||||||
|
* * **`offline`** - user is offline or invisible
|
||||||
|
* * **`dnd`** - user is in Do Not Disturb
|
||||||
|
* @typedef {string} PresenceStatus
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a user's presence.
|
* Represents a user's presence.
|
||||||
*/
|
*/
|
||||||
@@ -8,13 +18,8 @@ class Presence {
|
|||||||
Object.defineProperty(this, 'client', { value: client });
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The status of the presence:
|
* The status of this presence:
|
||||||
*
|
* @type {PresenceStatus}
|
||||||
* * **`online`** - user is online
|
|
||||||
* * **`offline`** - user is offline or invisible
|
|
||||||
* * **`idle`** - user is AFK
|
|
||||||
* * **`dnd`** - user is in Do not Disturb
|
|
||||||
* @type {string}
|
|
||||||
*/
|
*/
|
||||||
this.status = data.status || 'offline';
|
this.status = data.status || 'offline';
|
||||||
|
|
||||||
@@ -23,11 +28,21 @@ class Presence {
|
|||||||
* @type {?Game}
|
* @type {?Game}
|
||||||
*/
|
*/
|
||||||
this.game = data.game ? new Game(data.game, this) : null;
|
this.game = data.game ? new Game(data.game, this) : null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The devices this presence is on
|
||||||
|
* @type {?object}
|
||||||
|
* @property {PresenceStatus} web
|
||||||
|
* @property {PresenceStatus} mobile
|
||||||
|
* @property {PresenceStatus} desktop
|
||||||
|
*/
|
||||||
|
this.clientStatus = data.client_status || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {
|
update(data) {
|
||||||
this.status = data.status || this.status;
|
this.status = data.status || this.status;
|
||||||
this.game = data.game ? new Game(data.game, this) : null;
|
this.game = data.game ? new Game(data.game, this) : null;
|
||||||
|
this.clientStatus = data.client_status || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +54,10 @@ class Presence {
|
|||||||
return this === presence || (
|
return this === presence || (
|
||||||
presence &&
|
presence &&
|
||||||
this.status === presence.status &&
|
this.status === presence.status &&
|
||||||
this.game ? this.game.equals(presence.game) : !presence.game
|
(this.game ? this.game.equals(presence.game) : !presence.game) &&
|
||||||
|
this.clientStatus.web === presence.clientStatus.web &&
|
||||||
|
this.clientStatus.mobile === presence.clientStatus.mobile &&
|
||||||
|
this.clientStatus.desktop === presence.clientStatus.desktop
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
typings/index.d.ts
vendored
14
typings/index.d.ts
vendored
@@ -968,7 +968,8 @@ declare module 'discord.js' {
|
|||||||
constructor(data: object, client: Client);
|
constructor(data: object, client: Client);
|
||||||
public readonly client: Client;
|
public readonly client: Client;
|
||||||
public game: Game;
|
public game: Game;
|
||||||
public status: 'online' | 'offline' | 'idle' | 'dnd';
|
public status: PresenceStatusData;
|
||||||
|
public clientStatus: ClientPresenceStatusData;
|
||||||
public equals(presence: Presence): boolean;
|
public equals(presence: Presence): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2033,7 +2034,16 @@ declare module 'discord.js' {
|
|||||||
} | null;
|
} | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PresenceStatus = 'online' | 'idle' | 'invisible' | 'dnd';
|
type ClientPresenceStatus = 'online' | 'idle' | 'dnd';
|
||||||
|
|
||||||
|
type PresenceStatus = ClientPresenceStatus | 'invisible' ;
|
||||||
|
type PresenceStatusData = ClientPresenceStatus | 'offline';
|
||||||
|
|
||||||
|
type ClientPresenceStatusData = {
|
||||||
|
web?: ClientPresenceStatus;
|
||||||
|
mobile?: ClientPresenceStatus;
|
||||||
|
desktop?: ClientPresenceStatus;
|
||||||
|
};
|
||||||
|
|
||||||
type RateLimitInfo = {
|
type RateLimitInfo = {
|
||||||
requestLimit: number;
|
requestLimit: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user