diff --git a/commands/ping.js b/commands/test/ping.js similarity index 60% rename from commands/ping.js rename to commands/test/ping.js index 7d5f6c2..3b8965a 100644 --- a/commands/ping.js +++ b/commands/test/ping.js @@ -1,7 +1,9 @@ +const { SlashCommandBuilder } = require('discord.js'); + module.exports = { data: new SlashCommandBuilder() .setName('ping') - .setDescription('Replies with pong.') + .setDescription('Replies with pong.'), async execute(interaction) { await interaction.reply('Pong!'); } diff --git a/main.js b/main.js index d775f1b..eb1ba29 100644 --- a/main.js +++ b/main.js @@ -3,7 +3,7 @@ const { token } = require('./config.json'); const fs = require('node:fs'); const path = require('node:path'); -const informationStatus = "[STATUS]: "; +const informationStatus = "[INFO]: "; const warningStatus = "[WARNING]: "; const errorStatus = "[ERROR]: "; @@ -11,20 +11,26 @@ const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.commands = new Collection(); -const foldersPath = path.join(__dirname, './commands/'); +const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); + + console.log(informationStatus + `'${folder}' folder has been added! All js files will be called.`); + for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); + if('data' in command && 'execute' in command) { client.commands.set(command.data.name, command) } else { console.log(warningStatus + `This file at ${filePath} does not contain data or execute properties, will be ignored.`); } + + console.log(informationStatus + `'${file}' has been added into command pool.`); } }