Improve formatting on output of the RankCheck command
This commit is contained in:
parent
f48fd77c77
commit
06f93e44da
@ -28,7 +28,7 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
|
|
||||||
List<LodestoneRankedUser> rankedUsers = await GetRanksFromEndpoint(Context.Guild.Id);
|
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)
|
if (rankedUsers.Count(u => u.ShouldBeRole != null) > 0)
|
||||||
{
|
{
|
||||||
@ -40,32 +40,52 @@ namespace ChaosBot.Discord.Modules.Admin
|
|||||||
if (rankedUser.ShouldBeRole == null) continue;
|
if (rankedUser.ShouldBeRole == null) continue;
|
||||||
if (rankedUser.ShouldBeRole == rankedUser.IngameRole) continue;
|
if (rankedUser.ShouldBeRole == rankedUser.IngameRole) continue;
|
||||||
|
|
||||||
if (embedContent.Last().Length >= 1800)
|
string key = $"{rankedUser.IngameRole} Pending Promotion to {rankedUser.ShouldBeRole}";
|
||||||
embedContent.Add(new StringBuilder());
|
|
||||||
|
|
||||||
embedContent.Last().Append($"{rankedUser.IngameRole} {rankedUser.DisplayName}");
|
if (!promotionLists.TryGetValue(key, out StringBuilder embedContent))
|
||||||
|
{
|
||||||
|
embedContent = new StringBuilder();
|
||||||
|
promotionLists.Add(key, embedContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
embedContent.Append($"{rankedUser.DisplayName}");
|
||||||
if (rankedUser.DiscordId != null)
|
if (rankedUser.DiscordId != null)
|
||||||
embedContent.Last().Append($" [<@{rankedUser.DiscordId}>]");
|
embedContent.Append($"linked to <@{rankedUser.DiscordId}>");
|
||||||
embedContent.Last().AppendLine($" -> {rankedUser.ShouldBeRole}");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LoggingFacade.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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (StringBuilder builder in embedContent)
|
embedContent.AppendLine("No new promotions found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, StringBuilder> promotionList in promotionLists)
|
||||||
{
|
{
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
|
|
||||||
embedBuilder.Title = "Pending Promotions";
|
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());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user