diff --git a/BOT/botscript.py b/BOT/botscript.py index 6e2d637..ab9c320 100644 --- a/BOT/botscript.py +++ b/BOT/botscript.py @@ -181,6 +181,12 @@ set_bot(bot) # Register bot globally for other modules register_stack_commands(bot) +@bot.tree.error +async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError): + """Fallback slash-command error handler for commands without local handlers.""" + await permission_fail(interaction, error) + + @bot.event async def on_ready(): diff --git a/BOT/utils.py b/BOT/utils.py index 913ffd0..711e1c0 100644 --- a/BOT/utils.py +++ b/BOT/utils.py @@ -528,8 +528,8 @@ def is_blacklisted(): """Return an app-command check that rejects blacklisted users or guilds. Blacklisted users come from the shared BLACKLIST.json (see - ``shared_store.check_user_blacklist``); entries there may be a plain id or - ``[id, reason]``. + ``shared_store.check_user_blacklist``); entries there may include an + internal comment/name and an optional reason. Raises: BlacklistCheckFailure: If the guild or user is blacklisted, @@ -577,6 +577,13 @@ async def permission_fail(interaction: discord.Interaction, error): lang = await guild_lang(interaction.guild_id) if interaction.guild_id else "en" if isinstance(error, BlacklistCheckFailure): reason = error.args[0] if error.args else None + logging.warning( + "Blacklisted command attempt blocked: user_id=%s guild_id=%s command=%s reason=%r", + getattr(interaction.user, "id", None), + interaction.guild_id, + interaction.command.qualified_name if interaction.command else None, + reason, + ) desc = t(lang, "permission.blacklisted_desc") if reason: desc += "\n" + t(lang, "permission.reason_line", reason=reason)