[英]Discord.js || Can bot track ban list?
There are a lot of to ban a user in a server, you can do it manually or with another bot.有很多方法可以禁止服务器中的用户,您可以手动或使用其他机器人。 I want my bot to scan a banlist
, and if someone will get banned, it will send a message "user (id) has been banned我想让我的机器人扫描一个禁止banlist
,如果有人被禁止,它会发送一条消息“user (id) has been banned
I started writing smt but now, I had no idea what can I do to check it.我开始写 smt 但现在,我不知道我能做些什么来检查它。 EDIT: It's working now, but it still need to find this user id.编辑:它现在正在工作,但它仍然需要找到这个用户 ID。
client.on('guildBanAdd', message => {
client.user.cache.find() //idk how to define it
const channel1 = client.channels.cache.find(channel => channel.id === "158751278127895");
channel1.send('12512');
})
You don't have to fetch bans because the guildBanAdd
event parses a GuildBan
object,您不必获取禁令,因为guildBanAdd
事件解析了GuildBan
object,
which als includes a User
object.其中还包括User
object。
client.on('guildBanAdd', ban => {
console.log(ban.user.username); // Username
})
message.channel
won't work because there isn't a message object. message.channel
将不起作用,因为没有消息 object。 If you want to get the executor (moderator) who performed the ban, kick etc.如果你想获得执行禁令,踢等的执行者(主持人)。
There is a good guide for this Working with Audit Logs
这个Working with Audit Logs
有一个很好的指南
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.