aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-12-01 22:47:25 +0000
committerGravatar Chris Lovering <[email protected]>2021-12-01 22:47:25 +0000
commit8265f206517ef1a35b03120993c8fab4e45bb88d (patch)
treed7004d68643059281292d365f31ac15a6d30b01d
parentSort subscribe roles alphabetically (diff)
Redirect subscribe command output to bot commands
Instead of silently failing in channels other than bot commands for non-staff, the bot now instead redirects the command output to bot commands and pings the user. To facilitate this, I had to change the ctx.reply to a ctx.send since the invocation message may be in a different channel.
-rw-r--r--bot/exts/info/subscribe.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/bot/exts/info/subscribe.py b/bot/exts/info/subscribe.py
index 4797f2347..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)
@@ -172,7 +172,10 @@ class Subscribe(commands.Cog):
@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
@@ -183,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."""