if (interaction.customId === "accept") { // This is from an earlier collector which asks the target if they wish to play or not
await interaction.deferUpdate();
const reply = await interaction.editReply({
embeds: [blackjackEmbed],
components: [hitStand],
});
const hitStandFilter = (i) =>
(i.customId === "hit" || "stand") &&
(i.member.id === target.id || i.member.id == interaction.user);
const hitStandCollector = reply.createMessageComponentCollector(
{
componentType: ComponentType.Button,
filter: hitStandFilter,
max: 1,
time: 10000,
}
);
hitStandCollector.on("collect", async (interaction) => {
if (
interaction.customId === "hit" &&
currentPlayerIndex === 0
) {
let count1 = 0;
let count2 = 0;
count1 += hitCard(); // Function declared earlier, just randomly adds a number to simulate the "hit" in blackjack
currentPlayerIndex = 1 - currentPlayerIndex; // Declared earlier to be 0, flips between 0 and 1 to check whose turn it is
const newBlackjackEmbed = new EmbedBuilder()
.setTitle("Blackjack")
.setColor("Red")
.setDescription(
"`\`` _____\n|A . |\n| /.\\ |\n|(_._)|\n| | |\n|____Ɐ|\n`\``\nWelcome to blackjack. Press the buttons below to hit or stand."
)
.addFields(
{
name: "Player 1's count",
value: `${count1}`,
},
{ name: "Player 2's count", value: "0" },
{
name: "The current player is:",
value: `Player ${currentPlayerIndex}`,
}
);
await interaction.deferUpdate();
await interaction.editReply({
embeds: [newBlackjackEmbed],
});
return;
} else if ((interaction, customId === "stand")) {
await interaction.reply("test 2"); // Stand function is unimplemented
return;
}
});
return;
} else if (interaction.customId === "deny") {
await interaction.deferUpdate();
await interaction.editReply({
content: `You have declined the game.`,
embeds: [],
components: [],
});
return;
}
if (interaction.customId === "accept") { // This is from an earlier collector which asks the target if they wish to play or not
await interaction.deferUpdate();
const reply = await interaction.editReply({
embeds: [blackjackEmbed],
components: [hitStand],
});
const hitStandFilter = (i) =>
(i.customId === "hit" || "stand") &&
(i.member.id === target.id || i.member.id == interaction.user);
const hitStandCollector = reply.createMessageComponentCollector(
{
componentType: ComponentType.Button,
filter: hitStandFilter,
max: 1,
time: 10000,
}
);
hitStandCollector.on("collect", async (interaction) => {
if (
interaction.customId === "hit" &&
currentPlayerIndex === 0
) {
let count1 = 0;
let count2 = 0;
count1 += hitCard(); // Function declared earlier, just randomly adds a number to simulate the "hit" in blackjack
currentPlayerIndex = 1 - currentPlayerIndex; // Declared earlier to be 0, flips between 0 and 1 to check whose turn it is
const newBlackjackEmbed = new EmbedBuilder()
.setTitle("Blackjack")
.setColor("Red")
.setDescription(
"`\`` _____\n|A . |\n| /.\\ |\n|(_._)|\n| | |\n|____Ɐ|\n`\``\nWelcome to blackjack. Press the buttons below to hit or stand."
)
.addFields(
{
name: "Player 1's count",
value: `${count1}`,
},
{ name: "Player 2's count", value: "0" },
{
name: "The current player is:",
value: `Player ${currentPlayerIndex}`,
}
);
await interaction.deferUpdate();
await interaction.editReply({
embeds: [newBlackjackEmbed],
});
return;
} else if ((interaction, customId === "stand")) {
await interaction.reply("test 2"); // Stand function is unimplemented
return;
}
});
return;
} else if (interaction.customId === "deny") {
await interaction.deferUpdate();
await interaction.editReply({
content: `You have declined the game.`,
embeds: [],
components: [],
});
return;
}