Add command to show current proxy blacklist (#189)

This commit is contained in:
ariel w
2020-07-05 06:54:27 -04:00
committed by GitHub
parent 42b9b4f08e
commit 224b653ee0
2 changed files with 27 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -71,7 +72,28 @@ namespace PluralKit.Bot
$"{Emojis.Success} Message logging for the given channels {(enable ? "enabled" : "disabled")}." +
(logChannel == null ? $"\n{Emojis.Warn} Please note that no logging channel is set, so there is nowhere to log messages to. You can set a logging channel using `pk;log channel #your-log-channel`." : ""));
}
public async Task ShowBlacklisted(Context ctx)
{
ctx.CheckGuildContext().CheckAuthorPermission(Permissions.ManageGuild, "Manage Server");
await using (var conn = await _db.Obtain())
{
var guild = await conn.QueryOrInsertGuildConfig(ctx.Guild.Id);
List<string> blacklist = new List<string>();
foreach (ulong item in guild.Blacklist.ToHashSet()) {
blacklist.Add($"<#{item}>");
}
await ctx.Paginate(blacklist.ToAsyncEnumerable(), blacklist.Count, 25, $"Blacklisted channels for {ctx.Guild.Name}",
async (eb, l) => {
eb.Description += String.Join("\n", l);
});
}
}
public async Task SetBlacklisted(Context ctx, bool shouldAdd)
{
ctx.CheckGuildContext().CheckAuthorPermission(Permissions.ManageGuild, "Manage Server");