from server import keep_alive
import discord
import os
bot = discord.Bot()
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
keep_alive()
bot.run(os.environ['DISCORD_TOKEN'])
Traceback (most recent call last):
File "main.py", line 6, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
Itâs discord.Client()
not discord.Bot()
. If this worked, please mark this as solution to avoid confusion.
Thanks, but it doesnât work either
Could you please give me the error?
Traceback (most recent call last):
File âmain.pyâ, line 6, in
bot = discord.Bot()
AttributeError: module âdiscordâ has no attribute âBotâ
Use this code:
from server import keep_alive
import discord
import os
bot = discord.Client()
@bot.event
async def on_ready():
print(f`{bot.user} has connected to Discord!`)
keep_alive()
bot.run(os.environ[âDISCORD_TOKENâ])
Traceback (most recent call last):
File âmain.pyâ, line 6, in
bot = discord.Client()
AttributeError: module âdiscordâ has no attribute âClientâ
Follow this step by step:
-
First, click the 3 dots in the file selector sidebar and press âshow hidden filesâ.
-
Pycord isnt discord.py but uses import discord namespace. So replit imports discord.py So go to .replit
file and change to guessImports = false
.
-
Go to shell then pip uninstall discord
and then pip install pycord
because of this, from now on auto package installation wont work. But its easy to just install from shell
Invite @QuantumCodes to the repl. It will work.
Message me when u invited
It seems you followed me instead of inviting me to the repl
Still didnt get itâŚ
Go to the repl editor and click the invite button:
If you have discord
(.py
) installed, remove it and run in shell:
sed -i '/ignoredPackages/s/\]/, "discord"]/' .replit
1 Like