mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(Guild): add support for premium/boosting (#3332)
Backports:
PR: #3316
Commit: c87758086b
This commit is contained in:
@@ -62,6 +62,13 @@ class Emoji {
|
||||
*/
|
||||
this.animated = data.animated;
|
||||
|
||||
/**
|
||||
* Whether this emoji is available
|
||||
* @type {boolean}
|
||||
* @name Emoji#available
|
||||
*/
|
||||
if (typeof data.available !== 'undefined') this.available = data.available;
|
||||
|
||||
this._roles = data.roles;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +184,30 @@ class Guild {
|
||||
this.defaultMessageNotifications = Constants.DefaultMessageNotifications[data.default_message_notifications] ||
|
||||
data.default_message_notifications;
|
||||
|
||||
/**
|
||||
* The type of premium tier:
|
||||
* * 0: NONE
|
||||
* * 1: TIER_1
|
||||
* * 2: TIER_2
|
||||
* * 3: TIER_3
|
||||
* @typedef {number} PremiumTier
|
||||
*/
|
||||
|
||||
/**
|
||||
* The premium tier on this guild
|
||||
* @type {PremiumTier}
|
||||
*/
|
||||
this.premiumTier = data.premium_tier;
|
||||
|
||||
/**
|
||||
* The total number of users currently boosting this server
|
||||
* @type {?number}
|
||||
* @name Guild#premiumSubscriptionCount
|
||||
*/
|
||||
if (typeof data.premium_subscription_count !== 'undefined') {
|
||||
this.premiumSubscriptionCount = data.premium_subscription_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hash of the guild banner
|
||||
* @type {?string}
|
||||
|
||||
@@ -37,6 +37,12 @@ class GuildMember {
|
||||
*/
|
||||
this.joinedTimestamp = null;
|
||||
|
||||
/**
|
||||
* The timestamp of when the member used their Nitro boost on the guild, if it was used
|
||||
* @type {?number}
|
||||
*/
|
||||
this.premiumSinceTimestamp = null;
|
||||
|
||||
this._roles = [];
|
||||
if (data) this.setup(data);
|
||||
|
||||
@@ -109,6 +115,7 @@ class GuildMember {
|
||||
this.nickname = data.nick || null;
|
||||
|
||||
if (data.joined_at) this.joinedTimestamp = new Date(data.joined_at).getTime();
|
||||
if (data.premium_since) this.premiumSinceTimestamp = new Date(data.premium_since).getTime();
|
||||
|
||||
this.user = data.user;
|
||||
this._roles = data.roles;
|
||||
@@ -123,6 +130,15 @@ class GuildMember {
|
||||
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time of when the member used their Nitro boost on the guild, if it was used
|
||||
* @type {?Date}
|
||||
* @readonly
|
||||
*/
|
||||
get premiumSince() {
|
||||
return this.premiumSinceTimestamp ? new Date(this.premiumSinceTimestamp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The presence of this member
|
||||
* @type {Presence}
|
||||
|
||||
@@ -480,6 +480,10 @@ exports.WSEvents = {
|
||||
* * CHANNEL_ICON_CHANGE
|
||||
* * PINS_ADD
|
||||
* * GUILD_MEMBER_JOIN
|
||||
* * USER_PREMIUM_GUILD_SUBSCRIPTION
|
||||
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1
|
||||
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2
|
||||
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3
|
||||
* @typedef {string} MessageType
|
||||
*/
|
||||
exports.MessageTypes = [
|
||||
@@ -491,6 +495,10 @@ exports.MessageTypes = [
|
||||
'CHANNEL_ICON_CHANGE',
|
||||
'PINS_ADD',
|
||||
'GUILD_MEMBER_JOIN',
|
||||
'USER_PREMIUM_GUILD_SUBSCRIPTION',
|
||||
'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1',
|
||||
'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2',
|
||||
'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
7
typings/index.d.ts
vendored
7
typings/index.d.ts
vendored
@@ -403,6 +403,7 @@ declare module 'discord.js' {
|
||||
export class Emoji {
|
||||
constructor(guild: Guild, data: object);
|
||||
public animated: boolean;
|
||||
public available: boolean;
|
||||
public readonly client: Client;
|
||||
public readonly createdAt: Date;
|
||||
public readonly createdTimestamp: number;
|
||||
@@ -516,6 +517,8 @@ declare module 'discord.js' {
|
||||
public readonly nameAcronym: string;
|
||||
public readonly owner: GuildMember;
|
||||
public ownerID: string;
|
||||
public premiumSubscriptionCount: number | null;
|
||||
public premiumTier: PremiumTier;
|
||||
public readonly position: number;
|
||||
public presences: Collection<Snowflake, Presence>;
|
||||
public region: string;
|
||||
@@ -665,6 +668,8 @@ declare module 'discord.js' {
|
||||
public nickname: string;
|
||||
public readonly manageable: boolean;
|
||||
public readonly permissions: Permissions;
|
||||
public readonly premiumSince: Date | null;
|
||||
public premiumSinceTimestamp: number | null;
|
||||
public readonly presence: Presence;
|
||||
public readonly roles: Collection<Snowflake, Role>;
|
||||
public selfDeaf: boolean;
|
||||
@@ -2058,6 +2063,8 @@ declare module 'discord.js' {
|
||||
|
||||
type PermissionResolvable = RecursiveArray<Permissions | PermissionString | number> | Permissions | PermissionString | number;
|
||||
|
||||
type PremiumTier = number;
|
||||
|
||||
type PresenceData = {
|
||||
status?: PresenceStatus;
|
||||
afk?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user