mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add support for premium guilds (#3316)
* add premiumTier and premiumSubscriptionCount * add premiumSinceTimestamp and premiumSince * add premium message types * typings * add GuildEmoji#available * fix doc description
This commit is contained in:
@@ -188,6 +188,30 @@ class Guild extends Base {
|
||||
*/
|
||||
this.embedEnabled = data.embed_enabled;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether widget images are enabled on this guild
|
||||
* @type {?boolean}
|
||||
|
||||
@@ -45,6 +45,13 @@ class GuildEmoji extends Emoji {
|
||||
*/
|
||||
if (typeof data.managed !== 'undefined') this.managed = data.managed;
|
||||
|
||||
/**
|
||||
* Whether this emoji is available
|
||||
* @type {boolean}
|
||||
* @name GuildEmoji#available
|
||||
*/
|
||||
if (typeof data.available !== 'undefined') this.available = data.available;
|
||||
|
||||
if (data.roles) this._roles = data.roles;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ class GuildMember extends Base {
|
||||
/**
|
||||
* The timestamp the member joined the guild at
|
||||
* @type {?number}
|
||||
* @name GuildMember#joinedTimestamp
|
||||
*/
|
||||
this.joinedTimestamp = null;
|
||||
|
||||
@@ -55,6 +54,12 @@ class GuildMember extends Base {
|
||||
*/
|
||||
this.lastMessageChannelID = null;
|
||||
|
||||
/**
|
||||
* The timestamp of when the member used their Nitro boost on the guild, if it was used
|
||||
* @type {?number}
|
||||
*/
|
||||
this.premiumSinceTimestamp = null;
|
||||
|
||||
/**
|
||||
* Whether the member has been removed from the guild
|
||||
* @type {boolean}
|
||||
@@ -74,6 +79,7 @@ class GuildMember extends Base {
|
||||
if (typeof data.nick !== 'undefined') this.nickname = data.nick;
|
||||
|
||||
if (data.joined_at) this.joinedTimestamp = new Date(data.joined_at).getTime();
|
||||
if (data.premium_since) this.premiumSinceTimestamp = new Date(data.premium_since).getTime();
|
||||
|
||||
if (data.user) this.user = this.guild.client.users.add(data.user);
|
||||
if (data.roles) this._roles = data.roles;
|
||||
@@ -131,6 +137,15 @@ class GuildMember extends Base {
|
||||
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 guild member
|
||||
* @type {Presence}
|
||||
|
||||
@@ -375,6 +375,10 @@ exports.WSEvents = keyMirror([
|
||||
* * 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 = [
|
||||
@@ -386,6 +390,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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
13
typings/index.d.ts
vendored
13
typings/index.d.ts
vendored
@@ -427,6 +427,8 @@ declare module 'discord.js' {
|
||||
public readonly nameAcronym: string;
|
||||
public readonly owner: GuildMember | null;
|
||||
public ownerID: Snowflake;
|
||||
public premiumSubscriptionCount: number | null;
|
||||
public premiumTier: PremiumTier;
|
||||
public presences: PresenceStore;
|
||||
public region: string;
|
||||
public roles: RoleStore;
|
||||
@@ -551,6 +553,7 @@ declare module 'discord.js' {
|
||||
constructor(client: Client, data: object, guild: Guild);
|
||||
private _roles: string[];
|
||||
|
||||
public available: boolean;
|
||||
public deleted: boolean;
|
||||
public guild: Guild;
|
||||
public managed: boolean;
|
||||
@@ -579,6 +582,8 @@ declare module 'discord.js' {
|
||||
public nickname: string;
|
||||
public readonly partial: boolean;
|
||||
public readonly permissions: Readonly<Permissions>;
|
||||
public readonly premiumSince: Date | null;
|
||||
public premiumSinceTimestamp: number | null;
|
||||
public readonly presence: Presence;
|
||||
public roles: GuildMemberRoleStore;
|
||||
public user: User;
|
||||
@@ -2039,7 +2044,11 @@ declare module 'discord.js' {
|
||||
| 'CHANNEL_NAME_CHANGE'
|
||||
| 'CHANNEL_ICON_CHANGE'
|
||||
| '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';
|
||||
|
||||
interface OverwriteData {
|
||||
allow?: PermissionResolvable;
|
||||
@@ -2099,6 +2108,8 @@ declare module 'discord.js' {
|
||||
id: UserResolvable | RoleResolvable;
|
||||
}
|
||||
|
||||
type PremiumTier = number;
|
||||
|
||||
interface PresenceData {
|
||||
status?: PresenceStatusData;
|
||||
afk?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user