From 9201cbf35713e0b7e59861d7195170dde9c0b3a8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 18 Apr 2023 20:33:59 +0200 Subject: [PATCH] Fixed bug that mods cannot see auto role rules --- kdb-bot/src/bot_graphql/abc/query_abc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kdb-bot/src/bot_graphql/abc/query_abc.py b/kdb-bot/src/bot_graphql/abc/query_abc.py index 9c8f3ef1..a0435218 100644 --- a/kdb-bot/src/bot_graphql/abc/query_abc.py +++ b/kdb-bot/src/bot_graphql/abc/query_abc.py @@ -2,6 +2,7 @@ from typing import Callable from ariadne import ObjectType from cpl_core.dependency_injection import ServiceProviderABC +from cpl_core.type import T from cpl_discord.service import DiscordBotServiceABC from cpl_query.extension import List @@ -66,7 +67,7 @@ class QueryABC(ObjectType): self.set_field(f"{name}Count", lambda *args: wrapper(*args).count()) @ServiceProviderABC.inject - def _can_user_see_element(self, user: AuthUser, element, services: ServiceProviderABC) -> bool: + def _can_user_see_element(self, user: AuthUser, element: T, services: ServiceProviderABC) -> bool: permissions: PermissionService = services.get_service(PermissionService) bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC) @@ -82,12 +83,12 @@ class QueryABC(ObjectType): break elif type(element) == AutoRoleRule: - element: AutoRole = element + element: AutoRoleRule = 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: + if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id: access = True break -- 2.45.2