Skip to content

Commit

Permalink
refactor(Guild): remove fetchVanityCode() (#5471)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaporoxx committed Apr 3, 2021
1 parent 8023250 commit 0a2e0c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
26 changes: 1 addition & 25 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { deprecate } = require('util');
const Base = require('./Base');
const GuildAuditLogs = require('./GuildAuditLogs');
const GuildPreview = require('./GuildPreview');
Expand Down Expand Up @@ -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
* <info>You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it</info>
* @type {?number}
*/
this.vanityURLUses = null;
/* eslint-enable max-len */

/**
* The description of the guild, if any
Expand Down Expand Up @@ -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<string>}
* @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
Expand All @@ -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;
Expand Down Expand Up @@ -1478,9 +1459,4 @@ class Guild extends Base {
}
}

Guild.prototype.fetchVanityCode = deprecate(
Guild.prototype.fetchVanityCode,
'Guild#fetchVanityCode: Use fetchVanityData() instead',
);

module.exports = Guild;
8 changes: 6 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ declare module 'discord.js' {
public fetchInvites(): Promise<Collection<string, Invite>>;
public fetchPreview(): Promise<GuildPreview>;
public fetchTemplates(): Promise<Collection<GuildTemplate['code'], GuildTemplate>>;
public fetchVanityCode(): Promise<string>;
public fetchVanityData(): Promise<{ code: string; uses: number }>;
public fetchVanityData(): Promise<Vanity>;
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
public fetchWidget(): Promise<GuildWidget>;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0a2e0c0

Please sign in to comment.