diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/fun/duck_pond.py | 17 | 
1 files changed, 16 insertions, 1 deletions
diff --git a/bot/exts/fun/duck_pond.py b/bot/exts/fun/duck_pond.py index 48aa2749c..43be0dd83 100644 --- a/bot/exts/fun/duck_pond.py +++ b/bot/exts/fun/duck_pond.py @@ -3,7 +3,7 @@ import logging  from typing import Union  import discord -from discord import Color, Embed, Member, Message, RawReactionActionEvent, User, errors +from discord import Color, Embed, Member, Message, RawReactionActionEvent, TextChannel, User, errors  from discord.ext.commands import Cog, Context, command  from bot import constants @@ -44,6 +44,17 @@ class DuckPond(Cog):                      return True          return False +    @staticmethod +    def is_helper_viewable(channel: TextChannel) -> bool: +        """Check if helpers can view a specific channel.""" +        guild = channel.guild +        helper_role = guild.get_role(constants.Roles.helpers) +        # check channel overwrites for both the Helper role and @everyone and +        # return True for channels that they have explicit permissions to view. +        helper_overwrites = channel.overwrites_for(helper_role) +        default_overwrites = channel.overwrites_for(guild.default_role) +        return default_overwrites.view_channel or helper_overwrites.view_channel +      async def has_green_checkmark(self, message: Message) -> bool:          """Check if the message has a green checkmark reaction."""          for reaction in message.reactions: @@ -165,6 +176,10 @@ class DuckPond(Cog):          message = await channel.fetch_message(payload.message_id)          member = discord.utils.get(message.guild.members, id=payload.user_id) +        # Was the message sent in a channel Helpers can see? +        if not self.is_helper_viewable(channel): +            return +          # Was the message sent by a human staff member?          if not self.is_staff(message.author) or message.author.bot:              return  |