Skip to content

Commit 29f2754

Browse files
committed
compress errors
1 parent 2f4e2e3 commit 29f2754

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

bot/cogs/config.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,6 @@ async def set_guild_settings(
429429
command_type = "Toggled" if config_type == ConfigType.TOGGLE else "Set"
430430
await ctx.send(f"{command_type} `{key}` from `{original_value}` to `{value}`")
431431

432-
async def _handle_config_error(
433-
self, error: commands.CommandError, ctx: GuildContext
434-
) -> None:
435-
if isinstance(error, commands.BadArgument):
436-
await ctx.send(str(error))
437-
438432
### Blocklist utilities
439433

440434
async def can_be_blocked(self, ctx: GuildContext, entity: discord.Member) -> bool:
@@ -470,11 +464,13 @@ def clean_prefixes(self, prefixes: Union[str, list[str]]) -> str:
470464

471465
### Misc Utilities
472466
async def _handle_error(
473-
self, ctx: GuildContext, error: commands.CommandError
467+
self, error: commands.CommandError, *, ctx: GuildContext
474468
) -> None:
475469
if isinstance(error, commands.CommandOnCooldown):
476470
embed = CooldownEmbed(error.retry_after)
477471
await ctx.send(embed=embed)
472+
elif isinstance(error, commands.BadArgument):
473+
await ctx.send(str(error))
478474

479475
@check_permissions(manage_guild=True)
480476
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
@@ -707,13 +703,13 @@ async def delete(self, ctx: GuildContext) -> None:
707703
async def on_setup_error(
708704
self, ctx: GuildContext, error: commands.CommandError
709705
) -> None:
710-
await self._handle_error(ctx, error)
706+
await self._handle_error(error, ctx=ctx)
711707

712708
@delete.error
713709
async def on_delete_error(
714710
self, ctx: GuildContext, error: commands.CommandError
715711
) -> None:
716-
await self._handle_error(ctx, error)
712+
await self._handle_error(error, ctx=ctx)
717713

718714
@check_permissions(manage_guild=True)
719715
@commands.guild_only()
@@ -836,19 +832,19 @@ async def config_toggle(
836832
async def on_config_set_age_error(
837833
self, ctx: GuildContext, error: commands.CommandError
838834
):
839-
await self._handle_config_error(error, ctx)
835+
await self._handle_error(error, ctx=ctx)
840836

841837
@config_set.error
842838
async def on_config_set_error(
843839
self, ctx: GuildContext, error: commands.CommandError
844840
):
845-
await self._handle_config_error(error, ctx)
841+
await self._handle_error(error, ctx=ctx)
846842

847843
@config_toggle.error
848844
async def on_config_toggle_error(
849845
self, ctx: GuildContext, error: commands.CommandError
850846
):
851-
await self._handle_config_error(error, ctx)
847+
await self._handle_error(error, ctx=ctx)
852848

853849
@check_permissions(manage_guild=True)
854850
@commands.guild_only()

0 commit comments

Comments
 (0)