Merge branch 'master' of ssh://git.chaoticlogic.us:2302/discord-bots/chaosbot
This commit is contained in:
commit
f4cdf5c9c6
@ -54,14 +54,15 @@ namespace ChaosBot.Database.Repository
|
||||
Controller.InsertQuery(Table, dict);
|
||||
}
|
||||
|
||||
public static void massInsert(Raffle raffle, int amount)
|
||||
public static void massInsert(List<Raffle> raffles)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
|
||||
dict.Add("userId", raffle.userId);
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
foreach (var raf in raffles)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
|
||||
dict.Add("userId", raf.userId);
|
||||
Controller.InsertQuery(Table, dict);
|
||||
}
|
||||
}
|
||||
|
||||
// public static void delete()
|
||||
|
||||
@ -3,14 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ChaosBot.Database;
|
||||
using ChaosBot.Database.Entity;
|
||||
using ChaosBot.Database.Repository;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using ChaosBot.Database.Repository;
|
||||
|
||||
namespace ChaosBot.Discord.Modules
|
||||
{
|
||||
@ -129,23 +127,29 @@ namespace ChaosBot.Discord.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRaffle(StringBuilder sb, string user, int amount)
|
||||
private void AddRaffle(StringBuilder sb, string user, int amount = 1)
|
||||
{
|
||||
ulong userId = Convert.ToUInt64(user.Substring(3, user.Length-4));
|
||||
int currentAmount;
|
||||
if (_currentPot.TryGetValue(userId, out currentAmount))
|
||||
|
||||
if (amount > 1)
|
||||
{
|
||||
_currentPot.Remove(userId);
|
||||
_currentPot.Add(userId, currentAmount + amount);
|
||||
List<Raffle> raffles = new List<Raffle>();
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
raffles.Add(new Raffle(userId.ToString()));
|
||||
|
||||
RaffleRepository.massInsert(raffles);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentPot.Add(userId, amount);
|
||||
RaffleRepository.insert(new Raffle(userId.ToString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
sb.AppendLine($"{Context.User.Mention} has added {amount} rafflepoints to <@{userId}>.");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"<@{userId}> now has {_currentPot.GetValueOrDefault(userId)} rafflepoints!");
|
||||
sb.AppendLine($"<@{userId}> now has WIP rafflepoints!");
|
||||
}
|
||||
|
||||
private void PickRaffle(StringBuilder sb)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user