diff --git a/lib/structures/Member.ts b/lib/structures/Member.ts index 08e840f4..d715fb42 100644 --- a/lib/structures/Member.ts +++ b/lib/structures/Member.ts @@ -26,6 +26,8 @@ export default class Member extends Base { avatar: string | null; /** The data for this user's avatar decoration. */ avatarDecorationData: AvatarDecorationData | null; + /** The member's banner hash, if they have set a guild banner. */ + banner: string | null; /** When the member's [timeout](https://support.discord.com/hc/en-us/articles/4413305239191-Time-Out-FAQ) will expire, if active. */ communicationDisabledUntil: Date | null; /** If this member is server deafened. */ @@ -66,6 +68,7 @@ export default class Member extends Base { super(user.id, client); this.avatar = null; this.avatarDecorationData = null; + this.banner = null; this.communicationDisabledUntil = null; this.deaf = !!data.deaf; this.flags = 0; @@ -94,6 +97,9 @@ export default class Member extends Base { skuID: data.avatar_decoration_data.sku_id } : null; } + if (data.banner !== undefined) { + this.banner = data.banner; + } if (data.communication_disabled_until !== undefined) { this.communicationDisabledUntil = data.communication_disabled_until === null ? null : new Date(data.communication_disabled_until); } @@ -231,6 +237,15 @@ export default class Member extends Base { await this.client.rest.guilds.createBan(this.guildID, this.id, options); } + /** + * The url of this user's guild banner (or their user banner if no guild banner is set). + * @param format The format the url should be. + * @param size The dimensions of the image. + */ + bannerURL(format?: ImageFormat, size?: number): string | null { + return this.banner === null ? this.user.bannerURL(format, size) : this.client.util.formatImage(Routes.MEMBER_BANNER(this.guildID, this.id, this.banner), format, size); + } + /** * Disable the `BYPASSES_VERIFICATION` flag for this member. Requires any of the following permission sets: * * MANAGE_GUILD @@ -288,6 +303,7 @@ export default class Member extends Base { ...super.toJSON(), avatar: this.avatar, avatarDecorationData: this.avatarDecorationData, + banner: this.banner, communicationDisabledUntil: this.communicationDisabledUntil?.getTime() ?? null, deaf: this.deaf, flags: this.flags, diff --git a/lib/types/guilds.d.ts b/lib/types/guilds.d.ts index e216b59c..74375656 100644 --- a/lib/types/guilds.d.ts +++ b/lib/types/guilds.d.ts @@ -204,6 +204,7 @@ export interface Sticker { export interface RawMember { avatar?: string | null; avatar_decoration_data?: RawAvatarDecorationData | null; + banner?: string | null; communication_disabled_until?: string | null; deaf: boolean; /** undocumented */ diff --git a/lib/types/json.d.ts b/lib/types/json.d.ts index 260d956f..fd99a138 100644 --- a/lib/types/json.d.ts +++ b/lib/types/json.d.ts @@ -440,6 +440,7 @@ export interface JSONMediaChannel extends JSONThreadOnlyChannel { export interface JSONMember extends JSONBase { avatar: string | null; avatarDecorationData: AvatarDecorationData | null; + banner: string | null; communicationDisabledUntil: number | null; deaf: boolean; flags?: number;