Skip to content

Commit

Permalink
Add guild member banners
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jul 16, 2024
1 parent e5fa7c6 commit 0135689
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/structures/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/types/guilds.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions lib/types/json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0135689

Please sign in to comment.