const { SlashCommandBuilder } = require('discord.js'); const fs = require('fs'); const path = require('path'); const { clientId } = require('../config.json'); // Correct path for config.json // The function to deploy commands to Discord async function deployCommands(client) { const commands = []; const commandFolders = ['commands', 'moderation']; // Read commands from both the 'commands' and 'moderation' folders for (const folder of commandFolders) { const folderPath = path.join(__dirname, folder); const files = fs.readdirSync(folderPath).filter(file => file.endsWith('.js')); for (const file of files) { const command = require(path.join(folderPath, file)); commands.push(command.data.toJSON()); } } try { // Register commands globally await client.application.commands.set(commands); console.log('Successfully registered application commands globally.'); } catch (error) { console.error('Error deploying commands:', error); } } module.exports = { deployCommands };