Fixed Issues

This commit is contained in:
Patrick Hatsune 2024-05-10 03:39:09 -07:00
parent ff7d1ee7e6
commit d4c29573c9
2 changed files with 11 additions and 3 deletions

View file

@ -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
View file

@ -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.`);
}
}