Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sean "Solao Bajiuik" Stoves 2020-06-03 17:32:03 -04:00
commit d83874512e

View File

@ -19,8 +19,9 @@ namespace ChaosBot.Discord.Modules
private static Dictionary<ulong, int> _currentPot = new Dictionary<ulong, int>();
[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 <discord mention> <amount>");
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.");
}
}
}