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