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
|
// Loop through every channel and group them by sets of permissions missing
|
||||||
var permissionsMissing = new Dictionary<ulong, List<Channel>>();
|
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))
|
foreach (var channel in await _rest.GetGuildChannels(guild.Id))
|
||||||
{
|
{
|
||||||
var botPermissions = _bot.PermissionsIn(channel.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
|
// If the user can't see this channel, don't calculate permissions for it
|
||||||
// (to prevent info-leaking, mostly)
|
// (to prevent info-leaking, mostly)
|
||||||
// Instead, count how many hidden channels and show the user (so they don't get confused)
|
// Instead, show the user that some channels got ignored (so they don't get confused)
|
||||||
hiddenChannels++;
|
hiddenChannels = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +106,10 @@ namespace PluralKit.Bot
|
|||||||
missingPermissionField |= (ulong) requiredPermission;
|
missingPermissionField |= (ulong) requiredPermission;
|
||||||
|
|
||||||
if ((webhookPermissions & PermissionSet.UseExternalEmojis) == 0)
|
if ((webhookPermissions & PermissionSet.UseExternalEmojis) == 0)
|
||||||
|
{
|
||||||
missingPermissionField |= (ulong) PermissionSet.UseExternalEmojis;
|
missingPermissionField |= (ulong) PermissionSet.UseExternalEmojis;
|
||||||
|
missingEmojiPermissions = true;
|
||||||
|
}
|
||||||
|
|
||||||
// If we're not missing any permissions, don't bother adding it to the dict
|
// 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
|
// 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
|
// so we extract them all and generate a comma-separated list
|
||||||
var missingPermissionNames = ((PermissionSet) missingPermissionField).ToPermissionString();
|
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
|
var channelsList = string.Join("\n", channels
|
||||||
.OrderBy(c => c.Position)
|
.OrderBy(c => c.Position)
|
||||||
.Select(c => $"#{c.Name}"));
|
.Select(c => $"#{c.Name}"));
|
||||||
@ -143,8 +144,17 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hiddenChannels > 0)
|
var footer = "";
|
||||||
eb.Footer(new($"{"channel".ToQuantity(hiddenChannels)} were ignored as you do not have view access to them."));
|
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! :)
|
// Send! :)
|
||||||
await ctx.Reply(embed: eb.Build());
|
await ctx.Reply(embed: eb.Build());
|
||||||
|
Loading…
Reference in New Issue
Block a user