Skip to content

Commit

Permalink
Pull logic for checking if a channel is publically visible out of sta…
Browse files Browse the repository at this point in the history
…rboard
  • Loading branch information
jeremy-rifkin committed Jul 20, 2024
1 parent c56f08a commit e0aaa21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/components/starboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,7 @@ export default class Starboard extends BotComponent {
}

async is_valid_channel(channel: Discord.GuildTextBasedChannel | Discord.TextBasedChannel) {
return (
!this.excluded_channels.has(channel.id) &&
!(channel instanceof Discord.ForumChannel) &&
!channel.isDMBased() &&
!(channel.isThread() && channel.type == Discord.ChannelType.PrivateThread) &&
channel.permissionsFor(this.wheatley.TCCPP.roles.everyone).has("ViewChannel")
);
return !this.excluded_channels.has(channel.id) && this.wheatley.is_public_channel(channel);
}

async update_starboard(message: Discord.Message) {
Expand Down
9 changes: 9 additions & 0 deletions src/wheatley.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,15 @@ export class Wheatley {
M.debug("root_mod_list", [this.root_mod_list]);
}

async is_public_channel(channel: Discord.GuildTextBasedChannel | Discord.TextBasedChannel) {
return (
!(channel instanceof Discord.ForumChannel) &&
!channel.isDMBased() &&
!(channel.isThread() && channel.type == Discord.ChannelType.PrivateThread) &&
channel.permissionsFor(this.TCCPP.roles.everyone).has("ViewChannel")
);
}

// case-insensitive
get_role_by_name(name: string) {
return unwrap(this.TCCPP.roles.cache.find(role => role.name.toLowerCase() === name.toLowerCase()));
Expand Down

0 comments on commit e0aaa21

Please sign in to comment.