fix(User): bannerURL() should not throw when not present (#6789)

This commit is contained in:
Suneet Tipirneni
2022-01-07 18:48:46 -05:00
committed by GitHub
parent 12ffa069aa
commit 3872acfeb8
2 changed files with 3 additions and 7 deletions

View File

@@ -2,7 +2,6 @@
const Base = require('./Base');
const TextBasedChannel = require('./interfaces/TextBasedChannel');
const { Error } = require('../errors');
const SnowflakeUtil = require('../util/SnowflakeUtil');
const UserFlags = require('../util/UserFlags');
@@ -180,15 +179,12 @@ class User extends Base {
}
/**
* A link to the user's banner.
* <info>This method will throw an error if called before the user is force fetched.
* See {@link User#banner} for more info</info>
* A link to the user's banner. See {@link User#banner} for more info
* @param {ImageURLOptions} [options={}] Options for the Image URL
* @returns {?string}
*/
bannerURL({ format, size, dynamic } = {}) {
if (typeof this.banner === 'undefined') throw new Error('USER_BANNER_NOT_FETCHED');
if (!this.banner) return null;
if (!this.banner) return this.banner;
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
}

View File

@@ -2381,7 +2381,7 @@ export class User extends PartialTextBasedChannel(Base) {
public readonly tag: string;
public username: string;
public avatarURL(options?: ImageURLOptions): string | null;
public bannerURL(options?: ImageURLOptions): string | null;
public bannerURL(options?: ImageURLOptions): string | null | undefined;
public createDM(force?: boolean): Promise<DMChannel>;
public deleteDM(): Promise<DMChannel>;
public displayAvatarURL(options?: ImageURLOptions): string;