Reputation: 122
I tried a few different codes but they all seem to be giving me the same error.
import discord
client = discord.Client()
client.run("TheBotTokenzzzInQuotes")
And it's giving me this error
File "<ipython-input-1-1f31c2ad1160>", line 1, in <module>
runfile('C:/Users/Lenovo/Desktop/bot.py', wdir='C:/Users/Lenovo/Desktop')
File "C:\Users\Lenovo\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\Lenovo\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Lenovo/Desktop/bot.py", line 4, in <module>
client.run("token")
File "C:\Users\Lenovo\Anaconda3\lib\site-packages\discord\client.py", line 637, in run
_cleanup_loop(loop)
File "C:\Users\Lenovo\Anaconda3\lib\site-packages\discord\client.py", line 97, in _cleanup_loop
loop.close()
File "C:\Users\Lenovo\Anaconda3\lib\asyncio\selector_events.py", line 83, in close
raise RuntimeError("Cannot close a running event loop")
RuntimeError: Cannot close a running event loop
Upvotes: 1
Views: 1800
Reputation: 131
I have my own discord bot that I run, and the client variable for mine doesn't look anything like that if I'm being honest.
If you are not using "Discord.py Rewrite", that could be a possible reason for a failure.
Another possible reason(although very unlikely) is that you do not have aiohttp installed(which is the dependency asyncio needs for Discord.py Rewrite), you can install it by using the following command:
pip install aiohttp
If you would like an example bot to look at, I have listed one below that is directly from the developer of discord.py Rewrite(the version that is currently supported for python).
https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py
If you were wondering what the beginning of my code looked like, I have it below this:
import discord
from discord.ext import commands
from discord.utils import get
client = commands.Bot(command_prefix = '>')
Upvotes: 4