mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
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:
committed by
SpaceEEC
parent
1b1289b35e
commit
2ca74d6b63
@@ -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}
|
||||
|
||||
@@ -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
6
typings/index.d.ts
vendored
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user