mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +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 Base = require('./Base');
|
||||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||||
const { Error } = require('../errors');
|
|
||||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
const UserFlags = require('../util/UserFlags');
|
const UserFlags = require('../util/UserFlags');
|
||||||
|
|
||||||
@@ -180,15 +179,12 @@ class User extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the user's banner.
|
* A link to the user's banner. See {@link User#banner} for more info
|
||||||
* <info>This method will throw an error if called before the user is force fetched.
|
|
||||||
* See {@link User#banner} for more info</info>
|
|
||||||
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
||||||
* @returns {?string}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
bannerURL({ format, size, dynamic } = {}) {
|
bannerURL({ format, size, dynamic } = {}) {
|
||||||
if (typeof this.banner === 'undefined') throw new Error('USER_BANNER_NOT_FETCHED');
|
if (!this.banner) return this.banner;
|
||||||
if (!this.banner) return null;
|
|
||||||
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
|
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 readonly tag: string;
|
||||||
public username: string;
|
public username: string;
|
||||||
public avatarURL(options?: ImageURLOptions): string | null;
|
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 createDM(force?: boolean): Promise<DMChannel>;
|
||||||
public deleteDM(): Promise<DMChannel>;
|
public deleteDM(): Promise<DMChannel>;
|
||||||
public displayAvatarURL(options?: ImageURLOptions): string;
|
public displayAvatarURL(options?: ImageURLOptions): string;
|
||||||
|
|||||||
Reference in New Issue
Block a user