diff --git a/PluralKit.Bot/Commands/ServerConfig.cs b/PluralKit.Bot/Commands/ServerConfig.cs index fd6c7298..504bd06c 100644 --- a/PluralKit.Bot/Commands/ServerConfig.cs +++ b/PluralKit.Bot/Commands/ServerConfig.cs @@ -77,22 +77,27 @@ namespace PluralKit.Bot { ctx.CheckGuildContext().CheckAuthorPermission(Permissions.ManageGuild, "Manage Server"); - await using (var conn = await _db.Obtain()) + var blacklist = await _db.Execute(c => c.QueryOrInsertGuildConfig(ctx.Guild.Id)); + + // Resolve all channels from the cache and order by position + var channels = blacklist.Blacklist + .Select(id => ctx.Guild.GetChannel(id)) + .OrderBy(c => c.Position) + .ToList(); + + if (channels.Count == 0) { - 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}", - (eb, l) => { - eb.Description += string.Join("\n", l); - return Task.CompletedTask; - }); - + await ctx.Reply($"This server has no blacklisted channels."); + return; } + + await ctx.Paginate(channels.ToAsyncEnumerable(), channels.Count, 25, + $"Blacklisted channels for {ctx.Guild.Name}", + (eb, l) => + { + eb.Description = string.Join("\n", l.Select(c => c.Mention)); + return Task.CompletedTask; + }); } public async Task SetBlacklisted(Context ctx, bool shouldAdd)