diff options
| author | 2021-11-05 09:03:07 +0100 | |
|---|---|---|
| committer | 2021-11-05 09:03:07 +0100 | |
| commit | 5da7bdfeba938a91f4476057219aea473db44bcc (patch) | |
| tree | 6673751149e8fa99f854694a6da64928af24a81b | |
| parent | Add sql-fstring tag (diff) | |
Unpin all messages when help channel goes dormant
| -rw-r--r-- | bot/exts/help_channels/_caches.py | 4 | ||||
| -rw-r--r-- | bot/exts/help_channels/_message.py | 10 | 
2 files changed, 3 insertions, 11 deletions
| diff --git a/bot/exts/help_channels/_caches.py b/bot/exts/help_channels/_caches.py index 8d45c2466..937c4ab57 100644 --- a/bot/exts/help_channels/_caches.py +++ b/bot/exts/help_channels/_caches.py @@ -17,10 +17,6 @@ claimant_last_message_times = RedisCache(namespace="HelpChannels.claimant_last_m  # RedisCache[discord.TextChannel.id, UtcPosixTimestamp]  non_claimant_last_message_times = RedisCache(namespace="HelpChannels.non_claimant_last_message_times") -# This cache maps a help channel to original question message in same channel. -# RedisCache[discord.TextChannel.id, discord.Message.id] -question_messages = RedisCache(namespace="HelpChannels.question_messages") -  # This cache keeps track of the dynamic message ID for  # the continuously updated message in the #How-to-get-help channel.  dynamic_message = RedisCache(namespace="HelpChannels.dynamic_message") diff --git a/bot/exts/help_channels/_message.py b/bot/exts/help_channels/_message.py index 241dd606c..cb8aa2d1a 100644 --- a/bot/exts/help_channels/_message.py +++ b/bot/exts/help_channels/_message.py @@ -174,8 +174,7 @@ async def notify(channel: discord.TextChannel, last_notification: t.Optional[Arr  async def pin(message: discord.Message) -> None:      """Pin an initial question `message` and store it in a cache.""" -    if await pin_wrapper(message.id, message.channel, pin=True): -        await _caches.question_messages.set(message.channel.id, message.id) +    await pin_wrapper(message.id, message.channel, pin=True)  async def send_available_message(channel: discord.TextChannel) -> None: @@ -201,11 +200,8 @@ async def send_available_message(channel: discord.TextChannel) -> None:  async def unpin(channel: discord.TextChannel) -> None:      """Unpin the initial question message sent in `channel`.""" -    msg_id = await _caches.question_messages.pop(channel.id) -    if msg_id is None: -        log.debug(f"#{channel} ({channel.id}) doesn't have a message pinned.") -    else: -        await pin_wrapper(msg_id, channel, pin=False) +    for message in await channel.pins(): +        await pin_wrapper(message.id, channel, pin=False)  def _match_bot_embed(message: t.Optional[discord.Message], description: str) -> bool: | 
