discord.py audit logs code example
Example: discord.py how to print audit logs
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)