I am currently working on a discord bot. I was working on a command: Restart, I checked on discord to see if it work.
But I get this error
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002DDBD6FC280> Traceback (most recent call last): File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002DDBD6FC280> Traceback (most recent call last): File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon File "C:\Users\Jerry\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed RuntimeError: Event loop is closed
My Code
import discord import asyncio from discord.ext import commands client = commands.Bot(command_prefix='>') client.remove_command('help') @client.event async def on_ready(): print('Ready') @client.event async def on_connect(): Online = discord.Embed(title='Online', color=discord.Color.green()) Online.set_author(name="Bot Status") @client.event async def on_disconnect(): Offline = discord.Embed(title='Offline', color=discord.Color.red()) Offline.set_author(name="Bot Status") @client.command() async def clear(ctx, amount=9999): await ctx.send("Fetching messages...", delete_after=2.0) await asyncio.sleep(2.0) await ctx.send(content="Deleting messages...", delete_after=2.0) await asyncio.sleep(2) await ctx.channel.purge(limit=amount + 1) await ctx.send(f"Done! {amount} message(s) deleted.", delete_after=10.0) return @client.command() async def restart(ctx): await ctx.send('Restarting...', delete_after=4.0) await ctx.message.add_reaction('👋') await ctx.bot.logout() await ctx.bot.login('ODAxMTM2OTY0NjM5MTI5NjQx.YAcS8A.SAhQAjupviCH7pWokkYkdTmow1w', bot=True) await ctx.send('Done!', delete_after=5.0) client.run('Token', bot=True, reconnect=True)
So Now I put my full code in. So The problem is how to fix it? Any Idea how to fix it?
I use:
Python 3.9.1, VS Code
(I didn't mean to put in the token but I regenerated it so it fine)
https://stackoverflow.com/questions/65854145/discord-py-restart-command-error-runtimeerror-event-loop-is-closed January 23, 2021 at 07:33AM
没有评论:
发表评论