mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +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;
|
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;
|
this._roles = data.roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,30 @@ class Guild {
|
|||||||
this.defaultMessageNotifications = Constants.DefaultMessageNotifications[data.default_message_notifications] ||
|
this.defaultMessageNotifications = Constants.DefaultMessageNotifications[data.default_message_notifications] ||
|
||||||
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
|
* The hash of the guild banner
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ class GuildMember {
|
|||||||
*/
|
*/
|
||||||
this.joinedTimestamp = null;
|
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 = [];
|
this._roles = [];
|
||||||
if (data) this.setup(data);
|
if (data) this.setup(data);
|
||||||
|
|
||||||
@@ -109,6 +115,7 @@ class GuildMember {
|
|||||||
this.nickname = data.nick || null;
|
this.nickname = data.nick || null;
|
||||||
|
|
||||||
if (data.joined_at) this.joinedTimestamp = new Date(data.joined_at).getTime();
|
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.user = data.user;
|
||||||
this._roles = data.roles;
|
this._roles = data.roles;
|
||||||
@@ -123,6 +130,15 @@ class GuildMember {
|
|||||||
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
|
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
|
* The presence of this member
|
||||||
* @type {Presence}
|
* @type {Presence}
|
||||||
|
|||||||
@@ -480,6 +480,10 @@ exports.WSEvents = {
|
|||||||
* * CHANNEL_ICON_CHANGE
|
* * CHANNEL_ICON_CHANGE
|
||||||
* * PINS_ADD
|
* * PINS_ADD
|
||||||
* * GUILD_MEMBER_JOIN
|
* * 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
|
* @typedef {string} MessageType
|
||||||
*/
|
*/
|
||||||
exports.MessageTypes = [
|
exports.MessageTypes = [
|
||||||
@@ -491,6 +495,10 @@ exports.MessageTypes = [
|
|||||||
'CHANNEL_ICON_CHANGE',
|
'CHANNEL_ICON_CHANGE',
|
||||||
'PINS_ADD',
|
'PINS_ADD',
|
||||||
'GUILD_MEMBER_JOIN',
|
'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 {
|
export class Emoji {
|
||||||
constructor(guild: Guild, data: object);
|
constructor(guild: Guild, data: object);
|
||||||
public animated: boolean;
|
public animated: boolean;
|
||||||
|
public available: boolean;
|
||||||
public readonly client: Client;
|
public readonly client: Client;
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
@@ -516,6 +517,8 @@ declare module 'discord.js' {
|
|||||||
public readonly nameAcronym: string;
|
public readonly nameAcronym: string;
|
||||||
public readonly owner: GuildMember;
|
public readonly owner: GuildMember;
|
||||||
public ownerID: string;
|
public ownerID: string;
|
||||||
|
public premiumSubscriptionCount: number | null;
|
||||||
|
public premiumTier: PremiumTier;
|
||||||
public readonly position: number;
|
public readonly position: number;
|
||||||
public presences: Collection<Snowflake, Presence>;
|
public presences: Collection<Snowflake, Presence>;
|
||||||
public region: string;
|
public region: string;
|
||||||
@@ -665,6 +668,8 @@ declare module 'discord.js' {
|
|||||||
public nickname: string;
|
public nickname: string;
|
||||||
public readonly manageable: boolean;
|
public readonly manageable: boolean;
|
||||||
public readonly permissions: Permissions;
|
public readonly permissions: Permissions;
|
||||||
|
public readonly premiumSince: Date | null;
|
||||||
|
public premiumSinceTimestamp: number | null;
|
||||||
public readonly presence: Presence;
|
public readonly presence: Presence;
|
||||||
public readonly roles: Collection<Snowflake, Role>;
|
public readonly roles: Collection<Snowflake, Role>;
|
||||||
public selfDeaf: boolean;
|
public selfDeaf: boolean;
|
||||||
@@ -2058,6 +2063,8 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type PermissionResolvable = RecursiveArray<Permissions | PermissionString | number> | Permissions | PermissionString | number;
|
type PermissionResolvable = RecursiveArray<Permissions | PermissionString | number> | Permissions | PermissionString | number;
|
||||||
|
|
||||||
|
type PremiumTier = number;
|
||||||
|
|
||||||
type PresenceData = {
|
type PresenceData = {
|
||||||
status?: PresenceStatus;
|
status?: PresenceStatus;
|
||||||
afk?: boolean;
|
afk?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user