discord.py 如何查看频道何时被删除?

How to see when a channel is deleted with discord.py?

我正在尝试制作一个可以看到频道何时被删除的机器人,但我一直收到此错误

Ignoring exception in on_guild_channel_delete
Traceback (most recent call last):
  File "/home/runner/securityBotV2/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
TypeError: on_guild_channel_delete() takes 1 positional argument but 2 were given

这是我的代码

async def on_guild_channel_delete(channel):
      entry = await channel.guild.audit_logs(action=discord.AuditLogAction.channel_delete, limit=1).get()
      user = client.get_user(int(ID))
      await user.send(
        "User {} deleted channel {} at time {}".format(entry.user.name, channel.name, entry.created_at)
      )

我在我的代码中找不到任何错误,我做错了什么?

您忘记了任何命令中的第一个参数都是上下文。 所以不要用你的代码做

async def on_guild_channel_delete(ctx, channel):
      entry = await channel.guild.audit_logs(action=discord.AuditLogAction.channel_delete, limit=1).get()
      user = client.get_user(int(ID))
      await user.send(
        "User {} deleted channel {} at time {}".format(entry.user.name, channel.name, entry.created_at)
      )