diff --git a/src/structures/ClientPresence.js b/src/structures/ClientPresence.js index 90db53bd0..213b46f2d 100644 --- a/src/structures/ClientPresence.js +++ b/src/structures/ClientPresence.js @@ -68,7 +68,7 @@ class ClientPresence extends Presence { }; if ((status || afk || since) && !activity) { - packet.game = this.activity; + packet.game = this.activities[0] || null; } if (packet.game) { diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 16dd13d07..3f2883efc 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -149,7 +149,7 @@ class ClientUser extends Structures.get('User') { * @example * // Set the client user's activity * client.user.setActivity('discord.js', { type: 'WATCHING' }) - * .then(presence => console.log(`Activity set to ${presence.activity.name}`)) + * .then(presence => console.log(`Activity set to ${presence.activities[0].name}`)) * .catch(console.error); */ setActivity(name, options = {}) { diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 1ad6229a4..12888f1c6 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -85,11 +85,17 @@ class Presence { */ this.status = data.status || this.status || 'offline'; - /** - * The activities of this presence - * @type {Activity[]} - */ - this.activities = data.activities ? data.activities.map(activity => new Activity(this, activity)) : []; + if (data.activities) { + /** + * The activities of this presence + * @type {Activity[]} + */ + this.activities = data.activities.map(activity => new Activity(this, activity)); + } else if (data.activity || data.game) { + this.activities = [new Activity(this, data.game || data.activity)]; + } else { + this.activities = []; + } /** * The devices this presence is on @@ -105,7 +111,7 @@ class Presence { _clone() { const clone = Object.assign(Object.create(this), this); - if (this.activity) clone.activity = this.activity._clone(); + if (this.activities) clone.activities = this.activities.map(activity => activity._clone()); return clone; } @@ -118,10 +124,11 @@ class Presence { return this === presence || ( presence && this.status === presence.status && - this.activity ? this.activity.equals(presence.activity) : !presence.activity && - this.clientStatus.web === presence.clientStatus.web && - this.clientStatus.mobile === presence.clientStatus.mobile && - this.clientStatus.desktop === presence.clientStatus.desktop + this.activities.length === presence.activities.length && + this.activities.every((activity, index) => activity.equals(presence.activities[index])) && + this.clientStatus.web === presence.clientStatus.web && + this.clientStatus.mobile === presence.clientStatus.mobile && + this.clientStatus.desktop === presence.clientStatus.desktop ); }