Ferretsroq
DIAdiscord.js - Imagine an app
•Created by Ferretsroq on 2/7/2024 in #djs-questions
Avoiding Overwriting Variables in Collectors (14.14.1)
When using collectors, what is the best way to preserve a variable determined in one interaction for use in a future interaction on the same message? For example, I'm making an rpg bot that first asks which stat you're rolling with, and then which modifiers apply. If I assign the stat value to a variable, that variable gets overwritten if a second person uses the command before the first person finishes, and they both wind up rolling whichever stat was selected second. What is the best way to tie the stat to the specific message being interacted with, such that no overwriting occurs when multiple people are using the same command at the same time?
Code snippet:
4 replies