From 7ff8b2c9ebc27194835c25258bc90c623bdbec6b Mon Sep 17 00:00:00 2001 From: kosayoda Date: Tue, 14 Jul 2020 10:51:56 +0800 Subject: Allow ordering watched users by oldest first --- bot/cogs/watchchannels/watchchannel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot/cogs/watchchannels/watchchannel.py b/bot/cogs/watchchannels/watchchannel.py index 7c58a0fb5..2992a3085 100644 --- a/bot/cogs/watchchannels/watchchannel.py +++ b/bot/cogs/watchchannels/watchchannel.py @@ -287,7 +287,9 @@ class WatchChannel(metaclass=CogABCMeta): await self.webhook_send(embed=embed, username=msg.author.display_name, avatar_url=msg.author.avatar_url) - async def list_watched_users(self, ctx: Context, update_cache: bool = True) -> None: + async def list_watched_users( + self, ctx: Context, oldest_first: bool = False, update_cache: bool = True + ) -> None: """ Gives an overview of the watched user list for this channel. @@ -305,7 +307,11 @@ class WatchChannel(metaclass=CogABCMeta): time_delta = self._get_time_delta(inserted_at) lines.append(f"• <@{user_id}> (added {time_delta})") + if oldest_first: + lines.reverse() + lines = lines or ("There's nothing here yet.",) + embed = Embed( title=f"{self.__class__.__name__} watched users ({'updated' if update_cache else 'cached'})", color=Color.blue() -- cgit v1.2.3 From a6f66611b17aab8fbc3c54377c3971faeac5073b Mon Sep 17 00:00:00 2001 From: kosayoda Date: Tue, 14 Jul 2020 10:52:33 +0800 Subject: Pass argument as kwarg to preserve functionality --- bot/cogs/watchchannels/bigbrother.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py index 702d371f4..fc899281b 100644 --- a/bot/cogs/watchchannels/bigbrother.py +++ b/bot/cogs/watchchannels/bigbrother.py @@ -42,7 +42,7 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): The optional kwarg `update_cache` can be used to update the user cache using the API before listing the users. """ - await self.list_watched_users(ctx, update_cache) + await self.list_watched_users(ctx, update_cache=update_cache) @bigbrother_group.command(name='watch', aliases=('w',)) @with_role(*MODERATION_ROLES) -- cgit v1.2.3 From ac7ed93eb64884a622c8718c8594aa74a3b2b201 Mon Sep 17 00:00:00 2001 From: kosayoda Date: Tue, 14 Jul 2020 10:58:02 +0800 Subject: Accept argument to order nominees by oldest first --- bot/cogs/watchchannels/talentpool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py index 33550f68e..1f5989f23 100644 --- a/bot/cogs/watchchannels/talentpool.py +++ b/bot/cogs/watchchannels/talentpool.py @@ -38,14 +38,18 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): @nomination_group.command(name='watched', aliases=('all', 'list')) @with_role(*MODERATION_ROLES) - async def watched_command(self, ctx: Context, update_cache: bool = True) -> None: + async def watched_command( + self, ctx: Context, oldest_first: bool = False, update_cache: bool = True + ) -> None: """ Shows the users that are currently being monitored in the talent pool. + The optional kwarg `oldest_first` can be used to order the list by oldest nomination. + The optional kwarg `update_cache` can be used to update the user cache using the API before listing the users. """ - await self.list_watched_users(ctx, update_cache) + await self.list_watched_users(ctx, oldest_first=oldest_first, update_cache=update_cache) @nomination_group.command(name='watch', aliases=('w', 'add', 'a')) @with_role(*STAFF_ROLES) -- cgit v1.2.3 From 01d2803b608407330959ef880bd562456921d0fd Mon Sep 17 00:00:00 2001 From: kosayoda Date: Tue, 14 Jul 2020 10:58:56 +0800 Subject: Add command to list nominees by oldest first --- bot/cogs/watchchannels/talentpool.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bot/cogs/watchchannels/talentpool.py b/bot/cogs/watchchannels/talentpool.py index 1f5989f23..89256e92e 100644 --- a/bot/cogs/watchchannels/talentpool.py +++ b/bot/cogs/watchchannels/talentpool.py @@ -51,6 +51,17 @@ class TalentPool(WatchChannel, Cog, name="Talentpool"): """ await self.list_watched_users(ctx, oldest_first=oldest_first, update_cache=update_cache) + @nomination_group.command(name='oldest') + @with_role(*MODERATION_ROLES) + async def oldest_command(self, ctx: Context, update_cache: bool = True) -> None: + """ + Shows talent pool monitored users ordered by oldest nomination. + + The optional kwarg `update_cache` can be used to update the user + cache using the API before listing the users. + """ + await ctx.invoke(self.watched_command, oldest_first=True, update_cache=update_cache) + @nomination_group.command(name='watch', aliases=('w', 'add', 'a')) @with_role(*STAFF_ROLES) async def watch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None: -- cgit v1.2.3 From 28fe47d5d2404cdc70eaabe3e6c41567b9fd7c3d Mon Sep 17 00:00:00 2001 From: kosayoda Date: Tue, 14 Jul 2020 11:55:00 +0800 Subject: Achieve feature parity with talentpool --- bot/cogs/watchchannels/bigbrother.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py index fc899281b..4d27a6333 100644 --- a/bot/cogs/watchchannels/bigbrother.py +++ b/bot/cogs/watchchannels/bigbrother.py @@ -35,14 +35,29 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): @bigbrother_group.command(name='watched', aliases=('all', 'list')) @with_role(*MODERATION_ROLES) - async def watched_command(self, ctx: Context, update_cache: bool = True) -> None: + async def watched_command( + self, ctx: Context, oldest_first: bool = False, update_cache: bool = True + ) -> None: """ Shows the users that are currently being monitored by Big Brother. + The optional kwarg `oldest_first` can be used to order the list by oldest watched. + + The optional kwarg `update_cache` can be used to update the user + cache using the API before listing the users. + """ + await self.list_watched_users(ctx, oldest_first=oldest_first, update_cache=update_cache) + + @bigbrother_group.command(name='oldest') + @with_role(*MODERATION_ROLES) + async def oldest_command(self, ctx: Context, update_cache: bool = True) -> None: + """ + Shows Big Brother monitored users ordered by oldest watched. + The optional kwarg `update_cache` can be used to update the user cache using the API before listing the users. """ - await self.list_watched_users(ctx, update_cache=update_cache) + await ctx.invoke(self.watched_command, oldest_first=True, update_cache=update_cache) @bigbrother_group.command(name='watch', aliases=('w',)) @with_role(*MODERATION_ROLES) -- cgit v1.2.3 From 867b561a6ce4aff85451d00794c22e02793c8dac Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Tue, 14 Jul 2020 17:07:35 -0700 Subject: Suppress NotFound when removing help cmd reactions The message may be deleted somehow before the wait_for times out. Fixes #1050 Fixes BOT-6X --- bot/cogs/help.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bot/cogs/help.py b/bot/cogs/help.py index 832f6ea6b..70e62d590 100644 --- a/bot/cogs/help.py +++ b/bot/cogs/help.py @@ -36,13 +36,12 @@ async def help_cleanup(bot: Bot, author: Member, message: Message) -> None: await message.add_reaction(DELETE_EMOJI) - try: - await bot.wait_for("reaction_add", check=check, timeout=300) - await message.delete() - except TimeoutError: - await message.remove_reaction(DELETE_EMOJI, bot.user) - except NotFound: - pass + with suppress(NotFound): + try: + await bot.wait_for("reaction_add", check=check, timeout=300) + await message.delete() + except TimeoutError: + await message.remove_reaction(DELETE_EMOJI, bot.user) class HelpQueryNotFound(ValueError): -- cgit v1.2.3 From 992f3c47d328821bcf647df7683fd5ca8bd780aa Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Tue, 14 Jul 2020 18:20:52 -0700 Subject: HelpChannels: remove cooldown info from available message Users can no longer see available channels if they're on cooldown. They will instead see a special "cooldown" channel which will explain what's going on. --- bot/cogs/help_channels.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 4d0c534b0..0c8cbb417 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -34,9 +34,6 @@ and will be yours until it has been inactive for {constants.HelpChannels.idle_mi is closed manually with `!close`. When that happens, it will be set to **dormant** and moved into \ the **Help: Dormant** category. -You may claim a new channel once every {constants.HelpChannels.claim_minutes} minutes. If you \ -currently cannot send a message in this channel, it means you are on cooldown and need to wait. - Try to write the best question you can by providing a detailed description and telling us what \ you've tried already. For more information on asking a good question, \ check out our guide on [asking good questions]({ASKING_GUIDE_URL}). -- cgit v1.2.3 From e46385d656129e06dd267764811d10ef5e8cd5a2 Mon Sep 17 00:00:00 2001 From: kosayoda Date: Wed, 15 Jul 2020 11:06:03 +0800 Subject: Document new kwarg in docstring --- bot/cogs/watchchannels/watchchannel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot/cogs/watchchannels/watchchannel.py b/bot/cogs/watchchannels/watchchannel.py index 2992a3085..044077350 100644 --- a/bot/cogs/watchchannels/watchchannel.py +++ b/bot/cogs/watchchannels/watchchannel.py @@ -293,6 +293,8 @@ class WatchChannel(metaclass=CogABCMeta): """ Gives an overview of the watched user list for this channel. + The optional kwarg `oldest_first` orders the list by oldest entry. + The optional kwarg `update_cache` specifies whether the cache should be refreshed by polling the API. """ -- cgit v1.2.3