Deploy Commands
Deploy Commands
js';
import { config } from 'dotenv';
import * as fs from 'fs';
import * as path from 'path';
// Load each command file and add its data to the commands array
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if (process.env.GUILD_ID) {
// Register commands to a specific guild
data = await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID as string,
process.env.GUILD_ID as string
),
{ body: commands }
) as any[];
} catch (error) {
console.error('Error deploying commands:', error);
}
}