tweak: don't expose hidden channel count in pk;permcheck
This commit is contained in:
parent
c7fcf60fbf
commit
82544cf9ce
@ -80,7 +80,8 @@ namespace PluralKit.Bot
|
||||
|
||||
// Loop through every channel and group them by sets of permissions missing
|
||||
var permissionsMissing = new Dictionary<ulong, List<Channel>>();
|
||||
var hiddenChannels = 0;
|
||||
var hiddenChannels = false;
|
||||
var missingEmojiPermissions = false;
|
||||
foreach (var channel in await _rest.GetGuildChannels(guild.Id))
|
||||
{
|
||||
var botPermissions = _bot.PermissionsIn(channel.Id);
|
||||
@ -91,8 +92,8 @@ namespace PluralKit.Bot
|
||||
{
|
||||
// If the user can't see this channel, don't calculate permissions for it
|
||||
// (to prevent info-leaking, mostly)
|
||||
// Instead, count how many hidden channels and show the user (so they don't get confused)
|
||||
hiddenChannels++;
|
||||
// Instead, show the user that some channels got ignored (so they don't get confused)
|
||||
hiddenChannels = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -103,9 +104,12 @@ namespace PluralKit.Bot
|
||||
foreach (var requiredPermission in requiredPermissions)
|
||||
if ((botPermissions & requiredPermission) == 0)
|
||||
missingPermissionField |= (ulong) requiredPermission;
|
||||
|
||||
|
||||
if ((webhookPermissions & PermissionSet.UseExternalEmojis) == 0)
|
||||
{
|
||||
missingPermissionField |= (ulong) PermissionSet.UseExternalEmojis;
|
||||
missingEmojiPermissions = true;
|
||||
}
|
||||
|
||||
// If we're not missing any permissions, don't bother adding it to the dict
|
||||
// This means we can check if the dict is empty to see if all channels are proxyable
|
||||
@ -132,9 +136,6 @@ namespace PluralKit.Bot
|
||||
// so we extract them all and generate a comma-separated list
|
||||
var missingPermissionNames = ((PermissionSet) missingPermissionField).ToPermissionString();
|
||||
|
||||
if (missingPermissionField == (ulong) PermissionSet.UseExternalEmojis)
|
||||
eb.Footer(new($"Use External Emojis permissions must be granted to the @everyone role / Default Permissions."));
|
||||
|
||||
var channelsList = string.Join("\n", channels
|
||||
.OrderBy(c => c.Position)
|
||||
.Select(c => $"#{c.Name}"));
|
||||
@ -143,9 +144,18 @@ namespace PluralKit.Bot
|
||||
}
|
||||
}
|
||||
|
||||
if (hiddenChannels > 0)
|
||||
eb.Footer(new($"{"channel".ToQuantity(hiddenChannels)} were ignored as you do not have view access to them."));
|
||||
var footer = "";
|
||||
if (hiddenChannels)
|
||||
footer += "Some channels were ignored as you do not have view access to them.";
|
||||
if (missingEmojiPermissions)
|
||||
{
|
||||
if (hiddenChannels) footer += " | ";
|
||||
footer += "Use External Emojis permissions must be granted to the @everyone role / Default Permissions.";
|
||||
}
|
||||
|
||||
if (footer.Length > 0)
|
||||
eb.Footer(new(footer));
|
||||
|
||||
// Send! :)
|
||||
await ctx.Reply(embed: eb.Build());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user