From 0a2e0c0e3e06dc63359c4f69d74df3365e413f76 Mon Sep 17 00:00:00 2001 From: Jan <66554238+vaporox@users.noreply.github.com> Date: Sat, 3 Apr 2021 20:01:14 +0200 Subject: [PATCH] refactor(Guild): remove fetchVanityCode() (#5471) --- src/structures/Guild.js | 26 +------------------------- typings/index.d.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 1ba916704..d2690101a 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -1,6 +1,5 @@ 'use strict'; -const { deprecate } = require('util'); const Base = require('./Base'); const GuildAuditLogs = require('./GuildAuditLogs'); const GuildPreview = require('./GuildPreview'); @@ -335,14 +334,12 @@ class Guild extends Base { */ this.vanityURLCode = data.vanity_url_code; - /* eslint-disable max-len */ /** * The use count of the vanity URL code of the guild, if any * You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it * @type {?number} */ this.vanityURLUses = null; - /* eslint-enable max-len */ /** * The description of the guild, if any @@ -764,23 +761,6 @@ class Guild extends Base { .then(data => new GuildPreview(this.client, data)); } - /** - * Fetches the vanity url invite code to this guild. - * Resolves with a string matching the vanity url invite code, not the full url. - * @returns {Promise} - * @deprecated - * @example - * // Fetch invites - * guild.fetchVanityCode() - * .then(code => { - * console.log(`Vanity URL: https://discord.gg/${code}`); - * }) - * .catch(console.error); - */ - fetchVanityCode() { - return this.fetchVanityData().then(vanity => vanity.code); - } - /** * An object containing information about a guild's vanity invite. * @typedef {Object} Vanity @@ -805,6 +785,7 @@ class Guild extends Base { throw new Error('VANITY_URL'); } const data = await this.client.api.guilds(this.id, 'vanity-url').get(); + this.vanityURLCode = data.code; this.vanityURLUses = data.uses; return data; @@ -1478,9 +1459,4 @@ class Guild extends Base { } } -Guild.prototype.fetchVanityCode = deprecate( - Guild.prototype.fetchVanityCode, - 'Guild#fetchVanityCode: Use fetchVanityData() instead', -); - module.exports = Guild; diff --git a/typings/index.d.ts b/typings/index.d.ts index 4d485a7f9..9a089a2dd 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -662,8 +662,7 @@ declare module 'discord.js' { public fetchInvites(): Promise>; public fetchPreview(): Promise; public fetchTemplates(): Promise>; - public fetchVanityCode(): Promise; - public fetchVanityData(): Promise<{ code: string; uses: number }>; + public fetchVanityData(): Promise; public fetchVoiceRegions(): Promise>; public fetchWebhooks(): Promise>; public fetchWidget(): Promise; @@ -3359,6 +3358,11 @@ declare module 'discord.js' { type UserResolvable = User | Snowflake | Message | GuildMember; + interface Vanity { + code: string | null; + uses: number | null; + } + type VerificationLevel = 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH' | 'VERY_HIGH'; type VoiceStatus = number;