mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
refactor(Guild): remove fetchVanityCode() (#5471)
This commit is contained in:
@@ -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
|
||||
* <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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
8
typings/index.d.ts
vendored
8
typings/index.d.ts
vendored
@@ -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>;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user