#Getting original userID of slash command via Button Interaction

35 messages · Page 1 of 1 (latest)

viscid sundial
#

Hey, so I'm using a button Handler. But everyone can interact with the button. How do I restrict the button to be usable by the user who ran the slash command from which the button originated? (I use the interactionCreate event to reply to the buttons, so I can only get the buttonInteraction). I don't wanna use db

ashen kelp
#

you will have to associate the original author with the button, somehow
if you are just looking for confirm buttons, i'd probably recommend using a component collector in the scope you have "original author" available and supplying it as a filter condition.

if this is happening in another scope, you still need to somehow know who triggered the original response, either via in-memory map or by having the user id in the custom id and parsing it from there

echo phoenix
#

or another option is what Souji stated

#

You could cache the response with something like userID: messageID

#

Basically associating the button to specifically that user via that message itself and then if someone clicks that button, you can check if that user is associated with that button

#

and if not, handle it with what you prefer

viscid sundial
viscid sundial
echo phoenix
#

by cache I mean like

#

store it in memory

#

You can have a collection

#

and add it to them

#

and them remove it after x minutes etc

viscid sundial
viscid sundial
echo phoenix
#

then you need a db to store it

muted pagoda
#

@viscid sundial maybe you could just input the userid in the customid? That's how I handle things like that sometimes

viscid sundial
muted pagoda
#

How about a special character, like a hyphen in your customid, which seperates the name, and the I'd?

viscid sundial
#

I mean yea, but how would I access interaction when it's defined after customId

muted pagoda
#

That's easy to figure out, give it a few minutes of thought

#

If i tell you, would be spoonfeed of sorts

viscid sundial
muted pagoda
#

What do you mean by "i tried this", @viscid sundial

viscid sundial
echo phoenix
#

@viscid sundial Why not just use a file storing db

#

If you need to store these buttons for really long times then maybe not the best call but

#

you can always use a JSON file storing method for it if you want

violet pumice
#

so <buttonInteraction>.message.interaction.user.id

viscid sundial
muted pagoda
violet pumice
#

yeah