Improve formatting on output of the RankCheck command
This commit is contained in:
parent
f48fd77c77
commit
06f93e44da
@ -27,8 +27,8 @@ namespace ChaosBot.Discord.Modules.Admin
|
||||
await Context.Channel.TriggerTypingAsync();
|
||||
|
||||
List<LodestoneRankedUser> rankedUsers = await GetRanksFromEndpoint(Context.Guild.Id);
|
||||
|
||||
List<StringBuilder> embedContent = new List<StringBuilder>{new StringBuilder()};
|
||||
|
||||
Dictionary<string, StringBuilder> promotionLists = new Dictionary<string, StringBuilder>();
|
||||
|
||||
if (rankedUsers.Count(u => u.ShouldBeRole != null) > 0)
|
||||
{
|
||||
@ -39,35 +39,55 @@ namespace ChaosBot.Discord.Modules.Admin
|
||||
// Skip users that shouldn't be upgraded
|
||||
if (rankedUser.ShouldBeRole == null) continue;
|
||||
if (rankedUser.ShouldBeRole == rankedUser.IngameRole) continue;
|
||||
|
||||
if (embedContent.Last().Length >= 1800)
|
||||
embedContent.Add(new StringBuilder());
|
||||
|
||||
embedContent.Last().Append($"{rankedUser.IngameRole} {rankedUser.DisplayName}");
|
||||
string key = $"{rankedUser.IngameRole} Pending Promotion to {rankedUser.ShouldBeRole}";
|
||||
|
||||
if (!promotionLists.TryGetValue(key, out StringBuilder embedContent))
|
||||
{
|
||||
embedContent = new StringBuilder();
|
||||
promotionLists.Add(key, embedContent);
|
||||
}
|
||||
|
||||
embedContent.Append($"{rankedUser.DisplayName}");
|
||||
if (rankedUser.DiscordId != null)
|
||||
embedContent.Last().Append($" [<@{rankedUser.DiscordId}>]");
|
||||
embedContent.Last().AppendLine($" -> {rankedUser.ShouldBeRole}");
|
||||
embedContent.Append($"linked to <@{rankedUser.DiscordId}>");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
embedContent.Last().AppendLine($"Something went wrong checking {rankedUser.DisplayName}");
|
||||
|
||||
string key = "errors";
|
||||
if (!promotionLists.TryGetValue(key, out StringBuilder embedContent))
|
||||
{
|
||||
embedContent = new StringBuilder();
|
||||
promotionLists.Add(key, embedContent);
|
||||
}
|
||||
|
||||
embedContent.AppendLine($"Something went wrong checking {rankedUser.DisplayName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
embedContent.Last().AppendLine("No new promotions found!");
|
||||
string key = "empty";
|
||||
if (!promotionLists.TryGetValue(key, out StringBuilder embedContent))
|
||||
{
|
||||
embedContent = new StringBuilder();
|
||||
promotionLists.Add(key, embedContent);
|
||||
}
|
||||
|
||||
embedContent.AppendLine("No new promotions found!");
|
||||
}
|
||||
|
||||
foreach (StringBuilder builder in embedContent)
|
||||
foreach (KeyValuePair<string, StringBuilder> promotionList in promotionLists)
|
||||
{
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
|
||||
embedBuilder.Title = "Pending Promotions";
|
||||
embedBuilder.Description = builder.ToString();
|
||||
promotionList.Value.Insert(0, $"**{promotionList.Key}**\n");
|
||||
embedBuilder.Description = promotionList.Value.ToString();
|
||||
|
||||
await ReplyAsync(null, false, embedBuilder.Build());
|
||||
await ReplyAsync(null, false, embedBuilder.Build());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user