我正在尝试编码我的不和谐机器人,以防止广告其他不和谐。我在这个网站上读了很多,但找不到解决方案。我希望机器人搜索消息中的不一致邀请,如果这个链接不是由有踢权限的成员发布的,那么它应该删除邀请。
if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) { //if it contains an invite link
if(!message.member.hasPermission("KICK_MEMBERS")) {
message.delete() //delete the message
.then(message.member.send(ms.INVITELINK));
}}
发布于 2019-02-26 19:16:09
Includes只接受一个条件。如果对要捕获的每个字符串使用||
,则必须使用单独的include语句。如果您想检查多个条件,请尝试使用some()
if (message.content.includes('discord.gg/') || message.content.includes('discordapp.com/invite/')) { //if it contains an invite link
if (!message.member.hasPermission("KICK_MEMBERS")) {
message.delete() //delete the message
.then(message.member.send(ms.INVITELINK));
}
}
https://stackoverflow.com/questions/54892139
复制相似问题