bruhbruh
bruhbruh

Reputation: 33

Discord.js Error: Mute Embed Message Code

I am discord.js beginner on repl.it

code:

client.on("message", async (message) => {
 if(message.content.startsWith("!mute")) {
 if(message.member.hasPermission("ADMINISTRATOR")) {
 let member = message.mentions.members.first()
 if(!member) message.channel.send("mention someone to mute!")
 else {
 member.roles.add("813876389475385394")
 let embed = new Discord.MessageEmbed()
 .setTitle("Kicks")
 .setDescription(`${victim} got kicked by ${message.author}!`)
 .setColor("GREEN")
 .setFooter(`Moderator : ${message.author.username}`)
 .setTimestamp()
 
 message.channel.send(embed)
 }
});

But console sends error like that:

/home/runner/lifeafterbot/index.js:71
});
 ^

SyntaxError: Unexpected token ')'
Hint: hit control+c anytime to enter REPL.

Can anyone see where I am wrong?

Upvotes: 0

Views: 94

Answers (1)

Joe Moore
Joe Moore

Reputation: 2023

I have sorted out your formatting, it should work now

client.on("message", async (message) => {
    if(message.content.startsWith("!mute")) {
      if(message.member.hasPermission("ADMINISTRATOR")) {
        let member = message.mentions.members.first()
          if(!member) {
            message.channel.send("mention someone to mute!")
          } else {
            member.roles.add("813876389475385394")
            let embed = new Discord.MessageEmbed()
              .setTitle("Kicks")
              .setDescription(`${victim} got kicked by ${message.author}!`)
              .setColor("GREEN")
              .setFooter(`Moderator : ${message.author.username}`)
              .setTimestamp()
            message.channel.send(embed)
          };
       };
    };
});

Make sure you indent your code correctly, and perhaps download an IDE like Visual Studio Code, which helps immensely with formatting.

You should also keep nested statements to a minimum, you can cut them shorter like this:

if(!message.member.hasPermission("ADMINISTRATOR")) return; //the '!' operator means the returned value is false if the user does not have admin the command is cancelled

Upvotes: 1

Related Questions