import "dotenv/config"; import { REST, Routes } from "discord.js"; import { antispamCommands } from "../src/commands.js"; const token = process.env.DISCORD_TOKEN; const appId = process.env.APPLICATION_ID?.trim(); if (!token) { console.error("Missing DISCORD_TOKEN in .env"); process.exit(1); } if (!appId) { console.error("Missing APPLICATION_ID in .env"); console.error("Find it in the Developer Portal → General Information → Application ID"); process.exit(1); } const guildId = process.env.DEPLOY_GUILD_ID?.trim(); const rest = new REST().setToken(token); try { if (guildId) { await rest.put(Routes.applicationGuildCommands(appId, guildId), { body: antispamCommands, }); console.log(`Deployed ${antispamCommands.length} command(s) to guild ${guildId} (instant).`); } else { await rest.put(Routes.applicationCommands(appId), { body: antispamCommands }); console.log(`Deployed ${antispamCommands.length} global command(s).`); console.log("Global commands can take up to an hour to appear in Discord."); console.log("For instant commands, set DEPLOY_GUILD_ID in .env and run again."); } } catch (error) { console.error("Deploy failed:", error.rawBody ?? error.message); process.exit(1); }