#how can i pass any data to the interaction button?

23 messages · Page 1 of 1 (latest)

native portal
#

I have data that I need to use during the execution of the interaction button, but the handling of the button is in another file, what can I think of?

brisk tinsel
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

native portal
#

I can get this data via embed, but it's a crutch.

cerulean flicker
#

Do you need to handle the button in another file or can you also use a button collector in the file you have the data in you need?

pulsar salmon
#

Handling buttons in separate files is usually required when making a "persistent collector", I guess

cerulean flicker
#

Well, for a „persistent“ collector you need to persist the data you need somehow obviously… database would be advisable in most cases then

native portal
candid isleBOT
#

Suggestion for @native portal:
guide Interactions: Receiving button interactions
read more

native portal
#

This is what my message looks like, I need to pass this data to the button to create a new ticket (in database)

#

I can save to the database in advance at the time of preview, but the person can click "dismiss" and the ticket in the database will remain

cerulean flicker
#

Since this is on an ephemeral message a button collector would be perfect for this

candid isleBOT
#

guide Interactions: Receiving button interactions - Component collectors
read more

native portal
#

what if a person creates for a very long time?

cerulean flicker
#

And collectors won’t work beyond bot restarts

native portal
#

I don't quite get it, it just returns the ButtonInteraction that I'm already getting here

#

I just need to get the values to use their in handler button (TicketCreateButton)

the value is indicated by an arrow on the screen

cerulean flicker
#

And in that scope you have the data you used for the embed still available

native portal
#

i think this is impossible because sending a message is done in a modal handler (ModalSubmitInteraction) and the message is null

cerulean flicker
native portal
#

I understood what you meant, it dawned on me