Skip to content

Commit

Permalink
feat(Guild): add enum for premium_tier (#5868)
Browse files Browse the repository at this point in the history
  • Loading branch information
iShibi committed Jun 16, 2021
1 parent a0b7d95 commit a3cbcca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/structures/Guild.js
Expand Up @@ -27,6 +27,7 @@ const {
NSFWLevels,
Status,
MFALevels,
PremiumTiers,
} = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const SystemChannelFlags = require('../util/SystemChannelFlags');
Expand Down Expand Up @@ -217,19 +218,10 @@ class Guild extends BaseGuild {
this.systemChannelID = data.system_channel_id;

/**
* 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
* The premium tier of this guild
* @type {PremiumTier}
*/
this.premiumTier = data.premium_tier;
this.premiumTier = PremiumTiers[data.premium_tier];

if (typeof data.premium_subscription_count !== 'undefined') {
/**
Expand Down
10 changes: 10 additions & 0 deletions src/util/Constants.js
Expand Up @@ -865,6 +865,16 @@ exports.NSFWLevels = createEnum(['DEFAULT', 'EXPLICIT', 'SAFE', 'AGE_RESTRICTED'
*/
exports.PrivacyLevels = createEnum([null, 'PUBLIC', 'GUILD_ONLY']);

/**
* The premium tier (Server Boost level) of a guild:
* * NONE
* * TIER_1
* * TIER_2
* * TIER_3
* @typedef {string} PremiumTier
*/
exports.PremiumTiers = createEnum(['NONE', 'TIER_1', 'TIER_2', 'TIER_3']);

function keyMirror(arr) {
let tmp = Object.create(null);
for (const value of arr) tmp[value] = value;
Expand Down
10 changes: 9 additions & 1 deletion typings/index.d.ts
Expand Up @@ -95,6 +95,13 @@ declare enum OverwriteTypes {
member = 1,
}

declare enum PremiumTiers {
NONE = 0,
TIER_1 = 1,
TIER_2 = 2,
TIER_3 = 3,
}

declare enum PrivacyLevels {
PUBLIC = 1,
GUILD_ONLY = 2,
Expand Down Expand Up @@ -717,6 +724,7 @@ declare module 'discord.js' {
NSFWLevels: typeof NSFWLevels;
PrivacyLevels: typeof PrivacyLevels;
WebhookTypes: typeof WebhookTypes;
PremiumTiers: typeof PremiumTiers;
};

export class DataResolver {
Expand Down Expand Up @@ -3605,7 +3613,7 @@ declare module 'discord.js' {

type RecursiveReadonlyArray<T> = ReadonlyArray<T | RecursiveReadonlyArray<T>>;

type PremiumTier = 0 | 1 | 2 | 3;
type PremiumTier = keyof typeof PremiumTiers;

interface PresenceData {
status?: PresenceStatusData;
Expand Down

0 comments on commit a3cbcca

Please sign in to comment.