commands doesnt work
client.commands = new Collection();
const commandFiles = fs.readdirSync('/root/eye/Eye/Eye/commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(
/root/eye/Eye/Eye/commands/${file}
);
client.commands.set(command.name, command);
}
client.on('messageCreate', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('There was an error trying to execute that command!');
}
});
client.login(token);
i did this for register my commands folder and make use every .js on that exactly folder where all the commands for the server are there, but it doesnt work...why?14 Replies
have you considered using sapphire instead of your own handler? since that's what this server is for
no, im new on djs i dont even know what that is..
makes me wonder how you found this server then
eh..
by looking
š
looking where
anyway, how exactly sapphire works and whats that?
disboard
a framework for discordjs. https://sapphirejs.dev
Sapphire Framework
Home | Sapphire
Sapphire is a next-gen Discord bot framework for developers of all skill levels to make the best JavaScript/TypeScript based bots possible.
how it works
there is a guide on the site and a whole forum channel of hundreths of posts of information in #sapphire-support. Please put in some effort.
if you dont want to put effort in making your bot then by all means that's fine too but then pay someone to make it for you
the bot itself its working, i just had issues with the commands.
that's basically the same as not working considering that the core functionality lol
eh...
anyway betwen the djs guide and the sapphire guide you should be able to get a simple bot running with some commands
As for why your code wasnt working, you're not instantiating instances of what I assume are your command classes. It's honestly also a really messy way to load commands IMHO. If you look at how sapphire did it, much more thought goes into it.