Files
discordeno/src/helpers/guilds/guild_splash_url.ts
T
2021-10-21 19:38:09 +02:00

29 lines
834 B
TypeScript

import type { DiscordImageFormat } from "../../types/misc/image_format.ts";
import type { DiscordImageSize } from "../../types/misc/image_size.ts";
import type { Bot } from "../../bot.ts";
/** The full URL of the splash from Discords CDN. Undefined if no splash is set. */
export function guildSplashURL(
bot: Bot,
id: bigint,
options: {
splash?: string | bigint;
size?: DiscordImageSize;
format?: DiscordImageFormat;
animated?: boolean;
}
) {
return options.splash
? bot.utils.formatImageURL(
bot.constants.endpoints.GUILD_SPLASH(
id,
typeof options.splash === "string"
? options.splash
: bot.utils.iconBigintToHash(options.splash, options.animated ?? true)
),
options.size || 128,
options.format
)
: undefined;
}