mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
feat: add VanityData typedef and populate vanityURLUses
This commit is contained in:
@@ -311,6 +311,12 @@ class Guild extends Base {
|
|||||||
*/
|
*/
|
||||||
this.vanityURLCode = data.vanity_url_code;
|
this.vanityURLCode = data.vanity_url_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The use count of the vanity URL code of the guild, if any
|
||||||
|
* @type {?number}
|
||||||
|
*/
|
||||||
|
this.vanityURLUses = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of the guild, if any
|
* The description of the guild, if any
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
@@ -748,10 +754,17 @@ class Guild extends Base {
|
|||||||
}, 'fetchVanityCode() is deprecated. Use fetchVanityData() instead.');
|
}, 'fetchVanityCode() is deprecated. Use fetchVanityData() instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object containing information about a guild member's ban.
|
||||||
|
* @typedef {Object} VanityData
|
||||||
|
* @property {?string} code Vanity URL invite code, not the full url
|
||||||
|
* @property {?number} uses How many times this invite has been used
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the vanity url invite object to this guild.
|
* Fetches the vanity url invite object to this guild.
|
||||||
* Resolves with an object containing the vanity url invite code, not the full url and the use count.
|
* Resolves with an object containing the vanity url invite code and the use count
|
||||||
* @returns {Promise<{ code: ?string, uses: ?number }>}
|
* @returns {Promise<VanityData>}
|
||||||
* @example
|
* @example
|
||||||
* // Fetch invite data
|
* // Fetch invite data
|
||||||
* guild.fetchVanityData()
|
* guild.fetchVanityData()
|
||||||
@@ -764,7 +777,10 @@ class Guild extends Base {
|
|||||||
if (!this.features.includes('VANITY_URL')) {
|
if (!this.features.includes('VANITY_URL')) {
|
||||||
return Promise.reject(new Error('VANITY_URL'));
|
return Promise.reject(new Error('VANITY_URL'));
|
||||||
}
|
}
|
||||||
return this.client.api.guilds(this.id, 'vanity-url').get();
|
const data = this.client.api.guilds(this.id, 'vanity-url').get();
|
||||||
|
this.vanityURLUses = data.uses;
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user