37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/**
|
||
* 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);
|
||
} |