Fix: Recarga en caliente para canales y solución a caché estancado en MySQL
This commit is contained in:
@@ -5,9 +5,10 @@ import time
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext import commands, tasks
|
||||
from discord import app_commands
|
||||
import re
|
||||
from botdiscord.reload_marker import check_reload_marker
|
||||
import html
|
||||
|
||||
from botdiscord.config import get_discord_token, load_config, get_languages
|
||||
@@ -22,6 +23,17 @@ intents.message_content = True
|
||||
intents.members = True
|
||||
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||
|
||||
@tasks.loop(seconds=3)
|
||||
async def restart_monitor():
|
||||
if check_reload_marker():
|
||||
print("[Bot] Cambios desde panel detectados. Recargando configuraciones sin reiniciar...")
|
||||
from botdiscord.database import clear_channel_cache
|
||||
from botdiscord.translate import load_lang_mappings
|
||||
from botdiscord.config import load_config
|
||||
clear_channel_cache()
|
||||
load_config()
|
||||
load_lang_mappings("discord")
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
init_db()
|
||||
@@ -30,12 +42,15 @@ async def on_ready():
|
||||
bot.add_view(PersistentTranslationView())
|
||||
bot.add_view(WelcomeTranslationView())
|
||||
|
||||
if not restart_monitor.is_running():
|
||||
restart_monitor.start()
|
||||
|
||||
print(f"Bot Discord conectado como {bot.user}")
|
||||
try:
|
||||
synced = await bot.tree.sync()
|
||||
print(f"Sincronizados {len(synced)} comandos.")
|
||||
except Exception as e:
|
||||
print(f"Error sync: {e}")
|
||||
# try:
|
||||
# synced = await bot.tree.sync()
|
||||
# print(f"Sincronizados {len(synced)} comandos.")
|
||||
# except Exception as e:
|
||||
# print(f"Error sync: {e}")
|
||||
|
||||
@bot.event
|
||||
async def on_member_join(member):
|
||||
|
||||
Reference in New Issue
Block a user