Reputation: 23
I have the following error when program ends.
Error:
RuntimeError: Event loop is closed
Code:
client = discord.Client()
@client.event
async def on_ready():
amount2 = 0
for guild in client.guilds:
for member in guild.members:
members.insert(amount2, member) # or do whatever you wish with the member detail
amount2 = amount2 + 1
await client.close()
client.run(TOKEN)
How can I resolve it?
Upvotes: 2
Views: 912
Reputation: 58
I got the same error and noticed it doesn't happen while debugging, so I added a sleep(1) after the close call:
await client.close()
time.sleep(1)
Upvotes: 2