†TitanLord†
†TitanLord†
DIAdiscord.js - Imagine an app
Created by †TitanLord† on 9/14/2023 in #djs-questions
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
35 replies