Doubt about how data is tracked in embeds/buttons

I have a questiong regarding embeds/buttons, ill give you an example here: Lets pretend that im making a suggestion bot, now people is gonna use a command to generate an embed with 2 buttons, either accept or deny, how does the bot store what embed links to what user etc, does this structure include databases or am I too noob. Like users are gonna create an infinite number of suggestions and the but must know what suggestion links to what user. And im not talking about displaying user information in the embed, im talking about after using the buttons get back information about who made the suggestion to interact with it. Thanks and sorry for being kinda dumb.
10 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna3w ago
you need to store the id of the message and map it to the suggestion / whatever content you display then, when receiving the button interaction, compare <ButtonInteraction>.message.id Alternatively, you can use the latter and parse out the content from <Message>.embeds
MiKKey
MiKKeyOP3w ago
Does that mean i need to involve some mind of database? Like json or whatever
treble/luna
treble/luna3w ago
yes json isnt a database btw
MiKKey
MiKKeyOP3w ago
Wasnt there a way to store data that way? For small stuff
Syjalo
Syjalo3w ago
You can use JSON files as a database, but it not meant to be used so
MiKKey
MiKKeyOP3w ago
I mean a database seems overcomplicated, storing data in every suggestion..., Is it easy to setup?
Syjalo
Syjalo3w ago
Depends on the database and driver you choose Node.js has node:sqlite built-in
d.js docs
d.js docs3w ago
:node: SQLite Source Code: lib/sqlite.jsThe node:sqlite module facilitates working with SQLite databases.
MiKKey
MiKKeyOP3w ago
I think in gonna use mongodb, so basically store a suggestion with the message id, the user, and bla bla and then just listen to the interaction and look for that specific suggestion right?, the interaction with the button will provide me the message id that i need to look for in the db etc etc

Did you find this page helpful?