mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
NadekoBot Patronage system, Search commands improvements + fixes
This commit is contained in:
@@ -65,7 +65,7 @@ public partial class Gambling
|
||||
}
|
||||
catch
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.unable_to_dm_user);
|
||||
await ReplyErrorLocalizedAsync(strs.cant_dm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using NadekoBot.Db.Models;
|
||||
|
||||
namespace NadekoBot.Modules.Gambling.Bank;
|
||||
|
||||
@@ -74,4 +75,19 @@ public sealed class BankService : IBankService, INService
|
||||
?.Balance
|
||||
?? 0;
|
||||
}
|
||||
|
||||
public async Task<long> BurnAllAsync(ulong userId)
|
||||
{
|
||||
await using var ctx = _db.GetDbContext();
|
||||
var output = await ctx.GetTable<BankUser>()
|
||||
.Where(x => x.UserId == userId)
|
||||
.UpdateWithOutputAsync(old => new()
|
||||
{
|
||||
Balance = 0
|
||||
});
|
||||
if (output.Length == 0)
|
||||
return 0;
|
||||
|
||||
return output[0].Deleted.Balance;
|
||||
}
|
||||
}
|
@@ -5,4 +5,5 @@ public interface IBankService
|
||||
Task<bool> DepositAsync(ulong userId, long amount);
|
||||
Task<bool> WithdrawAsync(ulong userId, long amount);
|
||||
Task<long> GetBalanceAsync(ulong userId);
|
||||
Task<long> BurnAllAsync(ulong userId);
|
||||
}
|
Reference in New Issue
Block a user