#Container Json in Container Item
1 messages · Page 1 of 1 (latest)
@simple pivot idk if this is exoected
Wenn ich das Json versuche kommt dieser Fehler
Traceback (most recent call last):
File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\ui\modal.py", line 340, in dispatch
await value.callback(interaction)
File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\cogs\experiments.py", line 102, in callback
view = discord.ui.View(d, timeout=None)
File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\ezcord\components.py", line 134, in __init__
super().__init__(*args, **kwargs)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\ui\view.py", line 249, in __init__
self.add_item(item)
~~~~~~~~~~~~~^^^^^^
File "C:\Users\basti\BastiGame\Development\DevHQ\InternalBot\.venv\Lib\site-packages\discord\ui\view.py", line 389, in add_item
raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'dict'>
there should be a from_dict method on the view itself iirc
indeed.
though the signature seems to be incorrect
Its referencing the actual Component class and not it's TypedDict
I don't understand how to implement this. Do you have an example?
discord.View.from_dict(json.dumps(YOUR_JSON_DATA))
This is the data as I store it in the database.
container_json = json.dumps(container.to_component_dict())
{
"type": 17,
"id": null,
"components": [
{
"type": 10,
"id": null,
"content": "Testing the system"
},
{
"type": 14,
"id": null,
"divider": true,
"spacing": 1
},
{
"type": 10,
"id": null,
"content": " Information provided by :) "
}
],
"spoiler": false
}
The example you sent doesn't work there, though.
Wrap this in a list
I'll add more from_dict methods later