Add function to get vanity URL uses
See original GitHub issueIs your feature request related to a problem? Please describe. I want to get the uses of a vanity URL, but there is no function for that.
Describe the ideal solution
Add a function Guild.fetchVanityUses()
that gets the uses of a vanity URL, if any.
Describe alternatives you’ve considered
It is already possible to get vanity invites via client.fetchInvite(server.vanityURLCode)
, but the .uses
is always null
. Instead of the extra function the implementation could fill that field. Alternatively the fetchInvites
function could be changed to include the vanity URL invite and its uses.
Additional context The Discord API supports this: https://discordapp.com/developers/docs/resources/guild#get-guild-vanity-url There is this code in https://github.com/discordjs/discord.js/blob/master/src/structures/Guild.js#L726-L746:
fetchVanityCode() {
if (!this.features.includes('VANITY_URL')) {
return Promise.reject(new Error('VANITY_URL'));
}
return this.client.api
.guilds(this.id, 'vanity-url')
.get()
.then(res => res.code);
}
so it should be relatively easy to add
fetchVanityUses() {
if (!this.features.includes('VANITY_URL')) {
return Promise.reject(new Error('VANITY_URL'));
}
return this.client.api
.guilds(this.id, 'vanity-url')
.get()
.then(res => res.uses);
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
The linked PR #4103 will provide the ability to fetch the vanity data from the
/guilds/{guild.id}/vanity-url
endpoint - there’s really no need to discuss it further here or implement a workaround by Invite.