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
push0
push0OPā€¢10mo ago
No description
Favna
Favnaā€¢10mo ago
have you considered using sapphire instead of your own handler? since that's what this server is for
push0
push0OPā€¢10mo ago
no, im new on djs i dont even know what that is..
Favna
Favnaā€¢10mo ago
makes me wonder how you found this server then
push0
push0OPā€¢10mo ago
eh.. by looking šŸ˜‚
Favna
Favnaā€¢10mo ago
looking where
push0
push0OPā€¢10mo ago
anyway, how exactly sapphire works and whats that? disboard
Favna
Favnaā€¢10mo ago
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.
push0
push0OPā€¢10mo ago
how it works
Favna
Favnaā€¢10mo ago
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
push0
push0OPā€¢10mo ago
the bot itself its working, i just had issues with the commands.
Favna
Favnaā€¢10mo ago
that's basically the same as not working considering that the core functionality lol
push0
push0OPā€¢10mo ago
eh...
Favna
Favnaā€¢10mo ago
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.
Want results from more Discord servers?
Add your server