今天我想尝试用python创建一个不和谐的机器人。我的问题是,当我启动程序时,总是有一条错误消息:
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)
这是我经常收到的错误信息。这是我的脚本:
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')
我希望有人能帮帮我。
发布于 2021-06-01 05:06:14
您的文件名为discord.py
,请重命名该文件
将其重命名为bot.py
或main.py
或任何您喜欢的名称,您的问题就会得到解决
为什么会发生这种情况?
由于您的文件名为discord.py
,因此它实际上导入的是该文件,而不是您使用pip安装的实际discord.py
模块。
https://stackoverflow.com/questions/67702123
复制相似问题