Upload file deploy.js via GUI

This commit is contained in:
2026-02-25 18:50:35 +01:00
parent ee32067472
commit 4e4c0a552a

37
deploy.js Normal file
View File

@@ -0,0 +1,37 @@
/**
* deploy.js Einmalig ausführen um Slash-Befehle bei Discord zu registrieren
* Ausführen mit: node deploy.js
*/
import "dotenv/config";
import { REST, Routes } from "discord.js";
import fs from "fs";
import configFile from "./config.json" with { type: "json" };
const config = { ...configFile, token: process.env.DISCORD_TOKEN };
if (!config.token) {
console.error("❌ DISCORD_TOKEN fehlt in der .env Datei!");
process.exit(1);
}
const commands = [];
const commandFiles = fs.readdirSync("./commands").filter((f) => f.endsWith(".js"));
for (const file of commandFiles) {
const command = (await import(`./commands/${file}`)).default;
if (command.data) {
commands.push(command.data.toJSON());
console.log(`✅ Geladen: ${command.name}`);
} else {
console.log(`⚠️ Kein Slash-Data: ${command.name}`);
}
}
const rest = new REST().setToken(config.token);
try {
console.log(`\nRegistriere ${commands.length} Slash-Befehle bei Discord...`);
await rest.put(Routes.applicationCommands(config.inviteClientID), { body: commands });
console.log("✅ Alle Slash-Befehle erfolgreich registriert!");
} catch (e) {
console.error("❌ Fehler beim Registrieren:", e);
}