refactor: rewrite reload system

This commit is contained in:
2024-12-30 14:52:51 -05:00
parent 8985999d6c
commit 6d7b46a7e5
9 changed files with 37 additions and 105 deletions

View File

@@ -1,21 +1,6 @@
import importlib
import inspect
from state import reloaded_modules
from . import bot, tools, utils, voice
from .utils import *
def __reload_module__():
for name, module in globals().items():
if (
inspect.ismodule(module)
and name not in constants.RELOAD_BLACKLISTED_MODULES
):
importlib.reload(module)
if "__reload_module__" in dir(module) and name not in reloaded_modules:
reloaded_modules.add(name)
module.__reload_module__()
globals().update({k: v for k, v in vars(utils).items() if not k.startswith("_")})

View File

@@ -1,12 +1,9 @@
import importlib
import inspect
import time
import arguments
import commands
import constants
import utils
from state import reloaded_modules, start_time
from state import start_time
async def uptime(message):
@@ -28,15 +25,3 @@ async def uptime(message):
await utils.reply(message, f"{round(start_time)}")
else:
await utils.reply(message, f"up {round(time.time() - start_time)} seconds")
def __reload_module__():
for name, module in globals().items():
if (
inspect.ismodule(module)
and name not in constants.RELOAD_BLACKLISTED_MODULES
):
importlib.reload(module)
if "__reload_module__" in dir(module) and name not in reloaded_modules:
reloaded_modules.add(name)
module.__reload_module__()

View File

@@ -1,11 +1,8 @@
import importlib
import inspect
import re
import arguments
import commands
import constants
from state import reloaded_modules
import utils
async def clear(message):
@@ -63,15 +60,3 @@ async def clear(message):
)
except:
pass
def __reload_module__():
for name, module in globals().items():
if (
inspect.ismodule(module)
and name not in constants.RELOAD_BLACKLISTED_MODULES
):
importlib.reload(module)
if "__reload_module__" in dir(module) and name not in reloaded_modules:
reloaded_modules.add(name)
module.__reload_module__()

View File

@@ -1,12 +1,8 @@
import importlib
import inspect
import arguments
import commands
import constants
import utils
import ytdlp
from state import client, playback_queue, reloaded_modules
from state import client, playback_queue
async def queue_or_play(message):
@@ -225,15 +221,3 @@ def generate_queue_list(queue: list):
for i, queued in enumerate(queue)
]
)
def __reload_module__():
for name, module in globals().items():
if (
inspect.ismodule(module)
and name not in constants.RELOAD_BLACKLISTED_MODULES
):
importlib.reload(module)
if "__reload_module__" in dir(module) and name not in reloaded_modules:
reloaded_modules.add(name)
module.__reload_module__()