UNPKG

constatic

Version:

Constatic is a CLI for creating and managing modern TypeScript projects, providing an organized structure and features that streamline development.

24 lines (23 loc) 730 B
// src/helpers/discord/tokens.ts import { Result } from "#lib/result.js"; var baseURL = "https://discord.com/api/v10"; async function getDiscordBotInfo(token) { const response = await fetch(`${baseURL}/applications/@me`, { headers: { Authorization: `Bot ${token}` } }); if (response.status !== 200) { return Result.fail("The provided token is invalid"); } const data = await response.json(); const url = new URL("https://discord.com/oauth2/authorize?scope=bot+applications.commands"); url.searchParams.set("client_id", data["id"]); url.searchParams.set("permissions", "8"); return Result.ok({ id: data["id"], name: data["name"], invite: url.toString() }); } export { getDiscordBotInfo };