how to set up action row such that each user can interact with a button only once?
I'm trying to set up an action row with multiple buttons (for example A, B, C), and I want each user in my server to be able to interact with these buttons, however each user gets a max of only one interaction. The reason for this is a polling system; I want each user to vote only once. How can I achieve this?
20 Replies
- 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 OPDiscord doesn't support a per-user display for Buttons. If you disable one, they're disabled for everyone
It's up to you to track that internally and respond "You already submitted" or something like that
ahh thats what I thought too, any ideas how I can track a "you already submitted"?
my initial thought is to have a set with user id
but idk how to get the user id of each person who interacts
once i figure that out i could prob just send an ephemeral "you already submitted" and then we're good to go
Yep, thats pretty much how I'd do it.
interaction.user.id
will be available on the button interactionokay, ill try that out! thanks for the help:) hopefully I can get it to work with multiple interactions without much of a headache
Just gotta maintain that set in the right scope, so it's not a
new Set()
on every interaction
Depends how you're listening for buttonsyeah i cant even get the button interactions to work at the moment unfortunately
im trying to follow the tutorial on the website but for some reason it just consistently fails
i copied the code straight from the tutorial to see if itll work
but nope
That error suggests its trying to respond to it like a command though
It might not be reaching these buttons
maybe but the error only comes up after i interact with a button
thats why im not too sure
If your command handler is rejecting it first, that would cause this issue
If you want to collect multiple button interactions a collector might be better than await
:guide: Message Components: Component interactions - Component collectors
Begin by storing the InteractionResponseopen in new window as a variable, and calling InteractionResponse#createMessageComponentCollector()open in new window on this instance. This method returns an InteractionCollector that will fire its InteractionCollector#event:collectopen in new window event...
read more
hmmm im gonna try that and see what happens
im hoping its not a command handler issue
It seems like your command handler might not have a line to ignore anything thats not a command
if(!interaction.isChatInputCommand()) return;
i do have that actually
this is my command handler
though i guess it is coming from here
ahh wait i figured it out, its cause i had copied from the tutorial but i didnt follow their ban command tutorial
i still get an error but at least this time i know its not from the command handler
continues to give me "This interaction failed"
when i click on a button
even if i set the ComponentType to Button
@ʎǝɹquoɯ is it at all possible that the reason there's issues is because it's a modalsubmission reply instead of an interaction reply?
no that shouldnt matter
sorry, Im busy with work stuff, cant give this the level of answer it needs right now
no worries! take your time
ill figure it out eventually 😅