Added PyCharm support to permission module

This commit is contained in:
Sven Heidemann 2022-01-08 19:18:06 +01:00
parent 7d4a28d524
commit bc8ff7dc0f
4 changed files with 13 additions and 16 deletions

View File

@ -22,11 +22,11 @@ class PermissionSettings(ConfigurationModelABC):
def from_dict(self, settings: dict):
try:
for id in settings['AdminRoleIds']:
self._admin_roles.append(int(id))
for index in settings['AdminRoleIds']:
self._admin_roles.append(int(index))
for id in settings['ModeratorRoleIds']:
self._moderator_roles.append(int(id))
for index in settings['ModeratorRoleIds']:
self._moderator_roles.append(int(index))
except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -2,11 +2,10 @@ import discord
from cpl_core.logging import LoggerABC
from modules.permission.abc.permission_service_abc import PermissionServiceABC
from modules.permission.configuration.permission_settings import \
PermissionSettings
from gismo_core.abc.events.on_member_update_abc import OnMemberUpdateABC
from gismo_core.abc.events.on_ready_abc import OnReadyABC
from gismo_core.abc.module_abc import ModuleABC
from modules.permission.configuration.permission_settings import PermissionSettings
class Permission(ModuleABC, OnReadyABC, OnMemberUpdateABC):

View File

@ -14,13 +14,13 @@ class PermissionService(PermissionServiceABC):
self._bot = bot
self._config = config
self._admin_role_ids: dict[str, list[int]] = {}
self._admin_roles: dict[list[discord.Role]] = {}
self._admins: dict[list[discord.Member]] = {}
self._admin_role_ids: dict[int, list[int]] = {}
self._admin_roles: dict[int, list[discord.Role]] = {}
self._admins: dict[int, list[discord.Member]] = {}
self._moderator_role_ids: dict[list[int]] = {}
self._moderator_roles: dict[list[discord.Role]] = {}
self._moderators: dict[list[discord.Member]] = {}
self._moderator_role_ids: dict[int, list[int]] = {}
self._moderator_roles: dict[int, list[discord.Role]] = {}
self._moderators: dict[int, list[discord.Member]] = {}
def on_ready(self):
for guild in self._bot.guilds:
@ -60,7 +60,6 @@ class PermissionService(PermissionServiceABC):
mods.append(member)
self._logger.trace(__name__, f'Added moderator {member}')
self._admin_roles[guild.id] = admin_roles
self._admins[guild.id] = admins
self._moderator_roles[guild.id] = mod_roles
@ -87,7 +86,6 @@ class PermissionService(PermissionServiceABC):
self._moderators[g_id].append(after)
self._logger.trace(__name__, f'Added {after.id} to moderators')
def get_admin_role_ids(self, g_id: int) -> list[int]:
return self._admin_role_ids[g_id]