Refactor modal usage and error handling in views

Replaced custom Modal class with BaseModal in embed_builder.py for consistency and maintainability. Updated modal instantiation to use custom_id and improved value handling. Removed redundant on_error methods from help.py, pagination.py, and search.py, and delegated error handling to superclass in controller.py for cleaner error management.
This commit is contained in:
Choco
2025-10-06 15:56:30 +08:00
parent 7f6135801d
commit b503385542
5 changed files with 166 additions and 174 deletions

View File

@@ -484,10 +484,6 @@ class InteractiveController(discord.ui.View):
async def on_error(self, interaction: discord.Interaction, error: Exception, item: discord.ui.Item) -> None:
if isinstance(error, ButtonOnCooldown):
sec = int(error.retry_after)
await interaction.response.send_message(f"You're on cooldown for {sec} second{'' if sec == 1 else 's'}!", ephemeral=True)
return await interaction.response.send_message(f"You're on cooldown for {sec} second{'' if sec == 1 else 's'}!", ephemeral=True)
elif isinstance(error, Exception):
traceback.print_exception(error)
await interaction.response.send_message(error)
return
super().on_error(interaction, error, item)