Fixed Issues
This commit is contained in:
parent
ff7d1ee7e6
commit
d4c29573c9
|
@ -1,7 +1,9 @@
|
||||||
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('ping')
|
.setName('ping')
|
||||||
.setDescription('Replies with pong.')
|
.setDescription('Replies with pong.'),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
await interaction.reply('Pong!');
|
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 fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const informationStatus = "[STATUS]: ";
|
const informationStatus = "[INFO]: ";
|
||||||
const warningStatus = "[WARNING]: ";
|
const warningStatus = "[WARNING]: ";
|
||||||
const errorStatus = "[ERROR]: ";
|
const errorStatus = "[ERROR]: ";
|
||||||
|
|
||||||
|
@ -11,20 +11,26 @@ const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||||
|
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
|
||||||
const foldersPath = path.join(__dirname, './commands/');
|
const foldersPath = path.join(__dirname, 'commands');
|
||||||
const commandFolders = fs.readdirSync(foldersPath);
|
const commandFolders = fs.readdirSync(foldersPath);
|
||||||
|
|
||||||
for (const folder of commandFolders) {
|
for (const folder of commandFolders) {
|
||||||
const commandsPath = path.join(foldersPath, folder);
|
const commandsPath = path.join(foldersPath, folder);
|
||||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
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) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
const command = require(filePath);
|
const command = require(filePath);
|
||||||
|
|
||||||
if('data' in command && 'execute' in command) {
|
if('data' in command && 'execute' in command) {
|
||||||
client.commands.set(command.data.name, command)
|
client.commands.set(command.data.name, command)
|
||||||
} else {
|
} else {
|
||||||
console.log(warningStatus + `This file at ${filePath} does not contain data or execute properties, will be ignored.`);
|
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