From a7b80b9d9bf4902bd85b592986771eadf7a765dc Mon Sep 17 00:00:00 2001 From: Almeida Date: Sat, 5 Feb 2022 13:30:14 +0000 Subject: [PATCH] types: use `GuildFeature` enum from `discord-api-types` (#7397) --- packages/discord.js/src/index.js | 1 + .../discord.js/src/structures/BaseGuild.js | 2 +- packages/discord.js/src/structures/Guild.js | 30 +---------------- .../discord.js/src/structures/GuildPreview.js | 2 +- packages/discord.js/typings/index.d.ts | 32 +++---------------- 5 files changed, 9 insertions(+), 58 deletions(-) diff --git a/packages/discord.js/src/index.js b/packages/discord.js/src/index.js index 13270cd06..61bccf422 100644 --- a/packages/discord.js/src/index.js +++ b/packages/discord.js/src/index.js @@ -161,6 +161,7 @@ exports.ButtonStyle = require('discord-api-types/v9').ButtonStyle; exports.ChannelType = require('discord-api-types/v9').ChannelType; exports.ComponentType = require('discord-api-types/v9').ComponentType; exports.GatewayIntentBits = require('discord-api-types/v9').GatewayIntentBits; +exports.GuildFeature = require('discord-api-types/v9').GuildFeature; exports.GuildMFALevel = require('discord-api-types/v9').GuildMFALevel; exports.GuildNSFWLevel = require('discord-api-types/v9').GuildNSFWLevel; exports.GuildPremiumTier = require('discord-api-types/v9').GuildPremiumTier; diff --git a/packages/discord.js/src/structures/BaseGuild.js b/packages/discord.js/src/structures/BaseGuild.js index 580a28170..fd99b9539 100644 --- a/packages/discord.js/src/structures/BaseGuild.js +++ b/packages/discord.js/src/structures/BaseGuild.js @@ -33,7 +33,7 @@ class BaseGuild extends Base { /** * An array of features available to this guild - * @type {Features[]} + * @type {GuildFeature[]} */ this.features = data.features; } diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index acb2892f4..7c58c787f 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -169,34 +169,6 @@ class Guild extends AnonymousGuild { this.premiumProgressBarEnabled = data.premium_progress_bar_enabled; } - /** - * An array of enabled guild features, here are the possible values: - * * ANIMATED_ICON - * * BANNER - * * COMMERCE - * * COMMUNITY - * * DISCOVERABLE - * * FEATURABLE - * * INVITE_SPLASH - * * MEMBER_VERIFICATION_GATE_ENABLED - * * NEWS - * * PARTNERED - * * PREVIEW_ENABLED - * * VANITY_URL - * * VERIFIED - * * VIP_REGIONS - * * WELCOME_SCREEN_ENABLED - * * TICKETED_EVENTS_ENABLED - * * MONETIZATION_ENABLED - * * MORE_STICKERS - * * THREE_DAY_THREAD_ARCHIVE - * * SEVEN_DAY_THREAD_ARCHIVE - * * PRIVATE_THREADS - * * ROLE_ICONS - * @typedef {string} Features - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-features} - */ - if ('application_id' in data) { /** * The id of the application that created this guild (if applicable) @@ -789,7 +761,7 @@ class Guild extends AnonymousGuild { * @property {string} [preferredLocale] The preferred locale of the guild * @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled * @property {string} [description] The discovery description of the guild - * @property {Features[]} [features] The features of the guild + * @property {GuildFeature[]} [features] The features of the guild */ /** diff --git a/packages/discord.js/src/structures/GuildPreview.js b/packages/discord.js/src/structures/GuildPreview.js index cef18a31c..01654744e 100644 --- a/packages/discord.js/src/structures/GuildPreview.js +++ b/packages/discord.js/src/structures/GuildPreview.js @@ -62,7 +62,7 @@ class GuildPreview extends Base { if ('features' in data) { /** * An array of enabled guild features - * @type {Features[]} + * @type {GuildFeature[]} */ this.features = data.features; } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 630e6f8fb..a1eeeb8b2 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -54,6 +54,7 @@ import { ComponentType, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, + GuildFeature, GuildMFALevel, GuildNSFWLevel, GuildPremiumTier, @@ -355,7 +356,7 @@ export abstract class BaseGuild extends Base { protected constructor(client: Client, data: RawBaseGuildData); public readonly createdAt: Date; public readonly createdTimestamp: number; - public features: GuildFeatures[]; + public features: GuildFeature[]; public icon: string | null; public id: Snowflake; public name: string; @@ -1137,7 +1138,7 @@ export class GuildPreview extends Base { public discoverySplash: string | null; public emojis: Collection; public stickers: Collection; - public features: GuildFeatures[]; + public features: GuildFeature[]; public icon: string | null; public id: Snowflake; public name: string; @@ -4281,7 +4282,7 @@ export interface GuildEditData { preferredLocale?: string; premiumProgressBarEnabled?: boolean; description?: string | null; - features?: GuildFeatures[]; + features?: GuildFeature[]; } export interface GuildEmojiCreateOptions { @@ -4305,30 +4306,6 @@ export interface GuildStickerEditData { tags?: string; } -export type GuildFeatures = - | 'ANIMATED_ICON' - | 'BANNER' - | 'COMMERCE' - | 'COMMUNITY' - | 'DISCOVERABLE' - | 'FEATURABLE' - | 'INVITE_SPLASH' - | 'MEMBER_VERIFICATION_GATE_ENABLED' - | 'NEWS' - | 'PARTNERED' - | 'PREVIEW_ENABLED' - | 'VANITY_URL' - | 'VERIFIED' - | 'VIP_REGIONS' - | 'WELCOME_SCREEN_ENABLED' - | 'TICKETED_EVENTS_ENABLED' - | 'MONETIZATION_ENABLED' - | 'MORE_STICKERS' - | 'THREE_DAY_THREAD_ARCHIVE' - | 'SEVEN_DAY_THREAD_ARCHIVE' - | 'PRIVATE_THREADS' - | 'ROLE_ICONS'; - export interface GuildMemberEditData { nick?: string | null; roles?: Collection | readonly RoleResolvable[]; @@ -5188,6 +5165,7 @@ export { ButtonStyle, ChannelType, ComponentType, + GuildFeature, GuildMFALevel, GuildNSFWLevel, GuildPremiumTier,