From d699873fa32615cf8ded5d090e080ee2cdf1b271 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Wed, 3 Jun 2020 23:19:42 +0200 Subject: [PATCH] Reword different commands in raffle system --- ChaosBot/Discord/Modules/RaffleSystem.cs | 47 ++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/ChaosBot/Discord/Modules/RaffleSystem.cs b/ChaosBot/Discord/Modules/RaffleSystem.cs index 6861553..fe35484 100644 --- a/ChaosBot/Discord/Modules/RaffleSystem.cs +++ b/ChaosBot/Discord/Modules/RaffleSystem.cs @@ -19,8 +19,9 @@ namespace ChaosBot.Discord.Modules private static Dictionary _currentPot = new Dictionary(); [Command("raffle")] + [Alias("raffle info")] [RequireUserPermission(GuildPermission.ManageGuild)] - public async Task RaffleInfo() { + public async Task RaffleCommandInfo() { try { var sb = new StringBuilder(); @@ -32,6 +33,10 @@ namespace ChaosBot.Discord.Modules sb.AppendLine($"{Context.User.Mention} has requested raffle information."); sb.AppendLine(); sb.AppendLine($"Usage:"); + sb.AppendLine($"{prefix}raffle status"); + sb.AppendLine($"{prefix}raffle info"); + sb.AppendLine(); + sb.AppendLine("Moderation commands:"); sb.AppendLine($"{prefix}raffle add "); sb.AppendLine($"{prefix}raffle pick"); sb.AppendLine($"{prefix}raffle clear"); @@ -52,9 +57,34 @@ namespace ChaosBot.Discord.Modules } } - [Command("raffle")] + [Command("raffle add")] [RequireUserPermission(GuildPermission.ManageGuild)] - public async Task RaffleCommand(string action, string user = null, int amount = 0) { + public async Task RaffleCommandAdd(string user, int amount) + { + await RaffleCommandHelper("add", user, amount); + } + + [Command("raffle pick")] + [RequireUserPermission(GuildPermission.ManageGuild)] + public async Task RaffleCommandPick() + { + await RaffleCommandHelper("pick"); + } + + [Command("raffle clear")] + [RequireUserPermission(GuildPermission.ManageGuild)] + public async Task RaffleCommandClear() + { + await RaffleCommandHelper("clear"); + } + + [Command("raffle status")] + public async Task RaffleCommandStatus() + { + await RaffleCommandHelper("status", $"<@!{Context.User.Id}>"); + } + + private async Task RaffleCommandHelper(string action, string user = null, int amount = 0) { try { StringBuilder sb = new StringBuilder(); @@ -75,6 +105,9 @@ namespace ChaosBot.Discord.Modules case "clear": ClearRaffle(sb); break; + case "status": + StatusRaffle(sb, user); + break; } /* @@ -145,5 +178,13 @@ namespace ChaosBot.Discord.Modules sb.AppendLine($"{Context.User.Mention} has cleared all rafflepoints"); } + + private void StatusRaffle(StringBuilder sb, string user) + { + ulong userId = Convert.ToUInt64(user.Substring(3, user.Length-4)); + + sb.AppendLine($"<@{userId}>, you have {_currentPot.GetValueOrDefault(userId)} rafflepoints."); + sb.AppendLine($"There is a total of {_currentPot.Values.Sum()} rafflepoints."); + } } } \ No newline at end of file