Improved formatting #166

This commit is contained in:
Sven Heidemann 2023-01-12 07:20:00 +01:00
parent b80958e3ab
commit 3cf0fe3479
3 changed files with 38 additions and 18 deletions

View File

@ -84,8 +84,11 @@ class ClientUtilsService(ClientUtilsServiceABC):
async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool: async def check_if_bot_is_ready_yet_and_respond(self, ctx: Context) -> bool:
result = await self.check_if_bot_is_ready_yet() result = await self.check_if_bot_is_ready_yet()
if not result: if not result:
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.errors.bot_not_ready_yet'), await self._message_service.send_ctx_msg(
without_tracking=True) ctx,
self._t.transform('common.errors.bot_not_ready_yet'),
without_tracking=True
)
return result return result

View File

@ -166,8 +166,10 @@ class UserGroup(DiscordCommandABC):
)) ))
else: else:
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
'modules.base.user.error.atr_not_found').format(atr)) ctx.interaction,
self._t.transform('modules.base.user.error.atr_not_found').format(atr)
)
return return
await self._message_service.send_interaction_msg( await self._message_service.send_interaction_msg(
@ -194,16 +196,19 @@ class UserGroup(DiscordCommandABC):
if atr == 'xp': if atr == 'xp':
if not value.isnumeric(): if not value.isnumeric():
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
'modules.base.user.set.error.value_type_not_numeric')) ctx.interaction, self._t.transform('modules.base.user.set.error.value_type_not_numeric')
)
return return
try: try:
user.xp = int(value) user.xp = int(value)
except TypeError as te: except TypeError as te:
self._logger.error(__name__, f'String value couldn\'t be converted to int', te) self._logger.error(__name__, f'String value couldn\'t be converted to int', te)
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
'modules.base.user.set.error.type_error')) ctx.interaction,
self._t.transform('modules.base.user.set.error.type_error')
)
return return
else: else:
self._users.update_user(user) self._users.update_user(user)
@ -211,12 +216,16 @@ class UserGroup(DiscordCommandABC):
await self._level.check_level(member) await self._level.check_level(member)
else: else:
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
'modules.base.user.error.atr_not_found').format(atr)) ctx.interaction,
self._t.transform('modules.base.user.error.atr_not_found').format(atr)
)
return return
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
f'modules.base.user.set.{atr.lower()}').format(member.mention, value)) ctx.interaction,
self._t.transform(f'modules.base.user.set.{atr.lower()}').format(member.mention, value)
)
@set.autocomplete('atr') @set.autocomplete('atr')
async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: async def set_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
@ -247,8 +256,10 @@ class UserGroup(DiscordCommandABC):
self._db.save_changes() self._db.save_changes()
else: else:
await self._message_service.send_interaction_msg(ctx.interaction, self._t.transform( await self._message_service.send_interaction_msg(
'modules.base.user.error.atr_not_found').format(atr)) ctx.interaction,
self._t.transform('modules.base.user.error.atr_not_found').format(atr)
)
return return
await self._message_service.send_interaction_msg( await self._message_service.send_interaction_msg(
@ -258,5 +269,6 @@ class UserGroup(DiscordCommandABC):
@remove.autocomplete('atr') @remove.autocomplete('atr')
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> List[ async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> List[
app_commands.Choice[str]]: app_commands.Choice[str]
]:
return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list] return [app_commands.Choice(name=value, value=key) for key, value in self._atr_list]

View File

@ -83,13 +83,18 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
self._users.update_user(user) self._users.update_user(user)
self._db.save_changes() self._db.save_changes()
self._logger.debug(__name__, f'User {user} leaved_on {join.leaved_on}. Ontime: {ontime}h | xp: from {old_xp} to {user.xp}') self._logger.debug(__name__,
f'User {user} leaved_on {join.leaved_on}. Ontime: {ontime}h | xp: from {old_xp} to {user.xp}')
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Ontime validation failed', e) self._logger.error(__name__, f'Ontime validation failed', e)
@EventChecks.check_is_ready() @EventChecks.check_is_ready()
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, async def on_voice_state_update(
after: discord.VoiceState): self,
member: discord.Member,
before: discord.VoiceState,
after: discord.VoiceState
):
self._logger.debug(__name__, f'Module {type(self)} started') self._logger.debug(__name__, f'Module {type(self)} started')
self._logger.trace(__name__, f'Detected on_voice_state_update {member.id} from {before} to {after}') self._logger.trace(__name__, f'Detected on_voice_state_update {member.id} from {before} to {after}')
settings: BaseServerSettings = self._base_helper.get_config(member.guild.id) settings: BaseServerSettings = self._base_helper.get_config(member.guild.id)