mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
backport(Guild): add fetchVanityCode (#2871)
This commit is contained in:
@@ -504,6 +504,26 @@ class Guild {
|
||||
return this.client.rest.methods.getGuildInvites(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>}
|
||||
* @example
|
||||
* // Fetch invites
|
||||
* guild.fetchVanityCode()
|
||||
* .then(code => {
|
||||
* console.log(`Vanity URL: https://discord.gg/${code}`);
|
||||
* })
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchVanityCode() {
|
||||
if (!this.features.includes('VANITY_URL')) {
|
||||
return Promise.reject(new Error('This guild does not have the VANITY_URL feature enabled.'));
|
||||
}
|
||||
return this.client.rest.methods.getGuildVanityCode(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch all webhooks for the guild.
|
||||
* @returns {Promise<Collection<Snowflake, Webhook>>}
|
||||
|
||||
Reference in New Issue
Block a user