Get the channel deletor discord py

Abolfazl Rabiei

I wrote the code that works properly but I also want to get the channel deletor to perform that person operation

my code discord py :

@bot.event
async def on_guild_channel_delete(channel):
    await channel.clone(name=channel.name,reason="clone channel")

how to get user channel deleted

enjoy ! thanks

Łukasz Kwieciński

It is possible, but you're gonna have to fetch the info from the audit logs

If you want the user that DELETED the newly deleted channel

@bot.event
async def on_guild_channel_delete(channel):
    async for entry in channel.guild.audit_logs(limit=1, action=discord.AuditLogAction.channel_delete):
        print(f"User: {entry.user} deleted channel {channel}")
        # Banning the user
        await channel.guild.ban(entry.user)

Reference:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

discord.py How to get logs from a DM channel

From Dev

How to get rid of Text Channels from channel list in Discord.py

From Java

message.channel.id Discord PY

From Java

Cloning and Deleting a channel: Discord.py

From Dev

Discord.py bot leaving voice channel

From Dev

Discord py get input

From Dev

I want to make a command that deletes a channel discord.py

From Dev

How to create a category and a channel using python discord.py

From Dev

Discord.py change channel title but keep id

From Dev

Discord py how can I join a voice channel

From Dev

Discord Py 'NoneType' object has no attribute 'voice_channel'

From Dev

How to check if a channel has any messages? Discord.py

From Dev

Discord Py bot spams channel when looping through a dictionary

From Dev

How do I move a user to a specific channel on discord using the discord.py API

From Dev

Get last message from text channel with discord.js

From Java

discord.py (rewrite) How do I make a command to a specific channel

From Java

discord.py (rewrite) How can I narrow a commands use ability to a single channel?

From Dev

how can i make my discord.py bot send a message i choose to a channel i choose?

From Dev

How to access which voice channel user writing command is in discord.py?

From Dev

How do I use discord.py to send a greeting message in the System Messages Channel

From Dev

Discord.py bot.send_message() does not go to the channel it has been called at

From Dev

discord channel link in message

From Dev

discord channel link in message

From Java

How to get the longest user name? (discord.py)

From Java

How to get Member object from user id discord.py

From Dev

discord.py - Cannot get average colour of a user's avatar

From Dev

Get permissions with @client.event on_message (Discord.py)

From Dev

How to get the prefix of a server when the bot is mentioned? discord.py

From Dev

discord.py | how to get list user banned name and id

Related Related

  1. 1

    discord.py How to get logs from a DM channel

  2. 2

    How to get rid of Text Channels from channel list in Discord.py

  3. 3

    message.channel.id Discord PY

  4. 4

    Cloning and Deleting a channel: Discord.py

  5. 5

    Discord.py bot leaving voice channel

  6. 6

    Discord py get input

  7. 7

    I want to make a command that deletes a channel discord.py

  8. 8

    How to create a category and a channel using python discord.py

  9. 9

    Discord.py change channel title but keep id

  10. 10

    Discord py how can I join a voice channel

  11. 11

    Discord Py 'NoneType' object has no attribute 'voice_channel'

  12. 12

    How to check if a channel has any messages? Discord.py

  13. 13

    Discord Py bot spams channel when looping through a dictionary

  14. 14

    How do I move a user to a specific channel on discord using the discord.py API

  15. 15

    Get last message from text channel with discord.js

  16. 16

    discord.py (rewrite) How do I make a command to a specific channel

  17. 17

    discord.py (rewrite) How can I narrow a commands use ability to a single channel?

  18. 18

    how can i make my discord.py bot send a message i choose to a channel i choose?

  19. 19

    How to access which voice channel user writing command is in discord.py?

  20. 20

    How do I use discord.py to send a greeting message in the System Messages Channel

  21. 21

    Discord.py bot.send_message() does not go to the channel it has been called at

  22. 22

    discord channel link in message

  23. 23

    discord channel link in message

  24. 24

    How to get the longest user name? (discord.py)

  25. 25

    How to get Member object from user id discord.py

  26. 26

    discord.py - Cannot get average colour of a user's avatar

  27. 27

    Get permissions with @client.event on_message (Discord.py)

  28. 28

    How to get the prefix of a server when the bot is mentioned? discord.py

  29. 29

    discord.py | how to get list user banned name and id

HotTag

Archive