mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
16 lines
627 B
TypeScript
16 lines
627 B
TypeScript
import { cacheHandlers } from "../../cache.ts";
|
|
import { rest } from "../../rest/rest.ts";
|
|
import { Errors } from "../../types/misc/errors.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
|
|
/** Returns the widget for the guild. */
|
|
export async function getWidget(guildId: string, options?: { 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 rest.runMethod("get", `${endpoints.GUILD_WIDGET(guildId)}.json`);
|
|
}
|