Fixed permission service

This commit is contained in:
Sven Heidemann 2023-03-09 19:27:56 +01:00
parent 21f0f32322
commit 80769a1bf0

View File

@ -1,6 +1,6 @@
import discord import discord
from cpl_core.logging import LoggerABC
from cpl_core.configuration import ConfigurationABC from cpl_core.configuration import ConfigurationABC
from cpl_core.logging import LoggerABC
from cpl_discord.service import DiscordBotServiceABC from cpl_discord.service import DiscordBotServiceABC
from bot_core.configuration.bot_settings import BotSettings from bot_core.configuration.bot_settings import BotSettings
@ -126,14 +126,15 @@ class PermissionService(PermissionServiceABC):
return self._technicians return self._technicians
def is_member_admin(self, member: discord.Member) -> bool: def is_member_admin(self, member: discord.Member) -> bool:
return member.guild.id in self._admins and member in self._admins[member.guild.id] return member is not None and member.guild.id in self._admins and member in self._admins[member.guild.id]
def is_member_moderator(self, member: discord.Member) -> bool: def is_member_moderator(self, member: discord.Member) -> bool:
return ( return (
member.guild.id in self._moderators member is not None
and member.guild.id in self._moderators
and member in self._moderators[member.guild.id] and member in self._moderators[member.guild.id]
or self.is_member_admin(member) or self.is_member_admin(member)
) )
def is_member_technician(self, member: discord.Member) -> bool: def is_member_technician(self, member: discord.Member) -> bool:
return member in self._technicians return member is not None and member in self._technicians