Fixed problems since merge #28

This commit is contained in:
Sven Heidemann 2022-11-09 08:51:08 +01:00
parent 57d59e91ac
commit eaae058754
2 changed files with 9 additions and 5 deletions

View File

@ -202,7 +202,7 @@
"down": { "down": {
"already_first": "{} hat bereits das erste Level.", "already_first": "{} hat bereits das erste Level.",
"success": "{} wurde auf Level {} runtergesetzt :)", "success": "{} wurde auf Level {} runtergesetzt :)",
"failed": "{} konnte nicht runtergesetzt werden :(" "failed": "{} konnte nicht runtergesetzt werden :(",
"created": "Level {} mit Berechtigungen {} wurde erstellt." "created": "Level {} mit Berechtigungen {} wurde erstellt."
} }
}, },

View File

@ -3,6 +3,7 @@ from typing import List as TList
import discord import discord
from cpl_core.database.context import DatabaseContextABC from cpl_core.database.context import DatabaseContextABC
from cpl_discord.command import DiscordCommandABC from cpl_discord.command import DiscordCommandABC
from cpl_discord.container import Guild, Role
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from cpl_translation import TranslatePipe from cpl_translation import TranslatePipe
from discord import app_commands from discord import app_commands
@ -14,6 +15,7 @@ from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.logging.command_logger import CommandLogger from bot_core.logging.command_logger import CommandLogger
from bot_data.abc.level_repository_abc import LevelRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.abc.user_repository_abc import UserRepositoryABC
from bot_data.model.level import Level from bot_data.model.level import Level
from modules.level.level_seeder import LevelSeeder from modules.level.level_seeder import LevelSeeder
from modules.level.service.level_service import LevelService from modules.level.service.level_service import LevelService
@ -30,9 +32,10 @@ class LevelGroup(DiscordCommandABC):
client_utils: ClientUtilsServiceABC, client_utils: ClientUtilsServiceABC,
permission_service: PermissionServiceABC, permission_service: PermissionServiceABC,
translate: TranslatePipe, translate: TranslatePipe,
db_context: DatabaseContextABC, db: DatabaseContextABC,
levels: LevelRepositoryABC, levels: LevelRepositoryABC,
servers: ServerRepositoryABC, servers: ServerRepositoryABC,
users: UserRepositoryABC,
level_service: LevelService, level_service: LevelService,
level_seeder: LevelSeeder, level_seeder: LevelSeeder,
): ):
@ -44,9 +47,10 @@ class LevelGroup(DiscordCommandABC):
self._client_utils = client_utils self._client_utils = client_utils
self._permissions = permission_service self._permissions = permission_service
self._t = translate self._t = translate
self._db_context = db_context self._db = db
self._levels = levels self._levels = levels
self._servers = servers self._servers = servers
self._users = users
self._level_service = level_service self._level_service = level_service
self._level_seeder = level_seeder self._level_seeder = level_seeder
@ -136,7 +140,7 @@ class LevelGroup(DiscordCommandABC):
else: else:
try: try:
self._levels.add_level(level) self._levels.add_level(level)
self._db_context.save_changes() self._db.save_changes()
self._logger.info(__name__, f'Saved level {name} with color {color}, min_xp {min_xp} and permissions {permissions}') self._logger.info(__name__, f'Saved level {name} with color {color}, min_xp {min_xp} and permissions {permissions}')
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Could not save level {name} with color {color}, min_xp {min_xp} and permissions {permissions}', e) self._logger.error(__name__, f'Could not save level {name} with color {color}, min_xp {min_xp} and permissions {permissions}', e)
@ -211,7 +215,7 @@ class LevelGroup(DiscordCommandABC):
try: try:
self._levels.delete_level(level_from_db) self._levels.delete_level(level_from_db)
self._db_context.save_changes() self._db.save_changes()
guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single() guild: Guild = self._bot.guilds.where(lambda g: g == ctx.guild).single()
role: Role = guild.roles.where(lambda r: r.name == level).single_or_default() role: Role = guild.roles.where(lambda r: r.name == level).single_or_default()
if role is not None: if role is not None: