Improved event checks #114

This commit is contained in:
Sven Heidemann 2022-11-13 12:11:01 +01:00
parent d38fa77757
commit 026d989789
3 changed files with 14 additions and 5 deletions

View File

@ -17,6 +17,9 @@ class ClientUtilsServiceABC(ABC):
@abstractmethod
def get_client(self, dc_ic: int, guild_id: int): pass
@abstractmethod
async def check_if_bot_is_ready_yet(self) -> bool: pass
@abstractmethod
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool: pass

View File

@ -22,10 +22,10 @@ class EventChecks:
@classmethod
def check_is_ready(cls):
async def check_if_bot_is_ready_yet_and_respond(ctx: Context) -> bool:
result = await cls._client_utils.check_if_bot_is_ready_yet_and_respond(ctx)
async def check_if_bot_is_ready() -> bool:
result = await cls._client_utils.check_if_bot_is_ready()
if not result:
raise CheckError(f'Bot is not ready')
return result
return commands.check(check_if_bot_is_ready_yet_and_respond)
return commands.check(check_if_bot_is_ready)

View File

@ -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)
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':
return True
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
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):
if not self._feature_flags.get_flag(FeatureFlagsEnum.presence):
return