0.3 - Levelsystem (#25) #92

Merged
edraft merged 15 commits from #25 into 0.3 2022-11-07 22:15:37 +01:00
2 changed files with 8 additions and 2 deletions
Showing only changes of commit 3d27295b14 - Show all commits

View File

@ -149,6 +149,9 @@
"boot_log": {
"login_message": "Ich bin on the line :D\nDer Scheiß hat {} Sekunden gedauert"
},
"level": {
"new_level_message": "<@{}> ist nun Level {}"
},
"database": {},
"permission": {
}

View File

@ -6,6 +6,7 @@ from cpl_core.database.context import DatabaseContextABC
from cpl_core.logging import LoggerABC
from cpl_discord.container import Guild, Role, Member
from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe
from bot_core.service.message_service import MessageService
from bot_data.model.level import Level
@ -27,7 +28,8 @@ class LevelService:
users: UserRepositoryService,
servers: ServerRepositoryService,
bot: DiscordBotServiceABC,
message_service: MessageService
message_service: MessageService,
t: TranslatePipe
):
self._config = config
self._logger = logger
@ -37,6 +39,7 @@ class LevelService:
self._servers = servers
self._bot = bot
self._message_service = message_service
self._t = t
def get_level(self, user: User) -> Level:
levels = self._levels.get_levels_by_server_id(user.server.server_id).order_by(lambda l: l.min_xp)
@ -73,7 +76,7 @@ class LevelService:
level_settings: LevelServerSettings = self._config.get_configuration(f'LevelServerSettings_{guild.id}')
await self._message_service.send_channel_message(
self._bot.get_channel(level_settings.changed_level_notification_channel),
f'<@{member.id}> ist nun Level {level.name}',
self._t.transform('modules.level.new_level_message'.format(member.id, level.name)),
is_persistent=True
)