My help command doesn't work

I new in v12
And why this command not work me on v12?

bot.on(“message”, async message => {

if(message.author.bot) return;
if(message.channel.type === “dm”) return;

if (message == <@${bot.user.id}> || message == <@!${bot.user.id}>) {
message.channel.cache.send(“Hey My Prefix Is !”)
}

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);
}

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

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

setTimeout(() => {
cooldown.delete(message.author.id)
}, cdseconds * 1000)
});

Hello, are you getting any errors?

No I don’t have

formatted version:

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

    if (message == < @$ {
            bot.user.id
        } > || message == < @!$ {
            bot.user.id
        } > ) {
        message.channel.send(“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);
});

I try your code and I have error

I’m just formatting the code, so others can view it and build off it.

Ok i edit code
I wait :smile:

I want to learn v12 now
All my bot my v12
And this last commands don’t works

I don’t see why this was flagged.

2 Likes

I try to label my bots and command its not work

Can you show us some logs, maybe? :smiley:

I try to label my bot and command not work

Try using the regular " character

The one in phone keyboards use a different type which js doesn’t not recognize

What do you mean I did not understand you in what you said

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

    if (message == < @$ {
            bot.user.id
        } > || message == < @!$ {
            bot.user.id
        } > ) {
        message.channel.send("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);
});

I took @code-alt’s formatted version and changed it to the main quotes.

1 Like

I have error your code

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

    if (message <= @$ {
            bot.user.id
        } > || message <= @!$ {
            bot.user.id
        } > ) {
        message.channel.send("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

Don’t work

Can i ask what the @$ is for?

@bot
And bot say my prefix is

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