Discord.js "Unexpected identifier" 尝试向用户发送私信时

Discord.js "Unexpected identifier" when trying to DM a user

我正在为服务器制作一个自定义机器人,并且制作了一个禁用词列表。我正在努力让它静音,直到他们再次同意规则。这是代码:

if(msg.split(" ").includes("asdf")){
  if(msg.deletable){
      msg.delete()
  if(!msg.member.roles.cache.get("777167323232469002")
     msg.member.send("You have been muted for saying a banned word. Please visit the rules and read all of our rules. React with a checkmark if you agree to all of the rules.")
          .then(sent =>{
            sent.react("✔️")
            let muted = msg.guild.roles.cache.get("759883236322574376")
            msg.member.roles.add(muted)
            sent.awaitReactions((reaction,user) => (reaction.emoji.name == "✔️"),
                        {max: 1}.then(collected => {
                        if(collected.first().emoji.name=="✔️"){
                            msg.member.roles.remove(muted)
                            msg.author.send("Thank you for agreeing to follow our rules. Please keep in mind breaking any rules will result in moderator punishment.")
                        }
            })

        )}
        
  }
  }
}

它给我的输出:

msg.member.send("You have been muted for saying a banned word. Please visit the rules and read all of our rules. React with a checkmark if you agree to all of the rules.")
^^^

SyntaxError: Unexpected identifier

我不确定如何解决这个问题,而且我是 JavaScript 的新手。有人可以帮忙吗?

你的语法到处都是。我建议安装 linter,使用具有语法高亮显示的 IDE 或两者。这会让您知道您是否缺少括号等。我可以为 IDE 推荐 Visual Studio Code

我更正了语法,但请务必按​​照我上面的建议进行操作。

if (msg.split(" ").includes("asdf")) {
    if (msg.deletable) msg.delete();
    if (!msg.member.roles.cache.get("777167323232469002")) {
        msg.member.send("You have been muted for saying a banned word. Please visit the rules and read all of our rules. React with a checkmark if you agree to all of the rules.")
            .then(sent => {
                sent.react("✔️");
                let muted = msg.guild.roles.cache.get("759883236322574376");
                msg.member.roles.add(muted);
                sent.awaitReactions((reaction, user) => (reaction.emoji.name == "✔️"), { max: 1 })
                    .then(collected => {
                        if (collected.first().emoji.name == "✔️") {
                            msg.member.roles.remove(muted);
                            msg.author.send("Thank you for agreeing to follow our rules. Please keep in mind breaking any rules will result in moderator punishment.");
                        }
                    })
            })
    }
}