2222from bot .exts .advent_of_code import _helpers
2323from bot .exts .advent_of_code .views .dayandstarview import AoCDropdownView
2424from bot .utils import members
25- from bot .utils .decorators import InChannelCheckFailure , in_month , whitelist_override , with_role
25+ from bot .utils .decorators import in_month , in_whitelist , with_role
2626
2727log = logging .getLogger (__name__ )
2828
3434# They aren't spammy and foster discussion
3535AOC_WHITELIST = AOC_WHITELIST_RESTRICTED + (Channels .advent_of_code ,)
3636
37+ AOC_REDIRECT = (Channels .advent_of_code_commands , Channels .sir_lancebot_playground , Channels .bot_commands )
38+
3739
3840class AdventOfCode (commands .Cog ):
3941 """Advent of Code festivities! Ho Ho Ho!"""
@@ -133,7 +135,7 @@ async def adventofcode_group(self, ctx: commands.Context) -> None:
133135 if not ctx .invoked_subcommand :
134136 await self .bot .invoke_help_command (ctx )
135137
136- @with_role (Roles .admins )
138+ @with_role (Roles .admins , fail_silently = True )
137139 @adventofcode_group .command (
138140 name = "block" ,
139141 brief = "Block a user from getting the completionist role." ,
@@ -148,7 +150,7 @@ async def block_from_role(self, ctx: commands.Context, member: discord.Member) -
148150 await ctx .send (f":+1: Blocked { member .mention } from getting the AoC completionist role." )
149151
150152 @adventofcode_group .command (name = "countdown" , aliases = ("count" , "c" ), brief = "Return time left until next day" )
151- @whitelist_override (channels = AOC_WHITELIST )
153+ @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
152154 async def aoc_countdown (self , ctx : commands .Context ) -> None :
153155 """Return time left until next day."""
154156 if _helpers .is_in_advent ():
@@ -167,13 +169,13 @@ async def aoc_countdown(self, ctx: commands.Context) -> None:
167169 )
168170
169171 @adventofcode_group .command (name = "about" , aliases = ("ab" , "info" ), brief = "Learn about Advent of Code" )
170- @whitelist_override (channels = AOC_WHITELIST )
172+ @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
171173 async def about_aoc (self , ctx : commands .Context ) -> None :
172174 """Respond with an explanation of all things Advent of Code."""
173175 await ctx .send (embed = self .cached_about_aoc )
174176
175177 @aoc_slash_group .command (name = "join" , description = "Get the join code for our community Advent of Code leaderboard" )
176- @whitelist_override (channels = AOC_WHITELIST )
178+ @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
177179 @app_commands .guild_only ()
178180 async def join_leaderboard (self , interaction : discord .Interaction ) -> None :
179181 """Send the user an ephemeral message with the information for joining the Python Discord leaderboard."""
@@ -229,7 +231,7 @@ async def join_leaderboard(self, interaction: discord.Interaction) -> None:
229231 aliases = ("connect" ,),
230232 brief = "Tie your Discord account with your Advent of Code name."
231233 )
232- @whitelist_override (channels = AOC_WHITELIST )
234+ @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
233235 async def aoc_link_account (self , ctx : commands .Context , * , aoc_name : str | None = None ) -> None :
234236 """
235237 Link your Discord Account to your Advent of Code name.
@@ -282,7 +284,7 @@ async def aoc_link_account(self, ctx: commands.Context, *, aoc_name: str | None
282284 aliases = ("disconnect" ,),
283285 brief = "Untie your Discord account from your Advent of Code name."
284286 )
285- @whitelist_override (channels = AOC_WHITELIST )
287+ @in_whitelist (channels = AOC_WHITELIST , redirect = AOC_REDIRECT )
286288 async def aoc_unlink_account (self , ctx : commands .Context ) -> None :
287289 """
288290 Unlink your Discord ID with your Advent of Code leaderboard name.
@@ -303,7 +305,7 @@ async def aoc_unlink_account(self, ctx: commands.Context) -> None:
303305 aliases = ("daynstar" , "daystar" ),
304306 brief = "Get a view that lets you filter the leaderboard by day and star" ,
305307 )
306- @whitelist_override (channels = AOC_WHITELIST_RESTRICTED )
308+ @in_whitelist (channels = AOC_WHITELIST_RESTRICTED , redirect = AOC_REDIRECT )
307309 async def aoc_day_and_star_leaderboard (
308310 self ,
309311 ctx : commands .Context ,
@@ -341,7 +343,7 @@ async def aoc_day_and_star_leaderboard(
341343 aliases = ("board" , "lb" ),
342344 brief = "Get a snapshot of the PyDis private AoC leaderboard" ,
343345 )
344- @whitelist_override (channels = AOC_WHITELIST_RESTRICTED )
346+ @in_whitelist (channels = AOC_WHITELIST_RESTRICTED , redirect = AOC_REDIRECT )
345347 async def aoc_leaderboard (self , ctx : commands .Context , * , aoc_name : str | None = None ) -> None :
346348 """
347349 Get the current top scorers of the Python Discord Leaderboard.
@@ -375,7 +377,7 @@ async def aoc_leaderboard(self, ctx: commands.Context, *, aoc_name: str | None =
375377 table = (
376378 "```\n "
377379 f"{ leaderboard ['placement_leaderboard' ] if aoc_name else leaderboard ['top_leaderboard' ]} "
378- "\n ```"
380+ "\n ```"
379381 )
380382 info_embed = _helpers .get_summary_embed (leaderboard )
381383
@@ -388,7 +390,7 @@ async def aoc_leaderboard(self, ctx: commands.Context, *, aoc_name: str | None =
388390 aliases = ("globalboard" , "gb" ),
389391 brief = "Get a link to the global leaderboard" ,
390392 )
391- @whitelist_override (channels = AOC_WHITELIST_RESTRICTED )
393+ @in_whitelist (channels = AOC_WHITELIST_RESTRICTED , redirect = AOC_REDIRECT )
392394 async def aoc_global_leaderboard (self , ctx : commands .Context ) -> None :
393395 """Get a link to the global Advent of Code leaderboard."""
394396 url = self .global_leaderboard_url
@@ -404,7 +406,7 @@ async def aoc_global_leaderboard(self, ctx: commands.Context) -> None:
404406 aliases = ("dailystats" , "ds" ),
405407 brief = "Get daily statistics for the Python Discord leaderboard"
406408 )
407- @whitelist_override (channels = AOC_WHITELIST_RESTRICTED )
409+ @in_whitelist (channels = AOC_WHITELIST_RESTRICTED , redirect = AOC_REDIRECT )
408410 async def private_leaderboard_daily_stats (self , ctx : commands .Context ) -> None :
409411 """Send an embed with daily completion statistics for the Python Discord leaderboard."""
410412 try :
@@ -429,7 +431,7 @@ async def private_leaderboard_daily_stats(self, ctx: commands.Context) -> None:
429431 info_embed = _helpers .get_summary_embed (leaderboard )
430432 await ctx .send (f"```\n { table } \n ```" , embed = info_embed )
431433
432- @with_role (Roles .admins )
434+ @with_role (Roles .admins , fail_silently = True )
433435 @adventofcode_group .command (
434436 name = "refresh" ,
435437 aliases = ("fetch" ,),
@@ -473,9 +475,3 @@ def _build_about_embed(self) -> discord.Embed:
473475
474476 about_embed .set_footer (text = "Last Updated" )
475477 return about_embed
476-
477- async def cog_command_error (self , ctx : commands .Context , error : Exception ) -> None :
478- """Custom error handler if an advent of code command was posted in the wrong channel."""
479- if isinstance (error , InChannelCheckFailure ):
480- await ctx .send (f":x: Please use <#{ Channels .advent_of_code_commands } > for aoc commands instead." )
481- error .handled = True
0 commit comments