Improved module priority handling
This commit is contained in:
parent
f4c340796e
commit
2e24a3b1f2
@ -27,15 +27,10 @@ class BootLog(ModuleABC, OnReadyABC):
|
|||||||
self._bot = bot
|
self._bot = bot
|
||||||
self._message_service = message_service
|
self._message_service = message_service
|
||||||
|
|
||||||
self._priorities = {
|
ModuleABC.__init__(self)
|
||||||
OnReadyABC: 10
|
self._priorities[OnReadyABC] = 10
|
||||||
}
|
|
||||||
|
|
||||||
self._logger.trace(__name__, f'Module {type(self)} loaded')
|
self._logger.trace(__name__, f'Module {type(self)} loaded')
|
||||||
|
|
||||||
def get_priority(self, t: type) -> int:
|
|
||||||
return self._priorities[t]
|
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
self._logger.debug(__name__, f'Module {type(self)} started')
|
self._logger.debug(__name__, f'Module {type(self)} started')
|
||||||
try:
|
try:
|
||||||
|
@ -5,7 +5,10 @@ import discord
|
|||||||
class ModuleABC(ABC):
|
class ModuleABC(ABC):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __init__(self): pass
|
def __init__(self):
|
||||||
|
self._priorities = {}
|
||||||
|
|
||||||
@abstractmethod
|
def get_priority(self, t: type) -> int:
|
||||||
def get_priority(self, t: type) -> int: pass
|
if t not in self._priorities:
|
||||||
|
raise Exception(f'Priority for {t} not found!')
|
||||||
|
return self._priorities[t]
|
||||||
|
Reference in New Issue
Block a user