diff options
| author | Fuwn <[email protected]> | 2025-09-24 18:14:30 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-24 18:14:30 -0700 |
| commit | 2d987046d094cf5eb784c8d79d678bd3efa5eaf9 (patch) | |
| tree | dd37d395961d9a68e3e1293a89fb46992aab88d1 /src/register.ts | |
| parent | style: Lint (diff) | |
| download | umabotdiscord-2d987046d094cf5eb784c8d79d678bd3efa5eaf9.tar.xz umabotdiscord-2d987046d094cf5eb784c8d79d678bd3efa5eaf9.zip | |
refactor: Move interactions client to packages directory
Diffstat (limited to 'src/register.ts')
| -rw-r--r-- | src/register.ts | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/register.ts b/src/register.ts deleted file mode 100644 index a23c9c8..0000000 --- a/src/register.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { - HOT_COMMAND, - NSFW_COMMAND, - ROLEPLAY_COMMAND, - TOP_COMMAND, - COMPLAIN_COMMAND, - APPEAL_COMMAND, - COLOURS_COMMAND, - ROLEPLAY_SERIOUS_COMMAND, - type DiscordCommand, -} from "./discord/commands.ts"; -import dotenv from "dotenv"; -import process from "node:process"; - -dotenv.config({ path: ".dev.vars" }); - -const token = process.env.DISCORD_TOKEN; -const applicationID = process.env.DISCORD_APPLICATION_ID; - -if (!token) - throw new Error("The DISCORD_TOKEN environment variable is required."); - -if (!applicationID) - throw new Error( - "The DISCORD_APPLICATION_ID environment variable is required.", - ); - -const url = `https://discord.com/api/v10/applications/${applicationID}/commands`; - -const commands: DiscordCommand[] = [ - HOT_COMMAND, - ROLEPLAY_COMMAND, - NSFW_COMMAND, - TOP_COMMAND, - COMPLAIN_COMMAND, - APPEAL_COMMAND, - COLOURS_COMMAND, - ROLEPLAY_SERIOUS_COMMAND, -]; - -const response = await fetch(url, { - headers: { - "Content-Type": "application/json", - Authorization: `Bot ${token}`, - }, - method: "PUT", - body: JSON.stringify(commands), -}); - -if (response.ok) { - console.log("Registered all commands"); - - const data = await response.json(); - - console.log(JSON.stringify(data, null, 2)); -} else { - console.error("Error registering commands"); - - let errorText = `Error registering commands \n ${response.url}: ${response.status} ${response.statusText}`; - - try { - const error = await response.text(); - - if (error) errorText = `${errorText} \n\n ${error}`; - } catch (error) { - console.error("Error reading body from request:", error); - } - - console.error(errorText); -} |