forked from EllieBotDevs/elliebot
Added grpc api, perm system
grpc api config in creds
This commit is contained in:
parent
de97213046
commit
391d2e43e8
14 changed files with 410 additions and 42 deletions
src/EllieBot/Modules/Gambling
|
@ -1,6 +1,7 @@
|
|||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using LinqToDB.Tools;
|
||||
using EllieBot.Db.Models;
|
||||
using EllieBot.Modules.Gambling.Bank;
|
||||
using EllieBot.Modules.Gambling.Common;
|
||||
|
@ -625,8 +626,6 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
|
||||
var (opts, _) = OptionsParser.ParseFrom(new LbOpts(), args);
|
||||
|
||||
// List<DiscordUser> cleanRichest;
|
||||
// it's pointless to have clean on dm context
|
||||
if (ctx.Guild is null)
|
||||
{
|
||||
opts.Clean = false;
|
||||
|
@ -640,10 +639,16 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
await ctx.Channel.TriggerTypingAsync();
|
||||
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild);
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
var users = ((SocketGuild)ctx.Guild).Users.Map(x => x.Id);
|
||||
var perPage = 9;
|
||||
|
||||
var cleanRichest = await uow.Set<DiscordUser>()
|
||||
.GetTopRichest(_client.CurrentUser.Id, 0, 1000);
|
||||
await using var uow = _db.GetDbContext();
|
||||
var cleanRichest = await uow.GetTable<DiscordUser>()
|
||||
.Where(x => x.UserId.In(users))
|
||||
.OrderByDescending(x => x.CurrencyAmount)
|
||||
.Skip(page * perPage)
|
||||
.Take(perPage)
|
||||
.ToListAsync();
|
||||
|
||||
var sg = (SocketGuild)ctx.Guild!;
|
||||
return cleanRichest.Where(x => sg.GetUser(x.UserId) is not null).ToList();
|
||||
|
@ -661,7 +666,6 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
await Response()
|
||||
.Paginated()
|
||||
.PageItems(GetTopRichest)
|
||||
.TotalElements(900)
|
||||
.PageSize(9)
|
||||
.CurrentPage(page)
|
||||
.Page((toSend, curPage) =>
|
||||
|
|
Reference in a new issue