My help command doesn't work

bot.on("message", (message) => {
    if (message.author.bot) return;
    if (message.channel.type === "dm") return;.

   if(message.content == `<@${bot.user.id}>` || message.content == `<@!${bot.user.id}>`) return message.reply("Hey My Prefix Is !")

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if (!message.content.startsWith(prefix)) return;

    let commandfile = bot.commands.get(cmd.slice(prefix.length));
    if (commandfile) commandfile.run(bot, message, args);
 });

Try this


In logs I don’t have error
Look i edit new commands on post

So actually you are doing message.channel.cache.send() but needs to be message.channel.send()

3 Likes

Not work i try

This is going to sound really stupid, but is prefix actually defined? You may have defined it in anothet function, but I don’t think it’s global, because the lines with errors both have prefix in them - can you try replacing them with your prefix e.g. '!':

bot.on("message", (message) => {
    if (message.author.bot) return;
    if (message.channel.type === "dm") return;.

   if(message.content == `<@${bot.user.id}>` || message.content == `<@!${bot.user.id}>`) return message.reply("Hey My Prefix Is !")

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if (!message.content.startsWith("!")) return;

    let commandfile = bot.commands.get(cmd.slice("!".length));
    if (commandfile) commandfile.run(bot, message, args);
 });

Its work but now all this no work
No errors

bot.on("message", (message) => {
    if (message.author.bot) return;
    if (message.channel.type === "dm") return;
  
  let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
  if(!prefixes[message.guild.id]){
    prefixes[message.guild.id] = {
      prefixes: botconfig.prefix
    };
  }

  

  let prefix = prefixes[message.guild.id].prefixes;
  if(!message.content.startsWith(prefix)) return;
  if(cooldown.has(message.author.id)){
    message.delete();
    return message.reply("You have to wait 5 seconds between commands.")
  }
  if(!message.member.hasPermission("ADMINISTRATOR")){
    cooldown.add(message.author.id);
  }

   if(message.content == `<@${bot.user.id}>` || message.content == `<@!${bot.user.id}>`) return message.reply("Hey My Prefix Is !")

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if (!message.content.startsWith("!")) return;

    let commandfile = bot.commands.get(cmd.slice("!".length));
    if (commandfile) commandfile.run(bot, message, args);
  
 }); 

Hey, can you please wrap your code in a code block? It makes it a bit easier to diagnose your code because Discourse does not render markdown in code block.

They look like this

Example: https://p2pbin.glitch.me/?id=QmcZami3oAmrTkNAuLiYipwDrMnQpZg41HeNE51C77RVVs

Ok i edit ty for say me

1 Like

Help me?
Please