H
H
Hacker29612021-07-04 14:08:59
Python
Hacker2961, 2021-07-04 14:08:59

How to make the bot get the id (or nickname # tag) of the person who deleted the channel through the on_guild_channel_delete event?

I'm writing a bot on discord.py, and I need that when deleting 3 channels, the bot gets the id or nick#tag of the member who does it, and writes it into a variable.
How to implement this through the on_guild_channel_delete event?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2021-07-04
@Hacker2961

In the event, you get the guild of the channel that was deleted, then call the audit_logs method of this guild with the action=discord.AuditLogAction.channel_delete argument, the method will return an asynchronous iterator, iterate over it accordingly (with the entry variable, for example) and check the entry.target value. id to match the ID of the remote channel, if it matches, then assign the entry.user value to the variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question