Merge branch 'master' of ssh://git.chaoticlogic.us:2302/discord-bots/chaosbot

This commit is contained in:
Daniel_I_Am 2020-06-04 02:14:18 +02:00
commit 0a6dab9cf5
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -60,9 +60,16 @@ namespace ChaosBot.Discord.Modules
[Command("raffle add")]
[RequireUserPermission(GuildPermission.ManageGuild)]
public async Task RaffleCommandAdd(string user, int amount)
public async Task RaffleCommandAdd(string user, int amount = 1)
{
await RaffleCommandHelper("add", user, amount);
if (Program.Cfg.GetValue<int>("Raffle:Max") >= amount)
await RaffleCommandHelper("add", user, amount);
else
{
await ReplyAsync(
$"You cannot give more then {Program.Cfg.GetValue<int>("Raffle:Max").ToString()} tickets at a time", false);
_logger.Warn($"{Context.User.Username} attempted to give {amount} tickets to {user}!");
}
}
[Command("raffle pick")]
@ -84,7 +91,7 @@ namespace ChaosBot.Discord.Modules
{
await RaffleCommandHelper("status", $"<@!{Context.User.Id}>");
}
private async Task RaffleCommandHelper(string action, string user = null, int amount = 0) {
try
{
@ -149,7 +156,7 @@ namespace ChaosBot.Discord.Modules
sb.AppendLine($"{Context.User.Mention} has added {amount} rafflepoints to <@{userId}>.");
sb.AppendLine();
sb.AppendLine($"<@{userId}> now has WIP rafflepoints!");
sb.AppendLine($"<@{userId}> now has {RaffleRepository.selectUser(userId.ToString()).Length} rafflepoints!");
}
private void PickRaffle(StringBuilder sb)
@ -171,8 +178,8 @@ namespace ChaosBot.Discord.Modules
{
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.");
sb.AppendLine($"<@{userId}>, you have {RaffleRepository.selectUser(userId.ToString()).Length} rafflepoints.");
sb.AppendLine($"There is a total of {RaffleRepository.all().Length} rafflepoints.");
}
}
}