Skip to content

Commit

Permalink
Fixed blackjack errors deducting coins
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonH53 committed Sep 29, 2024
1 parent 41a2dab commit 979ec2a
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/commandDetails/games/blackjack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,26 @@ const blackjackExecuteCommand: SapphireMessageExecuteType = async (
// Return next game state
await msg.edit({ embeds: [getEmbedFromGame(game!)] });
await reactCollector.update({ components: [optionRow] });
} catch {
// If player has not acted within time limit, consider it as quitting the game
game = performGameAction(author, BlackjackAction.QUIT);
msg.edit(
"You didn't act within the time limit. Unfortunately, this counts as a quit. Please start another game!",
);
if (game) {
game.stage = BlackjackStage.DONE;
} catch (error) {
if (error instanceof Error && error.message.includes('time')) {
// If player has not acted within time limit, consider it as quitting the game
game = performGameAction(author, BlackjackAction.QUIT);
await msg.edit(
"You didn't act within the time limit. Unfortunately, this counts as a quit. Please start another game!",
);
if (game) {
game.stage = BlackjackStage.DONE;
}
} else {
// Handling Unexpected Errors
await msg.edit("An unexpected error occured. The game has been aborted.");

Check failure on line 280 in src/commandDetails/games/blackjack.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `"An·unexpected·error·occured.·The·game·has·been·aborted."` with `'An·unexpected·error·occured.·The·game·has·been·aborted.'`

closeGame(author, 0); // No change to balance
return 'An unexpected error occured. The game has been aborted.';
}
}
}

if (game) {
// Update game embed
await msg.edit({ embeds: [getEmbedFromGame(game)], components: [] });
Expand Down

0 comments on commit 979ec2a

Please sign in to comment.