backport(Guild): add fetchVanityCode (#2871)

This commit is contained in:
SpaceEEC
2018-10-04 00:31:20 +02:00
committed by Isabella
parent 1e85887229
commit c6201ee41b
4 changed files with 27 additions and 0 deletions

View File

@@ -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>>}