From bb0ff1c5602885e782c73d0032f99d886b296d78 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 9 Feb 2024 08:48:49 +0100 Subject: [PATCH] Check if guild is None --- bot/src/bot_api/transformer/auth_user_transformer.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bot/src/bot_api/transformer/auth_user_transformer.py b/bot/src/bot_api/transformer/auth_user_transformer.py index 5188aee9..26f9f36a 100644 --- a/bot/src/bot_api/transformer/auth_user_transformer.py +++ b/bot/src/bot_api/transformer/auth_user_transformer.py @@ -35,15 +35,22 @@ class AuthUserTransformer(TransformerABC): @ServiceProviderABC.inject def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) + if guild is None: + return permissions.is_member_technician_by_id(user.discord_id) + member = guild.get_member(user.discord_id) if member is None: return permissions.is_member_technician_by_id(user.discord_id) + return permissions.is_member_technician(member) @staticmethod @ServiceProviderABC.inject def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) + if guild is None: + return False + member = guild.get_member(user.discord_id) if member is None: return False @@ -53,6 +60,9 @@ class AuthUserTransformer(TransformerABC): @ServiceProviderABC.inject def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): guild = bot.get_guild(user.server.discord_id) + if guild is None: + return False + member = guild.get_member(user.discord_id) if member is None: return False