From 0dd956ae0ee07c31575a88b362b244c0bf86f283 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Tue, 1 Nov 2022 16:23:51 -0500 Subject: [PATCH] twentyone: show ratelimit error when ratelimited --- files/templates/casino/blackjack_screen.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/files/templates/casino/blackjack_screen.html b/files/templates/casino/blackjack_screen.html index 189781d21..91340915f 100644 --- a/files/templates/casino/blackjack_screen.html +++ b/files/templates/casino/blackjack_screen.html @@ -11,6 +11,7 @@ } function handleBlackjackResponse(xhr) { + let status; try { const response = JSON.parse(xhr.response); const succeeded = xhr.status >= 200 && @@ -19,6 +20,11 @@ !response.error; clearResult(); + status = xhr.status; + + if (status == 429) { + throw new Error(response["details"]); + } if (succeeded) { updateBlackjackTable(response.state); @@ -36,8 +42,13 @@ "double-down": "Unable to double down.", "buy-insurance": "Unable to buy insurance." }; + result = results[xhr.blackjackAction]; - updateResult(results[xhr.blackjackAction], "danger"); + if (status == 429) { + result = error.message; + } + + updateResult(result, "danger"); } }