diff --git a/packages/utils/src/images.ts b/packages/utils/src/images.ts index 66c0e6593..5d0a5a7e5 100644 --- a/packages/utils/src/images.ts +++ b/packages/utils/src/images.ts @@ -241,6 +241,34 @@ export function memberAvatarUrl( : undefined } +/** + * Builds a URL to a member's banner stored in the Discord CDN. + * + * @param guildId - The ID of the guild where the member is + * @param userId - The ID of the user to get the banner of. + * @param options - The parameters for the building of the URL. + * @returns The link to the resource or `undefined` if no banner has been set. + */ +export function memberBannerUrl( + guildId: BigString, + userId: BigString, + options?: { + banner?: BigString + size?: ImageSize + format?: ImageFormat + }, +): string | undefined { + return options?.banner + ? formatImageUrl( + `https://cdn.discordapp.com/guilds/${guildId}/users/${userId}/banners/${ + typeof options.banner === 'string' ? options.banner : iconBigintToHash(options.banner) + }`, + options?.size ?? 128, + options?.format, + ) + : undefined +} + /** * Builds the URL to an application icon stored in the Discord CDN. *