diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index 3d42e5f9..0045caa1 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -60,6 +60,7 @@ namespace PluralKit.Bot public static Command LogEnable = new Command("log enable", "log enable all| [channel 2] [channel 3...]", "Enables message logging in certain channels"); public static Command LogDisable = new Command("log disable", "log disable all| [channel 2] [channel 3...]", "Disables message logging in certain channels"); public static Command LogClean = new Command("logclean", "logclean [on|off]", "Toggles whether to clean up other bots' log channels"); + public static Command BlacklistShow = new Command("blacklist show", "blacklist show", "Displays the current proxy blacklist"); public static Command BlacklistAdd = new Command("blacklist add", "blacklist add all| [channel 2] [channel 3...]", "Adds certain channels to the proxy blacklist"); public static Command BlacklistRemove = new Command("blacklist remove", "blacklist remove all| [channel 2] [channel 3...]", "Removes certain channels from the proxy blacklist"); public static Command Invite = new Command("invite", "invite", "Gets a link to invite PluralKit to other servers"); @@ -142,7 +143,9 @@ namespace PluralKit.Bot return ctx.Execute(BlacklistAdd, m => m.SetBlacklisted(ctx, true)); else if (ctx.Match("disable", "off", "remove", "allow")) return ctx.Execute(BlacklistRemove, m => m.SetBlacklisted(ctx, false)); - else return PrintCommandExpectedError(ctx, BlacklistAdd, BlacklistRemove); + else if (ctx.Match("list", "show")) + return ctx.Execute(BlacklistShow, m => m.ShowBlacklisted(ctx)); + else return PrintCommandExpectedError(ctx, BlacklistAdd, BlacklistRemove, BlacklistShow); if (ctx.Match("proxy", "enable", "disable")) return ctx.Execute(SystemProxy, m => m.SystemProxy(ctx)); if (ctx.Match("invite")) return ctx.Execute(Invite, m => m.Invite(ctx)); diff --git a/PluralKit.Bot/Commands/ServerConfig.cs b/PluralKit.Bot/Commands/ServerConfig.cs index 9dd29d22..b4f6d9bb 100644 --- a/PluralKit.Bot/Commands/ServerConfig.cs +++ b/PluralKit.Bot/Commands/ServerConfig.cs @@ -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 blacklist = new List(); + + 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");