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?
await client.close()should be the reason why it's happening.