Create a player loop for a blackjack game
Hi everyone! I'm currently implementing a game of blackjack in my bot, using an embed and buttons for the game information and functions. It is two-player, with the command to start the game having an option to mention the other player, with player 1 being the command initiator.
My issue is in how to make the game loop back and forth between both players then break when someone wins.
The code specifically for the game itself is below:
My idea for a solution is to check the current player id to flip between whose turn it is, however the "hit" collector only collects once, if I try to "hit" a second time it simply gives "this interaction has failed." How would I be able to loop through the players until one wins, by maybe allowing the collector to always collect, similar to the behaviour of addEventListener in default JS for HTML elements?
3 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!so the filter would look like this?
it doesn't work for some reason
it works for the first two turns, then when it's my turn again it gives an "interaction has failed"
ohhh i see