A
A
aitechb2021-05-29 14:38:08
Python
aitechb, 2021-05-29 14:38:08

How to output messages from console to discord.py file?

@bot.event
async def on_voice_state_update(member, before, after):
with open('log.txt', 'a') as f:
if before.channel is None and after.channel is not None:
f.write(f 'User {member} joined channel {after.channel}, in channel {len(after.channel.members)}')
elif before.channel is not None and after.channel is None:
f.write(f'User { member} left the channel {before.channel}, in the channel {len(before.channel.members)}')

If you go to one server, everything is recorded normally, if to others, it gives this error
File "D:\Programming\mus \Aitech.py", line 259, in on_voice_state_update
f.write(f'User {member} left channel {before.channel}, in channel {len(before.channel.members)}')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question