Files
SpigotWatch/deploy.js
2026-02-25 18:50:35 +01:00

37 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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);
}