public async Task GlobalXpLeaderboardAsync(int page = 1) { page--; if (page < 0) { page = 0; } var membersXp = await DbContext.GetOrderedListAsync <UserEntity, int>(x => x.Xp, true); var xpLeaderboard = membersXp.Skip(page * 15) .Take(15) .ToList(); if (xpLeaderboard.Count == 0) { await ReplyErrorAsync(Localization.XpLeaderboardEmpty); return; } var description = new StringBuilder(); var index = page * 15; foreach (var userDb in xpLeaderboard) { var user = await RiasBot.GetUserAsync(userDb.UserId); description.Append($"{++index}. **{user?.FullName()}**: " + $"`{GetText(Localization.XpLevelX, RiasUtilities.XpToLevel(userDb.Xp, XpService.XpThreshold))} " + $"({userDb.Xp} {GetText(Localization.XpXp).ToLowerInvariant()})`\n"); } var embed = new DiscordEmbedBuilder { Color = RiasUtilities.ConfirmColor, Title = GetText(Localization.XpLeaderboard), Description = description.ToString(), Footer = new DiscordEmbedBuilder.EmbedFooter { IconUrl = Context.User.GetAvatarUrl(ImageFormat.Auto), Text = $"{Context.User.FullName()} • #{membersXp.FindIndex(x => x.UserId == Context.User.Id) + 1}" } }; await ReplyAsync(embed); }
public async Task LeaderboardAsync(int page = 1) { page--; if (page < 0) { page = 0; } var usersCurrency = await DbContext.GetOrderedListAsync <UserEntity, int>(x => x.Currency, true); var currencyLeaderboard = usersCurrency.Skip(page * 15) .Take(15) .ToList(); if (currencyLeaderboard.Count == 0) { await ReplyErrorAsync(Localization.GamblingLeaderboardNoUsers); return; } var embed = new DiscordEmbedBuilder { Color = RiasUtilities.ConfirmColor, Title = GetText(Localization.GamblingCurrencyLeaderboard, Configuration.Currency), Footer = new DiscordEmbedBuilder.EmbedFooter { IconUrl = Context.User.GetAvatarUrl(ImageFormat.Auto), Text = $"{Context.User.FullName()} • #{usersCurrency.FindIndex(x => x.UserId == Context.User.Id) + 1}" } }; var index = 0; foreach (var userCurrency in currencyLeaderboard) { var user = await RiasBot.GetUserAsync(userCurrency.UserId); embed.AddField($"#{++index + page * 15} {user?.FullName()}", $"{userCurrency.Currency} {Configuration.Currency}", true); } await ReplyAsync(embed); }
public async Task FindUserAsync([Remainder] string value) { DiscordUser?user = null; if (ulong.TryParse(value, out var userId)) { user = await RiasBot.GetUserAsync(userId); if (user is null) { await ReplyErrorAsync(Localization.AdministrationUserNotFound); return; } } else { var index = value.LastIndexOf("#", StringComparison.Ordinal); if (index >= 0) { user = RiasBot.Members.FirstOrDefault(x => string.Equals(x.Value.Username, value[..index]) &&
public async Task GlobalXpLeaderboardAsync(int page = 1) { page--; if (page < 0) { page = 0; } var xpLeaderboard = await DbContext.GetOrderedListAsync <UsersEntity, int>(x => x.Xp, true, (page * 15)..((page + 1) * 15)); if (xpLeaderboard.Count == 0) { await ReplyErrorAsync(Localization.XpLeaderboardEmpty); return; } var embed = new LocalEmbedBuilder { Color = RiasUtilities.ConfirmColor, Title = GetText(Localization.XpLeaderboard) }; var index = page * 15; foreach (var userDb in xpLeaderboard) { var user = (IUser)RiasBot.GetUser(userDb.UserId) ?? await RiasBot.GetUserAsync(userDb.UserId); embed.AddField($"{++index}. {user}", $"{GetText(Localization.XpLevelX, RiasUtilities.XpToLevel(userDb.Xp, XpService.XpThreshold))} | {GetText(Localization.XpXp)} {userDb.Xp}", true); } await ReplyAsync(embed); }