Fixed can user see element for achievements

This commit is contained in:
Sven Heidemann 2023-08-21 20:06:49 +02:00
parent d364ea1b4c
commit 3ce5471ef4

View File

@ -10,6 +10,7 @@ from bot_api.exception.service_error_code_enum import ServiceErrorCode
from bot_api.exception.service_exception import ServiceException from bot_api.exception.service_exception import ServiceException
from bot_api.route.route import Route from bot_api.route.route import Route
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
from bot_data.model.achievement import Achievement
from bot_data.model.auth_role_enum import AuthRoleEnum from bot_data.model.auth_role_enum import AuthRoleEnum
from bot_data.model.auth_user import AuthUser from bot_data.model.auth_user import AuthUser
from bot_data.model.auto_role import AutoRole from bot_data.model.auto_role import AutoRole
@ -78,7 +79,17 @@ class QueryABC(ObjectType):
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
access = False access = False
if type(element) == AutoRole: if type(element) == Achievement:
element: Achievement = element
for u in user.users:
u: User = u
guild = bot.get_guild(u.server.discord_id)
member = guild.get_member(u.discord_id)
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
access = True
break
elif type(element) == AutoRole:
element: AutoRole = element element: AutoRole = element
for u in user.users: for u in user.users:
u: User = u u: User = u