Removed plantedcurrency repository

This commit is contained in:
Kwoth
2021-06-18 09:00:55 +02:00
parent 32dee3a078
commit a3fa8224c4
6 changed files with 14 additions and 49 deletions

View File

@@ -6,6 +6,7 @@ using NadekoBot.Modules.Gambling.Common.WheelOfFortune;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
@@ -136,7 +137,7 @@ WHERE CurrencyAmount > {config.Decay.MinThreshold} AND UserId!={_client.CurrentU
{
cash = uow.DiscordUsers.GetTotalCurrency();
onePercent = uow.DiscordUsers.GetTopOnePercentCurrency(_client.CurrentUser.Id);
planted = uow.PlantedCurrency.GetTotalPlanted();
planted = uow._context.PlantedCurrency.AsQueryable().Sum(x => x.Amount);
waifus = uow.Waifus.GetTotalValue();
bot = uow.DiscordUsers.GetUserCurrency(_client.CurrentUser.Id);
}

View File

@@ -269,7 +269,17 @@ namespace NadekoBot.Modules.Gambling.Services
// this method will sum all plants with that password,
// remove them, and get messageids of the removed plants
(amount, ids) = uow.PlantedCurrency.RemoveSumAndGetMessageIdsFor(ch.Id, pass);
pass = pass?.Trim().TrimTo(10, hideDots: true).ToUpperInvariant();
// gets all plants in this channel with the same password
var entries = uow._context.PlantedCurrency
.AsQueryable()
.Where(x => x.ChannelId == ch.Id && pass == x.Password)
.ToList();
// sum how much currency that is, and get all of the message ids (so that i can delete them)
amount = entries.Sum(x => x.Amount);
ids = entries.Select(x => x.MessageId).ToArray();
// remove them from the database
uow._context.RemoveRange(entries);
if (amount > 0)
@@ -360,7 +370,7 @@ namespace NadekoBot.Modules.Gambling.Services
{
using (var uow = _db.GetDbContext())
{
uow.PlantedCurrency.Add(new PlantedCurrency
uow._context.PlantedCurrency.Add(new PlantedCurrency
{
Amount = amount,
GuildId = gid,