feat(Activity): support for CUSTOM_STATUS activity type (#3353)

* feat: support for custom status in activity

* nit(typings): order properties
This commit is contained in:
Jeroen Claassens
2019-12-05 13:13:42 +01:00
committed by SpaceEEC
parent 1b1289b35e
commit 2ca74d6b63
3 changed files with 29 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
const Util = require('../util/Util');
const ActivityFlags = require('../util/ActivityFlags');
const { ActivityTypes } = require('../util/Constants');
const Emoji = require('./Emoji');
/**
* Activity sent in a message.
@@ -205,6 +206,18 @@ class Activity {
* @type {Readonly<ActivityFlags>}
*/
this.flags = new ActivityFlags(data.flags).freeze();
/**
* Emoji for a custom activity
* @type {?Emoji}
*/
this.emoji = data.emoji ? new Emoji(presence.client, data.emoji) : null;
/**
* Creation date of the activity
* @type {number}
*/
this.createdTimestamp = new Date(data.created_at).getTime();
}
/**
@@ -221,6 +234,15 @@ class Activity {
);
}
/**
* The time the activity was created at
* @type {Date}
* @readonly
*/
get createdAt() {
return new Date(this.createdTimestamp);
}
/**
* When concatenated with a string, this automatically returns the activities' name instead of the Activity object.
* @returns {string}

View File

@@ -411,6 +411,7 @@ exports.MessageTypes = [
* * STREAMING
* * LISTENING
* * WATCHING
* * CUSTOM_STATUS
* @typedef {string} ActivityType
*/
exports.ActivityTypes = [
@@ -418,6 +419,7 @@ exports.ActivityTypes = [
'STREAMING',
'LISTENING',
'WATCHING',
'CUSTOM_STATUS',
];
exports.ChannelTypes = {

6
typings/index.d.ts vendored
View File

@@ -25,7 +25,10 @@ declare module 'discord.js' {
constructor(presence: Presence, data?: object);
public applicationID: Snowflake | null;
public assets: RichPresenceAssets | null;
public readonly createdAt: Date;
public createdTimestamp: number;
public details: string | null;
public emoji: Emoji | null;
public name: string;
public party: {
id: string | null;
@@ -1913,7 +1916,8 @@ declare module 'discord.js' {
type ActivityType = 'PLAYING'
| 'STREAMING'
| 'LISTENING'
| 'WATCHING';
| 'WATCHING'
| 'CUSTOM_STATUS';
type MessageFlagsString = 'CROSSPOSTED'
| 'IS_CROSSPOST'