1async def save_audit_logs(guild):
2 with open(f'audit_logs_{guild.name}', 'w+') as f:
3 async for entry in guild.audit_logs(limit=100):
4 f.write('{0.user} did {0.action} to {0.target}'.format(entry))
5
6@client.event
7async def on_message(message):
8 if message.content.startswith('audit'):
9 await save_audit_logs(message.channel.guild)