mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Add category headers to blacklist channels
This commit is contained in:
parent
da9bfbb46d
commit
666b21a08f
1 changed files with 19 additions and 2 deletions
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue