mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(User): bannerURL() should not throw when not present (#6789)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user