#Prevent a user to click multiple times a button in a slash command

8 messages · Page 1 of 1 (latest)

empty leaf
#

I want to set up a button with a maximum number of collections, let's say 10. However I want the 10 collections to be from different users, is this possible? I can hack it a bit by adding the user ID to the text of the message and then simply read if the user is already there. This sounds terrible though, and I was wondering if there is a better way that does not involve me keeping this data in a db or anything.

foggy treeBOT
#

• 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.

empty leaf
#

Oh, it's not an issue as in an actual problem, it was a question for discussion. Somebody (not a bot) please let me know if there is a better channel for this and if that's the case I can delete this, thanks!

hollow lynx
#

Make an empty collection (or just an array of ids) of users that clicked the button. In your collector filter Check if the user is included in that collection/array. If not add them to it and return true, else return false. Set the collector to max:10 using that filter

empty leaf
#

That makes sense. The only issue would be if there are multiple occurrences of that command, but I can have a collection of collections I guess, one per message ID of the interaction

#

Probably overthinking it anyways, as it’s for a single server haha

#

Thank you!!!

hollow lynx
#

No, each run of the command would make its own collection/array anyway. It’s all about the right scope