【发布时间】:2020-05-20 03:24:57
【问题描述】:
为什么我的代码不起作用?
@bot.event
async def on_ready():
print('Bot is now working!')
await bot.change_presence(activity=discord.CustomActivity(name='Custom status' ,emoji='????️'))
然后给我一个错误。
Ignoring exception in on_ready
Traceback (most recent call last):
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/discord/client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "main.py", line 30, in on_ready
await bot.change_presence(activity=discord.CustomActivity(name='Custom status' ,emoji='????️'))
AttributeError: module 'discord' has no attribute 'CustomActivity'
如何修复错误?
【问题讨论】:
-
你用的是什么版本的discord包?
-
我使用的是最新版本 1.3。
-
您的路径中是否有另一个名为“discord”的模块,即文件或文件夹?
-
机器人无法使用自定义状态,只能使用之前的
Playing、Watching等。 -
您可以通过在机器人的开头添加
print(discord.__version__)来仔细检查版本是否正确更新。
标签: python python-3.x discord discord.py