如何解决Inviteblock Discord.js
我想创建一个阻止邀请的机器人。
这是我的代码
bot.on("message",async message => {
const regex = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|club)|discordapp\.com\/invite|discord\.com\/invite)\/.+[a-z]/gi;
if (regex.exec(message.content))
await message.channel.send(
`${message.author} **você não pode postar link de outros servidores aqui!**\n Vais levar ban se voltares a`
);
});
问题在于,这还会阻止adm邀请。
解决方法
您需要检查用户是否具有管理员角色。
bot.on("message",async message => {
const regex = /(https?:\/\/)?(www\.)?(discord\.(gg|io|me|li|club)|discordapp\.com\/invite|discord\.com\/invite)\/.+[a-z]/gi;
if (!message.member.roles.cache.has('xxxxx')) { //replace the Xs with the admin role ID
if (regex.exec(message.content)) {
await message.channel.send(
`${message.author} **você não pode postar link de outros servidores aqui!**\n Vais levar ban se voltares a`
)
}
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。