feat(Guild): setVanityCode
Co-Authored-By: Chino-chan <93425627+Tungchaphet@users.noreply.github.com> #533
This commit is contained in:
		@@ -1620,6 +1620,33 @@ class Guild extends AnonymousGuild {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Set the vanity URL to this guild.
 | 
			
		||||
   * Resolves with an object containing the vanity URL invite code and the use count.
 | 
			
		||||
   * @param {string} [code=''] Vanity URL code
 | 
			
		||||
   * @returns {Promise<Vanity>}
 | 
			
		||||
   * @example
 | 
			
		||||
   * // Set invite code
 | 
			
		||||
   * guild.setVanityCode('elysia')
 | 
			
		||||
   *   .then(res => {
 | 
			
		||||
   *     console.log(`Vanity URL: https://discord.gg/${res.code} with ${res.uses} uses`);
 | 
			
		||||
   *   })
 | 
			
		||||
   *   .catch(console.error);
 | 
			
		||||
   */
 | 
			
		||||
  async setVanityCode(code = '') {
 | 
			
		||||
    if (!this.features.includes('VANITY_URL')) {
 | 
			
		||||
      throw new Error('VANITY_URL');
 | 
			
		||||
    }
 | 
			
		||||
    if (typeof code !== 'string') throw new TypeError('INVALID_VANITY_URL_CODE');
 | 
			
		||||
    const data = await this.client.api.guilds(this.id, 'vanity-url').patch({
 | 
			
		||||
      data: { code },
 | 
			
		||||
    });
 | 
			
		||||
    this.vanityURLCode = data.code;
 | 
			
		||||
    this.vanityURLUses = data.uses;
 | 
			
		||||
 | 
			
		||||
    return data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  toJSON() {
 | 
			
		||||
    const json = super.toJSON({
 | 
			
		||||
      available: false,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								typings/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								typings/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1441,6 +1441,7 @@ export class Guild extends AnonymousGuild {
 | 
			
		||||
    reason?: string,
 | 
			
		||||
  ): Promise<Guild>;
 | 
			
		||||
  public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise<Guild>;
 | 
			
		||||
  public setVanityCode(code?: string): Promise<Vanity>;
 | 
			
		||||
  public toJSON(): unknown;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user