fix(discord): implementar botones persistentes para evitar 'Interacción fallida' tras reinicios
This commit is contained in:
@@ -22,6 +22,17 @@ bot = commands.Bot(command_prefix="!", intents=intents)
|
||||
async def on_ready():
|
||||
init_db()
|
||||
load_lang_mappings("discord")
|
||||
|
||||
# Registramos la vista persistente para que los botones funcionen tras reinicios
|
||||
# Primero obtenemos todos los idiomas habilitados globalmente para crear la vista base
|
||||
try:
|
||||
from botdiscord.translate import get_lang_mapping
|
||||
lang_mapping = get_lang_mapping("discord")
|
||||
all_langs = list(lang_mapping.keys())
|
||||
bot.add_view(TranslationView(all_langs))
|
||||
except Exception as e:
|
||||
print(f"Error registrando vista persistente: {e}")
|
||||
|
||||
print(f"Bot Discord conectado como {bot.user}")
|
||||
try:
|
||||
synced = await bot.tree.sync()
|
||||
@@ -100,7 +111,7 @@ async def on_message(message):
|
||||
|
||||
if langs_to_show:
|
||||
print(f"[BOT DEBUG] Creating TranslationView with langs: {langs_to_show}")
|
||||
view = TranslationView(text_to_translate, langs_to_show, message, message.attachments, mentions_map)
|
||||
view = TranslationView(langs_to_show)
|
||||
print(f"[BOT DEBUG] View created, sending message...")
|
||||
try:
|
||||
await message.reply("¿Traducir este mensaje?", view=view, mention_author=False)
|
||||
|
||||
Reference in New Issue
Block a user