Skip to content

Commit 36feabb

Browse files
committed
🌟 feat: Implement getPublicChannels function to filter accessible text channels
1 parent 325ba93 commit 36feabb

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/util/channel.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ChannelType, type Guild, PermissionFlagsBits, type TextChannel } from 'discord.js';
2+
3+
export const getPublicChannels = (guild: Guild) => {
4+
return guild.channels.cache.filter(
5+
(channel): channel is TextChannel =>
6+
channel.type === ChannelType.GuildText &&
7+
channel
8+
.permissionsFor(guild.roles.everyone)
9+
?.has(
10+
PermissionFlagsBits.ViewChannel |
11+
PermissionFlagsBits.ReadMessageHistory |
12+
PermissionFlagsBits.SendMessages
13+
)
14+
);
15+
};

0 commit comments

Comments
 (0)