feat: better private channel detection, bot version debugging (#7680)
Signed-off-by: The-Best-Codes <106822363+The-Best-Codes@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import type { Guild, TextChannel } from "discord.js";
|
||||
import { ChannelType } from "discord.js";
|
||||
import { ChannelType, PermissionFlagsBits } from "discord.js";
|
||||
|
||||
function isPublicChannel(ch: TextChannel, guild: Guild): boolean {
|
||||
const everyoneOverwrite = ch.permissionOverwrites.cache.get(guild.id);
|
||||
return !everyoneOverwrite?.deny.has(PermissionFlagsBits.ViewChannel);
|
||||
}
|
||||
|
||||
export async function buildServerContext(guild: Guild): Promise<string> {
|
||||
try {
|
||||
@@ -8,7 +13,9 @@ export async function buildServerContext(guild: Guild): Promise<string> {
|
||||
const textChannels = Array.from(channels.values())
|
||||
.filter(
|
||||
(ch): ch is TextChannel =>
|
||||
ch?.type === ChannelType.GuildText && ch !== null && ch.viewable,
|
||||
ch?.type === ChannelType.GuildText &&
|
||||
ch !== null &&
|
||||
isPublicChannel(ch, guild),
|
||||
)
|
||||
.sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user