diff --git a/ChaosBot/Discord/Modules/User/Roll.cs b/ChaosBot/Discord/Modules/User/Roll.cs index 1a30f7e..a77b1a2 100644 --- a/ChaosBot/Discord/Modules/User/Roll.cs +++ b/ChaosBot/Discord/Modules/User/Roll.cs @@ -15,7 +15,7 @@ namespace ChaosBot.Discord.Modules.User public class Roll : ModuleBase { private static readonly ILogger _logger = Program.Logger; - + [Command("roll")] [Alias("random", "dice")] [CheckCommandPerm("User")] @@ -23,35 +23,42 @@ namespace ChaosBot.Discord.Modules.User { try { - string diceRecipe = Strings.Join(args, " "); - - var sb = new StringBuilder(); - var embed = new EmbedBuilder(); + string diceRecipe = null; - RollResult rollResult = Roller.Roll(diceRecipe); - - embed.WithColor(new Color(255, 255,0)); - // embed.Title = $"Dice Roll"; - sb.AppendLine($"{Context.User.Mention} :game_die:"); - sb.AppendLine($"Result: {diceRecipe} ({DiceOutput(rollResult)})"); - sb.AppendLine($"Total: {rollResult.Value}"); - - /* - * Add the string to the Embed - */ - embed.Description = sb.ToString(); + if (args.Length > 1) + diceRecipe = Strings.Join(args, " "); + else + diceRecipe = "1d20"; - /* - * Reply with the Embed created above - */ - await ReplyAsync(null, false, embed.Build()); + var sb = new StringBuilder(); + var embed = new EmbedBuilder(); + + RollResult rollResult = Roller.Roll(diceRecipe); + + embed.WithColor(new Color(255, 255, 0)); + // embed.Title = $"Dice Roll"; + sb.AppendLine($"{Context.User.Mention} :game_die:"); + sb.AppendLine($"Result: {diceRecipe} ({DiceOutput(rollResult)})"); + sb.AppendLine($"Total: {rollResult.Value}"); + + /* + * Add the string to the Embed + */ + embed.Description = sb.ToString(); + + /* + * Reply with the Embed created above + */ + await ReplyAsync(null, false, embed.Build()); } catch (Exception ex) { - _logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); + _logger.Error( + $"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>."); } } - private string DiceOutput(RollResult rollResult) + + private string DiceOutput(RollResult rollResult) { if (rollResult.RollRoot == null) return ""; StringBuilder sb = new StringBuilder(); @@ -64,7 +71,7 @@ namespace ChaosBot.Discord.Modules.User sb.Append(result); sb.Append(DieFormatting(dieResult.Flags, true)); } - + return sb.ToString(); } @@ -97,14 +104,14 @@ namespace ChaosBot.Discord.Modules.User case SpecialDie.OpenParen: return "("; } - + break; } - + return ""; } - private string DieFormatting(DieFlags flags, bool reverse=false) + private string DieFormatting(DieFlags flags, bool reverse = false) { StringBuilder sb = new StringBuilder(); if ((flags & (DieFlags.Critical ^ DieFlags.Success ^ DieFlags.Failure ^ DieFlags.Fumble)) != 0) @@ -112,7 +119,7 @@ namespace ChaosBot.Discord.Modules.User if ((flags & DieFlags.Dropped) != 0) sb.Append("~~"); - + if ((flags & DieFlags.Extra) != 0) sb.Append("*");