dischord .js如何检查服务器上是否有用户从id_blacklist数组的id?



我正在做一些安全的东西,我需要黑名单的用户破坏我的服务器和离开,所以我不能禁止他们。

Here is code:
var id_blacklist = ["some","user","id-s"]
})
setInterval(function(){ 
checkUsers() 
}, 5000);

function checkUsers(){
//here check if there is a user id that is on blacklist
}

编辑:我的意思是每5秒检查一次用户。因为memberGuildAdd在我的bot中无缘无故不起作用

不使用setInterval,而是使用client# guildMemberAdd来只在有人加入时运行

bannedID = ['123', '456']
client.on('guildguildMemberAdd', (member) => {
// probably check guild with member.guild
// if their ID is in the list
if (bannedID.has(member.id) {
// they were banned, so do something
}
});

最新更新