Discord bots can have a Verified check mark. Is there a way to check if a Discord bot is verified using Discord.js?
I'm doing this mainly to avoid raids or nuke bots
client.on('guildMemberAdd', member => {
if (member.user.bot) {
// if is verified:
// member.roles.add("<BOT_ROLE_ID>")
// else:
// member.ban(...)
}
})
And if it can't be done using Discord.js, then is there another way using the member.user.id
property or something else?
Update: user flags may be the answer
You can check the User#flags
property as you mentioned in your update. The available flags can be found in the documentation. You'll need to check if the user has the VERIFIED_BOT
flag.
if (member.user.flags.has('VERIFIED_BOT')) {...}
Or you can import UserFlags
enums and use UserFlags.VerifiedBot
:
const { UserFlags } = require('discord.js')
// ...
if (member.user.flags.has(UserFlags.VerifiedBot)) {...}