I am trying to write a Discord bot, but the bot won't start and raises this error:
AttributeError: partially initialized module 'discord' has no attribute 'Client' (most likely due to a circular import)
I am trying to write a Discord bot, but the bot won't start and raises this error:
AttributeError: partially initialized module 'discord' has no attribute 'Client' (most likely due to a circular import)
If the name of your file is discord.py
try to change the name bot.py
for example
Your header (before you have any functions or method calls) should include the following items:
import discord
from discord.ext import commands
You also need to initialize your discord client. In this case, a client represents your script's connection to the discord server. If you don't initialize, none of your commands will work.
client = commands.Bot(command_prefix=".")
within the parenthesis, you can declare the prefix for your commands. Ex, .help vs !help.
Lastly, you need to connect your client to the server and run it in a continuous event loop. This should be at the end of your file.
client.run('your bot's token')