[英]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.")
}
})
)}
}
}
}
output 它給了我:
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.");
}
})
})
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.