From e5ec1c4dbc3fa54b2c43d1fec24932d7363e17cb Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 17 Jun 2022 22:25:29 +0100 Subject: [PATCH] refactor: Use `GuildFeature` enum (#8101) --- packages/discord.js/src/structures/BaseGuild.js | 6 +++--- packages/discord.js/src/structures/Guild.js | 6 +++--- packages/discord.js/src/structures/WelcomeScreen.js | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/discord.js/src/structures/BaseGuild.js b/packages/discord.js/src/structures/BaseGuild.js index c134a7e74..b12ca447d 100644 --- a/packages/discord.js/src/structures/BaseGuild.js +++ b/packages/discord.js/src/structures/BaseGuild.js @@ -2,7 +2,7 @@ const { makeURLSearchParams } = require('@discordjs/rest'); const { DiscordSnowflake } = require('@sapphire/snowflake'); -const { Routes } = require('discord-api-types/v10'); +const { Routes, GuildFeature } = require('discord-api-types/v10'); const Base = require('./Base'); /** @@ -75,7 +75,7 @@ class BaseGuild extends Base { * @readonly */ get partnered() { - return this.features.includes('PARTNERED'); + return this.features.includes(GuildFeature.Partnered); } /** @@ -84,7 +84,7 @@ class BaseGuild extends Base { * @readonly */ get verified() { - return this.features.includes('VERIFIED'); + return this.features.includes(GuildFeature.Verified); } /** diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 00335080a..d464a9717 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -2,7 +2,7 @@ const { Collection } = require('@discordjs/collection'); const { makeURLSearchParams } = require('@discordjs/rest'); -const { ChannelType, GuildPremiumTier, Routes } = require('discord-api-types/v10'); +const { ChannelType, GuildPremiumTier, Routes, GuildFeature } = require('discord-api-types/v10'); const AnonymousGuild = require('./AnonymousGuild'); const GuildAuditLogs = require('./GuildAuditLogs'); const GuildAuditLogsEntry = require('./GuildAuditLogsEntry'); @@ -510,7 +510,7 @@ class Guild extends AnonymousGuild { * @readonly */ get maximumBitrate() { - if (this.features.includes('VIP_REGIONS')) { + if (this.features.includes(GuildFeature.VIPRegions)) { return 384_000; } @@ -603,7 +603,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ async fetchVanityData() { - if (!this.features.includes('VANITY_URL')) { + if (!this.features.includes(GuildFeature.VanityURL)) { throw new Error('VANITY_URL'); } const data = await this.client.rest.get(Routes.guildVanityUrl(this.id)); diff --git a/packages/discord.js/src/structures/WelcomeScreen.js b/packages/discord.js/src/structures/WelcomeScreen.js index b4b7449a6..9ff79bc82 100644 --- a/packages/discord.js/src/structures/WelcomeScreen.js +++ b/packages/discord.js/src/structures/WelcomeScreen.js @@ -1,6 +1,7 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { GuildFeature } = require('discord-api-types/v10'); const Base = require('./Base'); const WelcomeChannel = require('./WelcomeChannel'); @@ -37,11 +38,11 @@ class WelcomeScreen extends Base { } /** - * Whether the welcome screen is enabled on the guild or not + * Whether the welcome screen is enabled on the guild * @type {boolean} */ get enabled() { - return this.guild.features.includes('WELCOME_SCREEN_ENABLED'); + return this.guild.features.includes(GuildFeature.WelcomeScreenEnabled); } }