Discord.py Hypesquad to_dict?

767 Views Asked by At

Im making a Python discord bot. I have given my bot a custom status, and it works. However when i try to use this code: await client.change_presence(activity=discord.BaseActivity(type=discord.HypeSquadHouse.bravery)) to give it a hype squad badge, I get this error:

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'

I have looked everywhere, but cant find any mention of Hypesquad in dsicord.py at all. I know that is real as its in the documentation. https://discordpy.readthedocs.io/en/latest/api.html#discord.Profile.hypesquad https://discordpy.readthedocs.io/en/latest/api.html#discord.Profile.hypesquad

2

There are 2 best solutions below

0
On

Hold Ctrl and click on the error message that has file path to the discord file. If you are on Visual Studio Code (I'm not sure if this works on other Editors and IDEs) and press Ctrl + F and the find 'to_dict'. If you can't find it Ctrl + F and locate BaseActivity and find the functions that go with it, then you should be able to see how they work and how to use them. This is what I do but it is not recommended. PS: Check on the discord.py website or Command Prompt and see if your discord module is up to date.

1
On

HypeSquad is not a status or activity, it's a badge. Even if you can give it HypeSquad with that code, it would not work as you need to specify which HypeSquad you want it to have, which would either be an int or string. discord.Profile is not for bots and is not for giving someone HypeSquad