Error While loading prefix commands

Greetings Devs and Staff Members I am trying to make some prefix command. But I am Getting this Error I tried to look at it and to fix it but it didnt worked maybe me you guys can help me out The code:
const prefixFolders = fs.readdirSync("./src/prefix").filter((f) => f.endsWith(".js"));

for (arx of prefixFolders) {
const Cmd = require('./prefix/' + arx)
client.prefix.set(Cmd.name, Cmd)
}
client.on('messageCreate', async message => {
const prefix = "s!";

if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
const prefixcmd = client.prefix.get(command);
if (prefixcmd) {
prefixcmd.run(client, message, args)
}
});
const prefixFolders = fs.readdirSync("./src/prefix").filter((f) => f.endsWith(".js"));

for (arx of prefixFolders) {
const Cmd = require('./prefix/' + arx)
client.prefix.set(Cmd.name, Cmd)
}
client.on('messageCreate', async message => {
const prefix = "s!";

if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
const prefixcmd = client.prefix.get(command);
if (prefixcmd) {
prefixcmd.run(client, message, args)
}
});
The Error I am getting client.prefix.set(Cmd.name, Cmd) ^ TypeError: Cannot read properties of undefined (reading 'set') Thank You
19 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna16mo ago
you did not define client.prefix
†TitanLord†
†TitanLord†OP16mo ago
I did check the 6th line client.prefix.set
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Uhm what?
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Ahh okh now I get it what you want to say So i need to define client.prefix right?
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Const client.prefix = "s!"; Like that?
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Okh Let me try Nope still not working, same error
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
I just added client.prefix = "s!"; Above
client.prefix.set(Cmd.name, Cmd)
client.prefix.set(Cmd.name, Cmd)
And change const prefix to client.prefix
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
But I did give it a prefixFolders
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Okh let me try GGs The Bot is Running now thanks alot
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
†TitanLord†
†TitanLord†OP16mo ago
Sure Thnx alot once again i really appericiate it : D
Want results from more Discord servers?
Add your server