UNPKG

aio-discord-bot

Version:

All-in-one Discord bot with moderation, economy, games, utilities, and SerpAPI search.

30 lines (26 loc) 968 B
require('dotenv').config(); const fs = require('fs'); const path = require('path'); const { REST, Routes } = require('discord.js'); const commands = []; const commandsPath = path.join(__dirname, 'commands'); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); for (const file of commandFiles) { const command = require(path.join(commandsPath, file)); if ('data' in command && 'execute' in command) { commands.push(command.data.toJSON()); } } const rest = new REST({ version: '10' }).setToken(process.env.TOKEN); (async () => { try { console.log(`🔄 Đang đăng ký ${commands.length} lệnh slash...`); await rest.put( Routes.applicationCommands(process.env.CLIENT_ID), { body: commands } ); console.log('✅ Slash commands đã được đăng ký!'); } catch (error) { console.error(error); } })();