'How can i fix this discord-components TypeError: Object of type Button is not JSON serializable?
i made with discord-components a message with buttons, but i get this error: TypeError: Object of type Button is not JSON serializable
The code is this:
msg = await ctx.reply(embed=embed,
components=[[
Button(label=spaceCar, style=1, emoji="🚙", custom_id="Car"),
Button(label=spaceCar, style=1, emoji="🛠️", custom_id="Tool")
]])
How can i fix this?
Solution 1:[1]
For those who have the same problem, there is a solution - just delete all discord libraries and install them again. It worked for me. The error was probably caused by the fact that there were differences in the versions of the libraries
Solution 2:[2]
make one list, not two in components.
msg = await ctx.reply(embed=embed,
components=[
Button(label=spaceCar, style=1, emoji="?", custom_id="Car"),
Button(label=spaceCar, style=1, emoji="??", custom_id="Tool")
])
Solution 3:[3]
I don't know why, but by importing this line locally, and not globally, the problem was solved:
from discord_components.dpy_overrides import fetch_message
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | svan |
Solution 2 | Ali FGT |
Solution 3 | UnderFleX |