From 02b5678a011da336910a79d0042caf0b8de7afa0 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Mon, 20 Apr 2020 03:30:27 +1000 Subject: [PATCH] feat: add VanityData typedef and populate vanityURLUses --- src/structures/Guild.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 9f1786604..ce027d2d4 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -311,6 +311,12 @@ class Guild extends Base { */ 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 * @type {?string} @@ -748,10 +754,17 @@ class Guild extends Base { }, '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. - * Resolves with an object containing the vanity url invite code, not the full url and the use count. - * @returns {Promise<{ code: ?string, uses: ?number }>} + * Resolves with an object containing the vanity url invite code and the use count + * @returns {Promise} * @example * // Fetch invite data * guild.fetchVanityData() @@ -764,7 +777,10 @@ class Guild extends Base { if (!this.features.includes('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; } /**