0.3 - Checks in Befehlen als Decorators (#114) #115

Merged
Ebola-Chan merged 7 commits from #114 into 0.3 2022-11-14 21:50:00 +01:00
3 changed files with 14 additions and 5 deletions
Showing only changes of commit 026d989789 - Show all commits

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