From 34c100acde882a538bdf27624d3cb5a190dfa1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Tue, 20 Dec 2022 17:55:30 +0100 Subject: [PATCH] Fix nothing being rolles if no arg was specified --- .../hidekobot/commands/message/DiceRollCommand.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/message/DiceRollCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/message/DiceRollCommand.java index a9d13b1..a4e7760 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/message/DiceRollCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/message/DiceRollCommand.java @@ -143,6 +143,14 @@ public class DiceRollCommand implements MessageCommand LinkedList rolledDices = new LinkedList<>(); + // in case no dice was specified (or invalid), roll a standard 6-sided dice. + if(dicesToRoll.isEmpty()) + { + Dice standardDice = new Dice(6); + dicesToRoll.put(standardDice, 1); + totalRolls = 1; + } + for(Dice dice : dicesToRoll.keySet()) { for(int roll = 0; roll < dicesToRoll.get(dice); roll++) @@ -186,7 +194,9 @@ public class DiceRollCommand implements MessageCommand embedBuilder.addField("\uD83C\uDFB2 Rolls", message.toString(), false); - embedBuilder.addField("✨ Total", totalRolls + " rolls: " + total, false); + String rolls = totalRolls == 1 ? "roll" : "rolls"; + + embedBuilder.addField("✨ Total", totalRolls + " " + rolls + ": " + total, false); event.getMessage().replyEmbeds(embedBuilder.build()).queue();