Check if guild is None
All checks were successful
Deploy prod on push / pre-build (push) Successful in 1s
Deploy prod on push / build-bot (push) Successful in 3m4s
Deploy prod on push / build-web (push) Successful in 1m45s
Deploy prod on push / deploy (push) Successful in 22s

This commit is contained in:
Sven Heidemann 2024-02-09 08:48:49 +01:00
parent 521a063fca
commit bb0ff1c560

View File

@ -35,15 +35,22 @@ class AuthUserTransformer(TransformerABC):
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_technician(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) 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) member = guild.get_member(user.discord_id)
if member is None: if member is None:
return permissions.is_member_technician_by_id(user.discord_id) return permissions.is_member_technician_by_id(user.discord_id)
return permissions.is_member_technician(member) return permissions.is_member_technician(member)
@staticmethod @staticmethod
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_admin(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) guild = bot.get_guild(user.server.discord_id)
if guild is None:
return False
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
if member is None: if member is None:
return False return False
@ -53,6 +60,9 @@ class AuthUserTransformer(TransformerABC):
@ServiceProviderABC.inject @ServiceProviderABC.inject
def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC): def _is_moderator(user: User, bot: DiscordBotServiceABC, permissions: PermissionServiceABC):
guild = bot.get_guild(user.server.discord_id) guild = bot.get_guild(user.server.discord_id)
if guild is None:
return False
member = guild.get_member(user.discord_id) member = guild.get_member(user.discord_id)
if member is None: if member is None:
return False return False