mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +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 Util = require('../util/Util');
|
||||||
const ActivityFlags = require('../util/ActivityFlags');
|
const ActivityFlags = require('../util/ActivityFlags');
|
||||||
const { ActivityTypes } = require('../util/Constants');
|
const { ActivityTypes } = require('../util/Constants');
|
||||||
|
const Emoji = require('./Emoji');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity sent in a message.
|
* Activity sent in a message.
|
||||||
@@ -205,6 +206,18 @@ class Activity {
|
|||||||
* @type {Readonly<ActivityFlags>}
|
* @type {Readonly<ActivityFlags>}
|
||||||
*/
|
*/
|
||||||
this.flags = new ActivityFlags(data.flags).freeze();
|
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.
|
* When concatenated with a string, this automatically returns the activities' name instead of the Activity object.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
|||||||
@@ -411,6 +411,7 @@ exports.MessageTypes = [
|
|||||||
* * STREAMING
|
* * STREAMING
|
||||||
* * LISTENING
|
* * LISTENING
|
||||||
* * WATCHING
|
* * WATCHING
|
||||||
|
* * CUSTOM_STATUS
|
||||||
* @typedef {string} ActivityType
|
* @typedef {string} ActivityType
|
||||||
*/
|
*/
|
||||||
exports.ActivityTypes = [
|
exports.ActivityTypes = [
|
||||||
@@ -418,6 +419,7 @@ exports.ActivityTypes = [
|
|||||||
'STREAMING',
|
'STREAMING',
|
||||||
'LISTENING',
|
'LISTENING',
|
||||||
'WATCHING',
|
'WATCHING',
|
||||||
|
'CUSTOM_STATUS',
|
||||||
];
|
];
|
||||||
|
|
||||||
exports.ChannelTypes = {
|
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);
|
constructor(presence: Presence, data?: object);
|
||||||
public applicationID: Snowflake | null;
|
public applicationID: Snowflake | null;
|
||||||
public assets: RichPresenceAssets | null;
|
public assets: RichPresenceAssets | null;
|
||||||
|
public readonly createdAt: Date;
|
||||||
|
public createdTimestamp: number;
|
||||||
public details: string | null;
|
public details: string | null;
|
||||||
|
public emoji: Emoji | null;
|
||||||
public name: string;
|
public name: string;
|
||||||
public party: {
|
public party: {
|
||||||
id: string | null;
|
id: string | null;
|
||||||
@@ -1913,7 +1916,8 @@ declare module 'discord.js' {
|
|||||||
type ActivityType = 'PLAYING'
|
type ActivityType = 'PLAYING'
|
||||||
| 'STREAMING'
|
| 'STREAMING'
|
||||||
| 'LISTENING'
|
| 'LISTENING'
|
||||||
| 'WATCHING';
|
| 'WATCHING'
|
||||||
|
| 'CUSTOM_STATUS';
|
||||||
|
|
||||||
type MessageFlagsString = 'CROSSPOSTED'
|
type MessageFlagsString = 'CROSSPOSTED'
|
||||||
| 'IS_CROSSPOST'
|
| 'IS_CROSSPOST'
|
||||||
|
|||||||
Reference in New Issue
Block a user