0

I am a beginner at Node.js Coding and recently coded my bot on repl.it I know that there is something wrong with this code and cannot understand where should I put '{' Can you please help me <3 Here is my code:

client.on("message", async (message) => {
 if(message.content.startsWith("!warn"))
 let victim = message.mentions.users.first()
 if(!victim) message.reply("mention someone to warn.")
 else {
 let embed = new Discord.MessageEmbed()
 .setTitle("Warnings")
 .setDescription(`${victim} got warned by ${message.author}!`)
 .setColor("GREEN")
 .setFooter(`Moderator : ${message.author.username}`)
 .setTimestamp()
 
 message.channel.send(embed)
 }
});

If there are some questions ask it I will really appreciate it if you will help! <3

Can you please send the final version of this code

3
  • 3
    After if(message.content.startsWith("!warn")) and a closing curly bracket before });. Please do make sure to learn some basic JavaScript before hopping into Discord.js Development. It is highly recommended to do so and would help you a lot while debugging your code rather than coming on a support site for such a minor issue (Sorry if I'm being a bit rude). Commented Mar 3, 2021 at 20:48
  • I corrected that in my answer to your other question. Commented Mar 3, 2021 at 21:04
  • ikr @WorthyAlpaca Commented Mar 3, 2021 at 21:13

1 Answer 1

1

You missed brackets on your opening check for message.content

and as a user suggested, try learn some basic JS before coding. I know making a discord bot you want to go straight into in but spend maybe an hour learning the very basics can solve alot of issues for you. :)

client.on("message", async (message) => {
  if (message.content.startsWith("!warn")) {
    let victim = message.mentions.users.first();
    if (!victim) return message.reply("mention someone to warn.");
    let embed = new Discord.MessageEmbed()
      .setTitle("Warnings")
      .setDescription(`${victim} got warned by ${message.author}!`)
      .setColor("GREEN")
      .setFooter(`Moderator : ${message.author.username}`)
      .setTimestamp();

    message.channel.send(embed);
  }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.