utility.guildinfo: hopefully fix permissions check for hidden channels

This commit is contained in:
Cynthia Foxwell 2023-11-19 17:13:42 -07:00
parent cfdc862535
commit 43fac0f1de

View file

@ -1786,7 +1786,6 @@ guildinfo.callback = async function (msg, line) {
switch (_guild.source) {
case "local": {
const roles = Array.from(guild.roles.values());
const defaultRole = roles.find((role) => role.name == "@everyone");
const channelTypeCounts = {};
let nsfwChannels = 0;
@ -1798,14 +1797,19 @@ guildinfo.callback = async function (msg, line) {
if (channel.nsfw) nsfwChannels++;
const defaultPermissions = channel.permissionOverwrites.get(
defaultRole.id
);
let defaultPermissions = channel.permissionOverwrites.get(guild.id);
if (!defaultPermissions && channel.parentID) {
defaultPermissions = guild.channels
.get(channel.parentID)
.permissionOverwrites.get(guild.id);
}
if (
defaultPermissions &&
(channel instanceof VoiceChannel
? !defaultPermissions.has(Constants.Permissions.voiceConnect)
: !defaultPermissions.has(Constants.Permissions.viewChannel))
? (defaultPermissions.deny & Constants.Permissions.voiceConnect) ===
Constants.Permissions.voiceConnect
: (defaultPermissions.deny & Constants.Permissions.viewChannel) ===
Constants.Permissions.viewChannel)
) {
hiddenChannels++;
}