Skip to content

Commit

Permalink
top command to doublefetch users
Browse files Browse the repository at this point in the history
  • Loading branch information
RheaAyase committed Jul 10, 2024
1 parent d22edf9 commit 831671e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Modules/Karma.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Discord;
using Discord.Net;
using Valkyrja.core;
using Valkyrja.entities;
Expand Down Expand Up @@ -62,13 +63,18 @@ public List<Command> Init(IValkyrjaClient iClient)
StringBuilder response = new StringBuilder($"Here is the top {n} {e.Server.Config.KarmaCurrencySingular} holders:");
foreach( UserData userData in users )
{
if( i++ == n )
break;

SocketGuildUser user = null;
if( (user = e.Server.Guild.GetUser(userData.UserId)) == null )
IGuildUser user = e.Server.Guild.GetUser(userData.UserId);
if( user == null )
{
user = await this.Client.DiscordClient.Rest.GetGuildUserAsync(e.Server.Id, userData.UserId);
}
if( user == null )
continue;
response.AppendLine($"**{i})** {user.GetNickname().Replace("@everyone", "@-everyone").Replace("@here", "@-here")} : `{userData.KarmaCount}`");

response.AppendLine($"**{++i})** {user.GetNickname().Replace("@everyone", "@-everyone").Replace("@here", "@-here")} : `{userData.KarmaCount}`");

if( i == n )
break;
}

await e.SendReplySafe(response.ToString());
Expand Down

0 comments on commit 831671e

Please sign in to comment.