Any tips for store data in the interaction ?
Hello
What is the best way to store data through interactions?
Today, I put everything in the customId of the interaction, but it is limited to 100 characters...
Do you have tips?
Thanks!
8 Replies
@Dragonite uses one strategy which includes compressing the data.
https://discord.com/channels/737141877803057244/1172211417810751559/1172223771436929035
GitHub
feat: added string-store by kyranet · Pull Request #118 · sapphired...
TODO
Dynamically increase size on size-unknown payloads.
Add tests, lots of tests
Does this thing even work? Endianness is a pain.
cc @Favna if you want to add more details
Depending on what you're storing, you could also just store the data in a database and identify it with the interaction ID
It's in the same spirit as what I do. For the moment:
1) I create an object with my parameters
2) I add my object to customId using JSON.stringify()
I think the easiest way to cut down on characters without any complex algorithms like the code I linked is not using JSON.stringify. For example:
my_id."{"type":23,"day":28,"label":"routine"}"
is 46 characters but
my_id.23.28.routine
is 19.
So I'd recommend using a custom formatYep, I see! The only problem is that it's hard to read after a while
But thank you for your feedback: it opens up other perspectives for me if I need
I also made a utility for this which I can send in a few minutes
It's pretty useful but overkill for most usecases
The dragonite link is #unknown for me but I don't really have anything other to add than the source code if it's linked there