File tree 1 file changed +17
-8
lines changed
1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -265,17 +265,26 @@ const blackjackExecuteCommand: SapphireMessageExecuteType = async (
265
265
// Return next game state
266
266
await msg . edit ( { embeds : [ getEmbedFromGame ( game ! ) ] } ) ;
267
267
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.' ;
276
284
}
277
285
}
278
286
}
287
+
279
288
if ( game ) {
280
289
// Update game embed
281
290
await msg . edit ( { embeds : [ getEmbedFromGame ( game ) ] , components : [ ] } ) ;
You can’t perform that action at this time.
0 commit comments