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
Lioness100
Lioness10013mo ago
@Dragonite uses one strategy which includes compressing the data. https://discord.com/channels/737141877803057244/1172211417810751559/1172223771436929035
Lioness100
Lioness10013mo ago
There's also been an @sapphire/string-store in development, but I don't think it's complete.
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.
Lioness100
Lioness10013mo ago
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
Mathias
MathiasOP13mo ago
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()
Lioness100
Lioness10013mo ago
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 format
Mathias
MathiasOP13mo ago
Yep, 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
Lioness100
Lioness10013mo ago
I also made a utility for this which I can send in a few minutes It's pretty useful but overkill for most usecases
Favna
Favna13mo ago
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
Want results from more Discord servers?
Add your server