require('dotenv').config();
const fs = require('fs');
const { Client, GatewayIntentBits, PermissionsBitField } = require('discord.js');
const { Logger, Level } = require('./util/logger.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// Initialize commands
const commands = new Map();
// Builds the list of commands to set
const commandList = [];
const commandPaths = fs.readdirSync('./commands');
for(const commandPath of commandPaths) {
const command = require(`./commands/${ commandPath }`);
commandList.push({
name: command.name,
description: command.description,
options: command.options,
defaultMemberPermissions: PermissionsBitField.Default
});
commands.set(command.name, command.obj);
Logger.log(Level.INFO, `Command initialized successfully: ${ command.name }`);
}
client.on('ready', async () => {
// Set the commands for the bot
console.log(await client.application.commands.set(commandList));
Logger.log(Level.INFO, 'Commands successfully sent to Discord.');
Logger.log(Level.INFO, 'Bot started successfully!');
});
require('dotenv').config();
const fs = require('fs');
const { Client, GatewayIntentBits, PermissionsBitField } = require('discord.js');
const { Logger, Level } = require('./util/logger.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// Initialize commands
const commands = new Map();
// Builds the list of commands to set
const commandList = [];
const commandPaths = fs.readdirSync('./commands');
for(const commandPath of commandPaths) {
const command = require(`./commands/${ commandPath }`);
commandList.push({
name: command.name,
description: command.description,
options: command.options,
defaultMemberPermissions: PermissionsBitField.Default
});
commands.set(command.name, command.obj);
Logger.log(Level.INFO, `Command initialized successfully: ${ command.name }`);
}
client.on('ready', async () => {
// Set the commands for the bot
console.log(await client.application.commands.set(commandList));
Logger.log(Level.INFO, 'Commands successfully sent to Discord.');
Logger.log(Level.INFO, 'Bot started successfully!');
});