-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
getGuildSplashUrl.ts
33 lines (32 loc) · 1.04 KB
/
getGuildSplashUrl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type { Bot } from "../../bot.ts";
import { BigString } from "../../types/shared.ts";
import { ImageFormat, ImageSize } from "../members/getAvatarUrl.ts";
/**
* Builds the URL to a guild splash stored in the Discord CDN.
*
* @param bot - The bot instance to use to build the URL.
* @param guildId - The ID of the guild to get the splash of.
* @param imageHash - The hash identifying the splash image.
* @param options - The parameters for the building of the URL.
* @returns The link to the resource or `undefined` if the guild does not have a splash image set.
*/
export function getGuildSplashURL(
bot: Bot,
guildId: BigString,
imageHash: BigString | undefined,
options?: {
size?: ImageSize;
format?: ImageFormat;
},
): string | undefined {
return imageHash
? bot.utils.formatImageURL(
bot.constants.routes.GUILD_SPLASH(
guildId,
typeof imageHash === "string" ? imageHash : bot.utils.iconBigintToHash(imageHash),
),
options?.size || 128,
options?.format,
)
: undefined;
}