Skip to content

Commit 4125523

Browse files
Fix bug with /crash button and add 3% auto fail
1 parent 81bfd6a commit 4125523

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/technobot/commands/casino/CrashCommand.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public void execute(SlashCommandInteractionEvent event) {
6060
}
6161
economyHandler.removeMoney(user.getIdLong(), bet);
6262

63+
// Check for auto fail
64+
if (ThreadLocalRandom.current().nextDouble() <= 0.03) {
65+
EmbedBuilder embed = new EmbedBuilder()
66+
.setAuthor(user.getAsTag(), null, user.getEffectiveAvatarUrl())
67+
.setColor(EmbedColor.ERROR.color)
68+
.setDescription("Your bet: " + economyHandler.getCurrency() + " " + EconomyHandler.FORMATTER.format(bet))
69+
.addField("Crashed At", "x1.00", true)
70+
.addField("Loss", economyHandler.getCurrency() + " -" + EconomyHandler.FORMATTER.format(bet), true);
71+
event.replyEmbeds(embed.build()).addActionRow(Button.primary("cashout", "Cashout").asDisabled()).queue();
72+
return;
73+
}
74+
6375
// Setup crash game
6476
double multiplier = 0.01 + (0.99 / ThreadLocalRandom.current().nextDouble());
6577
if (multiplier > 30) multiplier = 30;
@@ -86,9 +98,9 @@ public void execute(SlashCommandInteractionEvent event) {
8698
embed2.setDescription("Your bet: " + economyHandler.getCurrency() + " " + EconomyHandler.FORMATTER.format(bet));
8799
embed2.addField("Crashed At", multiplierString, true);
88100
embed2.addField("Loss", economyHandler.getCurrency() + " -" + EconomyHandler.FORMATTER.format(bet), true);
89-
msg.editOriginalEmbeds(embed2.build()).queue();
90101
games.remove(user.getIdLong()).task.cancel(true);
91-
ButtonListener.buttons.remove(uuid);
102+
Button disabledButton = ButtonListener.buttons.remove(uuid).get(0).asDisabled();
103+
msg.editOriginalEmbeds(embed2.build()).setActionRow(disabledButton).queue();
92104
} else {
93105
int profit = (int) (((double)bet)*game.currMultiplier);
94106
embed2.setColor(EmbedColor.DEFAULT.color);

0 commit comments

Comments
 (0)