+ Added fix for leader-board attempting to display non-existing user

This commit is contained in:
Matthew Cech
2019-08-07 20:47:15 -07:00
parent b0948303d1
commit 31c5727d13
2 changed files with 11 additions and 2 deletions
+6 -2
View File
@@ -83,13 +83,17 @@ public class CommandLeaderboard extends Command
embed.title = LocStrings.stub("LeaderboardTitle");
embed.descriptionText = "";
for(int i = 0; i < listSize && i < users.size(); ++i)
int indexToDisplay = 1;
for(int i = 0; indexToDisplay <= listSize && i < users.size(); ++i)
{
// Only now that we've sorted do we do the full construction and caching of users
Pair<Long, String> userPair = users.get(i);
KittyUser cachedUser = ObjectBuilderFactory.getKittyUser(guildID, userPair.Second);
embed.descriptionText += "**" + (i + 1) + ":** " + userPair.First + " - " + cachedUser.name;
if(cachedUser == null)
continue;
embed.descriptionText += "**" + (indexToDisplay++) + ":** " + userPair.First + " - " + cachedUser.name;
embed.descriptionText += "\n";
}