📜  discord.py 如何打印审计日志 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:11.970000             🧑  作者: Mango

代码示例1
async def save_audit_logs(guild):
     with open(f'audit_logs_{guild.name}', 'w+') as f:
          async for entry in guild.audit_logs(limit=100):
               f.write('{0.user} did {0.action} to {0.target}'.format(entry))

@client.event
async def on_message(message):
     if message.content.startswith('audit'):
         await save_audit_logs(message.channel.guild)