mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
d60c3242af
swc_bundler: - Fix cycle detection for complex circular imports. (denoland/deno#10752) swc_ecma_transforms_typescript: - Allow using large values for an enum variant.
19 lines
844 B
TypeScript
19 lines
844 B
TypeScript
// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/helpers/guilds/get_widget_image_url.ts
|
|
|
|
|
|
import { cacheHandlers } from "../../cache.ts";
|
|
import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts";
|
|
import { Errors } from "../../types/discordeno/errors.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
|
|
/** Returns the widget image URL for the guild. */
|
|
export async function getWidgetImageURL(guildId: bigint, options?: GetGuildWidgetImageQuery & { force?: boolean }) {
|
|
if (!options?.force) {
|
|
const guild = await cacheHandlers.get("guilds", guildId);
|
|
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
|
if (!guild.widgetEnabled) throw new Error(Errors.GUILD_WIDGET_NOT_ENABLED);
|
|
}
|
|
|
|
return `${endpoints.GUILD_WIDGET(guildId)}.png?style=${options?.style ?? "shield"}`;
|
|
}
|