Improved event checks #114
This commit is contained in:
parent
d38fa77757
commit
026d989789
@ -17,6 +17,9 @@ class ClientUtilsServiceABC(ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_client(self, dc_ic: int, guild_id: int): pass
|
def get_client(self, dc_ic: int, guild_id: int): pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def check_if_bot_is_ready_yet(self) -> bool: pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool: pass
|
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool: pass
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ class EventChecks:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_is_ready(cls):
|
def check_is_ready(cls):
|
||||||
async def check_if_bot_is_ready_yet_and_respond(ctx: Context) -> bool:
|
async def check_if_bot_is_ready() -> bool:
|
||||||
result = await cls._client_utils.check_if_bot_is_ready_yet_and_respond(ctx)
|
result = await cls._client_utils.check_if_bot_is_ready()
|
||||||
if not result:
|
if not result:
|
||||||
raise CheckError(f'Bot is not ready')
|
raise CheckError(f'Bot is not ready')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
return commands.check(check_if_bot_is_ready_yet_and_respond)
|
return commands.check(check_if_bot_is_ready)
|
||||||
|
@ -59,14 +59,20 @@ class ClientUtilsService(ClientUtilsServiceABC):
|
|||||||
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
|
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool:
|
async def check_if_bot_is_ready_yet(self) -> bool:
|
||||||
if self._config.get_configuration('IS_READY') == 'true':
|
if self._config.get_configuration('IS_READY') == 'true':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
self._logger.debug(__name__, f'Bot is not ready yet {self._t.transform("common.errors.bot_not_ready_yet")}')
|
self._logger.debug(__name__, f'Bot is not ready yet {self._t.transform("common.errors.bot_not_ready_yet")}')
|
||||||
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.errors.bot_not_ready_yet'), without_tracking=True)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool:
|
||||||
|
result = await self.check_if_bot_is_ready_yet()
|
||||||
|
if result:
|
||||||
|
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.errors.bot_not_ready_yet'), without_tracking=True)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
async def presence_game(self, t_key: str):
|
async def presence_game(self, t_key: str):
|
||||||
if not self._feature_flags.get_flag(FeatureFlagsEnum.presence):
|
if not self._feature_flags.get_flag(FeatureFlagsEnum.presence):
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user