Fixed Issues
This commit is contained in:
parent
ff7d1ee7e6
commit
d4c29573c9
|
@ -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!');
|
||||
}
|
10
main.js
10
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.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue