discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.32k stars 3.97k forks source link

AuditLogs (type:24) : Wrong executor for mute/deaf #4635

Closed Lucasgood5 closed 4 years ago

Lucasgood5 commented 4 years ago

Hi, i'm having trouble when trying to find who just muted or deaf me (or anyone). Using the auditLogs : executor is wrong, when someone else mute/deaf me, the executor is still me(=target)

client.on('voiceStateUpdate', async (ov, nv) => {
    if (nv.member.id == "158312532522565633")
        if (nv.serverMute || nv.serverDeaf)
            if (!ov.serverMute && !ov.serverDeaf) {
                let guild = nv.guild
                let log = await guild.fetchAuditLogs({ limit: 1, user: nv.member.user, type: 24 })
                log = log.entries.first()
                console.log(log) // .executor is wrong ( returning the same of target )
            }
})
almostSouji commented 4 years ago

That's a misconception on your end. The "user" query in audit logs is the executing user, so of course if you query for yourself (the person being muted) you will receive a log for when you muted someone. (If you are confused by this look at what the user interface allows you to search for. You can not query for targets, this uses the exact same endpoint)

As another side note: Audit logs are not guaranteed to have arrived when the websocket event (and by extension the discord.js client event) emits.

Lucasgood5 commented 4 years ago

Nop this is not that, if anyone mute anyone else , executor is still the target i tested it with 3 friend. executor still is same as target.

PS : and on discord app, server logs show good, someone muted someone else.

Lucasgood5 commented 4 years ago

Okay nevermind, i gatcha my error.