Skip to content

Commit d820f4e

Browse files
authored
Fixed blackjack errors deducting coins (#537)
* Fixed blackjack errors deducting coins * Fixed small typo
1 parent a3a369b commit d820f4e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/commandDetails/games/blackjack.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,26 @@ const blackjackExecuteCommand: SapphireMessageExecuteType = async (
265265
// Return next game state
266266
await msg.edit({ embeds: [getEmbedFromGame(game!)] });
267267
await reactCollector.update({ components: [optionRow] });
268-
} catch {
269-
// If player has not acted within time limit, consider it as quitting the game
270-
game = performGameAction(author, BlackjackAction.QUIT);
271-
msg.edit(
272-
"You didn't act within the time limit. Unfortunately, this counts as a quit. Please start another game!",
273-
);
274-
if (game) {
275-
game.stage = BlackjackStage.DONE;
268+
} catch (error) {
269+
if (error instanceof Error && error.message.includes('time')) {
270+
// If player has not acted within time limit, consider it as quitting the game
271+
game = performGameAction(author, BlackjackAction.QUIT);
272+
await msg.edit(
273+
"You didn't act within the time limit. Unfortunately, this counts as a quit. Please start another game!",
274+
);
275+
if (game) {
276+
game.stage = BlackjackStage.DONE;
277+
}
278+
} else {
279+
// Handling Unexpected Errors
280+
await msg.edit('An unexpected error occured. The game has been aborted.');
281+
282+
closeGame(author, 0); // No change to balance
283+
return 'An unexpected error occured. The game has been aborted.';
276284
}
277285
}
278286
}
287+
279288
if (game) {
280289
// Update game embed
281290
await msg.edit({ embeds: [getEmbedFromGame(game)], components: [] });

0 commit comments

Comments
 (0)