Val
DIAdiscord.js - Imagine an app
•Created by Val on 8/18/2023 in #djs-questions
More concise way to edit sent embeds
I am currently dealing editing the fields of an existing embed as a reply, where I'm only changing the fields and not the base content. However, so far the only way I've seen to edit embeds is to redefine the entire embed. I tried making a
baseEmbed
which only containts setTitle()
, .setDescription
etc, and using .addFields()
for the editable content. However, .addFields()
mutates the existing embed rather than making a new one and as such it simply keeps adding new copies of the fields. Is there any way to get this to work without having to repeat the .setTitle()
etc.?7 replies
DIAdiscord.js - Imagine an app
•Created by Val on 8/14/2023 in #djs-questions
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?
7 replies
DIAdiscord.js - Imagine an app
•Created by Val on 8/14/2023 in #djs-voice
Player loop for 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?
5 replies