[英]Discord.js “Unexpected identifier” when trying to DM a user
I'm making a custom bot for a server, and I made a banned word list.我正在为服务器制作自定义机器人,并制作了禁止词列表。 I'm trying to make it so it mutes them until they agree to the rules again.我正在努力让它静音,直到他们再次同意规则。 This is the 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.")
}
})
)}
}
}
}
The output it's giving me: 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
I'm not sure how to fix this, and I'm new to JavaScript.我不确定如何解决这个问题,而且我是 JavaScript 的新手。 Could someone please help?有人可以帮忙吗?
Your syntax is all over the place.你的语法到处都是。 I recommend either installing a linter, using an IDE that has syntax highlighting or both.我建议安装 linter,使用具有语法突出显示的 IDE 或两者兼而有之。 That'll let you know if you're missing brackets and so on.这会让你知道你是否缺少括号等等。 I can recommend Visual Studio Code for the IDE.我可以为 IDE 推荐Visual Studio Code 。
I corrected the syntax but please make sure to do what I recommended above.我更正了语法,但请确保按照我上面的建议进行操作。
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.