From 666b21a08fdea066d63c2513c9c18c11166a8f28 Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 5 Jul 2020 13:16:21 +0200 Subject: [PATCH] Add category headers to blacklist channels --- PluralKit.Bot/Commands/ServerConfig.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Commands/ServerConfig.cs b/PluralKit.Bot/Commands/ServerConfig.cs index 504bd06c..b21ea868 100644 --- a/PluralKit.Bot/Commands/ServerConfig.cs +++ b/PluralKit.Bot/Commands/ServerConfig.cs @@ -1,6 +1,6 @@ -using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading.Tasks; using DSharpPlus; @@ -95,7 +95,24 @@ namespace PluralKit.Bot $"Blacklisted channels for {ctx.Guild.Name}", (eb, l) => { - eb.Description = string.Join("\n", l.Select(c => c.Mention)); + DiscordChannel lastCategory = null; + + var fieldValue = new StringBuilder(); + foreach (var channel in l) + { + if (lastCategory != channel.Parent && fieldValue.Length > 0) + { + eb.AddField(lastCategory?.Name ?? "(no category)", fieldValue.ToString()); + fieldValue.Clear(); + } + else fieldValue.Append("\n"); + + fieldValue.Append(channel.Mention); + lastCategory = channel.Parent; + } + + eb.AddField(lastCategory?.Name ?? "(no category)", fieldValue.ToString()); + return Task.CompletedTask; }); }