Dont work pycord

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:

  1. First, click the 3 dots in the file selector sidebar and press “show hidden files”.

  2. Pycord isnt discord.py but uses import discord namespace. So replit imports discord.py So go to .replit file and change to guessImports = false.

  3. 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

It doesn’t work either :confused:

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

Yes, sorry. Invented

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