Discord.py Errors

Viewed 270

Today I wanted to try to create a discord bot with python. The problem i have is, that there is always an error message when I start the program:

Traceback (most recent call last):
  File "D:\...\Discord Bot\PythonGPU_Bot\bot.py", line 1, in <module>
    import discord
  File "C:\Users\...\Python\Python39\lib\discord\__init__.py", line 4, in <module>
    client = discord.Client()
AttributeError: partially initialized module 'discord' has no attribute 'Client' (most likely due to a circular import)

Thats the Error message I always get. This is my script:

import discord
import asyncio

client = discord.Client()


@client.event
async def on_ready():
    print('Logged in as {}'.format(client.user.name))
    client.loop.create_task(status_task())


async def status_task():
    while True:
        await client.change_presence(activity=discord.Game('Hello <:'))
        await asyncio.sleep(1)
        await client.change_presence(activity=discord.Game('Hello c:'))
        await asyncio.sleep(1)


@client.event
async def on_message(message):
    if message.auther.bot:
        return
    if '.status' in message.content:
        await message.channel.send('SSSS')


client.run('ID')

I hope someone can help me out.

1 Answers

The name of your file is discord.py, rename the file

rename it to bot.py or main.py or anything you like and your issue will be fixed

Why does it happen?

Since your file name is discord.py, it is actually importing that file and not the actual discord.py module you installed with pip.

Related