change: improved .xplb -c, it will now correctly work only on users who are still in the server, isntead of only top 1k

fix: Fixed medusa error on bot startup
This commit is contained in:
Kwoth
2024-10-03 12:58:45 +00:00
parent de8d4b7d9e
commit 0cf7909fef
4 changed files with 32 additions and 33 deletions

View File

@@ -183,27 +183,26 @@ public partial class Xp : NadekoModule<XpService>
await ctx.Channel.TriggerTypingAsync();
var socketGuild = (SocketGuild)ctx.Guild;
var allCleanUsers = new List<UserXpStats>();
if (opts.Clean)
{
await ctx.Channel.TriggerTypingAsync();
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild);
allCleanUsers = (await _service.GetTopUserXps(ctx.Guild.Id, 1000))
.Where(user => socketGuild.GetUser(user.UserId) is not null)
.ToList();
async Task<IReadOnlyCollection<UserXpStats>> GetPageItems(int curPage)
{
var socketGuild = (SocketGuild)ctx.Guild;
if (opts.Clean)
{
await ctx.Channel.TriggerTypingAsync();
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild);
return await _service.GetTopUserXps(ctx.Guild.Id,
socketGuild.Users.Select(x => x.Id).ToList(),
curPage);
}
return await _service.GetUserXps(ctx.Guild.Id, curPage);
}
var res = opts.Clean
? Response()
await Response()
.Paginated()
.Items(allCleanUsers)
: Response()
.Paginated()
.PageItems((curPage) => _service.GetUserXps(ctx.Guild.Id, curPage));
await res
.PageItems(GetPageItems)
.PageSize(9)
.CurrentPage(page)
.Page((users, curPage) =>