joel joel joel

This commit is contained in:
2024-05-02 13:22:15 +02:00
commit 73200479bd
20 changed files with 684 additions and 0 deletions

24
commands/register.ts Normal file
View File

@@ -0,0 +1,24 @@
import { REST, Routes } from "discord.js";
import type { Command } from "./command";
export const registerCommands = async (
commands: Command[],
clientId: string
) => {
const DISCORD_TOKEN = Bun.env.DISCORD_TOKEN;
if (!DISCORD_TOKEN) {
console.error("No DISCORD_TOKEN found in environment variables.");
return;
}
const rest = new REST({ version: "10" }).setToken(DISCORD_TOKEN);
try {
await rest.put(Routes.applicationCommands(clientId), {
body: commands.map((command) => command.data.toJSON()),
});
console.log(`Registered ${commands.length} commands.`);
} catch (error) {
console.error("Error while registering commands:", error);
}
};