V
V
Vlad Morkovkin2021-08-30 17:27:58
Node.js
Vlad Morkovkin, 2021-08-30 17:27:58

How to find out who invited the bot to the discord.js server?

How to calculate by audit who invited a new bot to the server and ban him?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlmondPark33609, 2021-08-30
@AlmondPark33609

client.on('guildMemberAdd', async (user) => {
   let fetchedLogs = await user.guild.fetchAuditLogs({
        limit: 1,
        type: 'BOT_ADD'
    })
    
    let deletionLog = fetchedLogs.entries.first()
    if (!deletionLog) return
    
    let { executor } = deletionLog
    
    user.guild.member(executor).ban().catch(err => {
           return console.log('Не могу забанить пользователя')
    })
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question