我正在制作一个 Python discord 机器人。我给我的机器人一个自定义状态,它可以工作。但是,当我尝试使用此代码:
await client.change_presence(activity=discord.BaseActivity(type=discord.HypeSquadHouse.bravery))
给它一个炒作队徽章时,我收到此错误:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:\Users\max\OneDrive\Desktop\Code\Python\BigBrian\BigBrian_3.0\Brian3.py", line 27, in on_ready
await client.change_presence(activity=discord.BaseActivity(type=discord.HypeSquadHouse.bravery))
File "C:\Python\Python38\lib\site-packages\discord\client.py", line 1001, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
File "C:\Python\Python38\lib\site-packages\discord\gateway.py", line 544, in change_presence
activity = activity.to_dict()
AttributeError: 'BaseActivity' object has no attribute 'to_dict'
我到处找,但在 dsicord.py 中根本找不到任何提到 Hypesquad 的内容。我知道这是真实的,因为它在文档中。 https://discordpy.readthedocs.io/en/latest/api.html#discord.Profile.hypesquad https://discordpy.readthedocs.io/en/latest/api.html#discord.Profile.hypesquad