I have created a view with 2 buttons.
Each button sends a modal with interaction.response.send_modal(modal)
I then fill in the fields of the modal and submit. The callback of the modal stores the data in a sqlite db.
My question is, if I then click the same button to view/edit the values I just put in, they are not there.
What I tried:
querying the database, and passing it along (if it exists) to the modal when the button is clicked. I then check the data to see if the values were already in the database, and if they were, I set the value of that specific inputText
class MyModal(discord.ui.Modal):
def __init__(self, view, data, *args, **kwargs) -> None:
self.view = view
self.item_value = data.get('val', 'Fake')
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(
label = 'label here',
placeholder = 'placeholder here',
custom_id = 'custom_modal'),
value = self.item_value
)```
That however results in an exception `TypeError: add_item() got an unexpected keyword argument 'value'`
However the docs say, that value is a property that you can pass https://docs.pycord.dev/en/stable/api.html#discord.ui.InputText
TLDR is there a better way to prefill values on modals that you can close/reopen