Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Guild): add enum for premium_tier #5868

Merged
merged 1 commit into from Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -3604,7 +3612,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