diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/constants.py | 7 | ||||
| -rw-r--r-- | bot/exts/info/pep.py | 2 | ||||
| -rw-r--r-- | bot/exts/info/subscribe.py | 21 | ||||
| -rw-r--r-- | bot/exts/recruitment/talentpool/_review.py | 10 | 
4 files changed, 18 insertions, 22 deletions
| diff --git a/bot/constants.py b/bot/constants.py index 3170c2915..078ab6912 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -691,7 +691,7 @@ class VideoPermission(metaclass=YAMLGetter):  class ThreadArchiveTimes(Enum):      HOUR = 60      DAY = 1440 -    THREE_DAY = 4230 +    THREE_DAY = 4320      WEEK = 10080 @@ -699,11 +699,6 @@ class ThreadArchiveTimes(Enum):  DEBUG_MODE: bool = _CONFIG_YAML["debug"] == "true"  FILE_LOGS: bool = _CONFIG_YAML["file_logs"].lower() == "true" -if DEBUG_MODE: -    DEFAULT_THREAD_ARCHIVE_TIME = ThreadArchiveTimes.HOUR.value -else: -    DEFAULT_THREAD_ARCHIVE_TIME = ThreadArchiveTimes.WEEK.value -  # Paths  BOT_DIR = os.path.dirname(__file__)  PROJECT_ROOT = os.path.abspath(os.path.join(BOT_DIR, os.pardir)) diff --git a/bot/exts/info/pep.py b/bot/exts/info/pep.py index 259095b50..8c0db18bc 100644 --- a/bot/exts/info/pep.py +++ b/bot/exts/info/pep.py @@ -16,7 +16,7 @@ log = get_logger(__name__)  ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png"  BASE_PEP_URL = "http://www.python.org/dev/peps/pep-" -PEPS_LISTING_API_URL = "https://api.github.com/repos/python/peps/contents?ref=master" +PEPS_LISTING_API_URL = "https://api.github.com/repos/python/peps/contents?ref=main"  pep_cache = AsyncCache() diff --git a/bot/exts/info/subscribe.py b/bot/exts/info/subscribe.py index 2e6101d27..1299d5d59 100644 --- a/bot/exts/info/subscribe.py +++ b/bot/exts/info/subscribe.py @@ -10,9 +10,9 @@ from discord.interactions import Interaction  from bot import constants  from bot.bot import Bot -from bot.decorators import in_whitelist +from bot.decorators import redirect_output  from bot.log import get_logger -from bot.utils import checks, members, scheduling +from bot.utils import members, scheduling  @dataclass(frozen=True) @@ -165,12 +165,17 @@ class Subscribe(commands.Cog):                      name=discord_role.name,                  )              ) -        # Sort unavailable roles to the end of the list + +        # Sort by role name, then shift unavailable roles to the end of the list +        self.assignable_roles.sort(key=operator.attrgetter("name"))          self.assignable_roles.sort(key=operator.methodcaller("is_currently_available"), reverse=True)      @commands.cooldown(1, 10, commands.BucketType.member)      @commands.command(name="subscribe") -    @in_whitelist(channels=(constants.Channels.bot_commands,)) +    @redirect_output( +        destination_channel=constants.Channels.bot_commands, +        bypass_roles=constants.STAFF_PARTNERS_COMMUNITY_ROLES, +    )      async def subscribe_command(self, ctx: commands.Context, *_) -> None:  # We don't actually care about the args          """Display the member's current state for each role, and allow them to add/remove the roles."""          await self.init_task @@ -181,18 +186,12 @@ class Subscribe(commands.Cog):              row = index // ITEMS_PER_ROW              button_view.add_item(SingleRoleButton(role, role.role_id in author_roles, row)) -        await ctx.reply( +        await ctx.send(              "Click the buttons below to add or remove your roles!",              view=button_view,              delete_after=DELETE_MESSAGE_AFTER,          ) -    # This cannot be static (must have a __func__ attribute). -    async def cog_command_error(self, ctx: commands.Context, error: Exception) -> None: -        """Check for & ignore any InWhitelistCheckFailure.""" -        if isinstance(error, checks.InWhitelistCheckFailure): -            error.handled = True -  def setup(bot: Bot) -> None:      """Load the Subscribe cog.""" diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index 110ac47bc..0e7194892 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -15,7 +15,7 @@ from discord.ext.commands import Context  from bot.api import ResponseCodeError  from bot.bot import Bot -from bot.constants import Channels, Colours, DEFAULT_THREAD_ARCHIVE_TIME, Emojis, Guild, Roles +from bot.constants import Channels, Colours, Emojis, Guild, Roles  from bot.log import get_logger  from bot.utils.members import get_or_fetch_member  from bot.utils.messages import count_unique_users_reaction, pin_no_system_message @@ -96,7 +96,6 @@ class Reviewer:          thread = await last_message.create_thread(              name=f"Nomination - {nominee}", -            auto_archive_duration=DEFAULT_THREAD_ARCHIVE_TIME          )          await thread.send(fr"<@&{Roles.mod_team}> <@&{Roles.admins}>") @@ -218,8 +217,11 @@ class Reviewer:          # Thread channel IDs are the same as the message ID of the parent message.          nomination_thread = message.guild.get_thread(message.id)          if not nomination_thread: -            log.warning(f"Could not find a thread linked to {message.channel.id}-{message.id}") -            return +            try: +                nomination_thread = await message.guild.fetch_channel(message.id) +            except NotFound: +                log.warning(f"Could not find a thread linked to {message.channel.id}-{message.id}") +                return          for message_ in messages:              with contextlib.suppress(NotFound): | 
