mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
feat(ClientOptions): add support for setting an initial presence (#2320)
* docs/feat(WebsocketOptions): Parse ws options presence Allow the `presence` property in `WebsocketOptions` to be used the same way as `ClientUser#setPresence`. * Move presence options to top level
This commit is contained in:
@@ -19,7 +19,14 @@ class ClientPresenceStore extends PresenceStore {
|
||||
});
|
||||
}
|
||||
|
||||
async setClientPresence({ status, since, afk, activity }) { // eslint-disable-line complexity
|
||||
async setClientPresence(presence) {
|
||||
const packet = await this._parse(presence);
|
||||
this.clientPresence.patch(packet);
|
||||
this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
|
||||
return this.clientPresence;
|
||||
}
|
||||
|
||||
async _parse({ status, since, afk, activity }) { // eslint-disable-line complexity
|
||||
const applicationID = activity && (activity.application ? activity.application.id || activity.application : null);
|
||||
let assets = new Collection();
|
||||
if (activity) {
|
||||
@@ -66,9 +73,7 @@ class ClientPresenceStore extends PresenceStore {
|
||||
packet.game.type : ActivityTypes.indexOf(packet.game.type);
|
||||
}
|
||||
|
||||
this.clientPresence.patch(packet);
|
||||
this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
|
||||
return this.clientPresence;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user