Added PyCharm support to permission module
This commit is contained in:
parent
7d4a28d524
commit
bc8ff7dc0f
0
src/modules/permission/configuration/__init__.py
Normal file
0
src/modules/permission/configuration/__init__.py
Normal 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()}')
|
||||
|
@ -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):
|
||||
@ -21,7 +20,7 @@ class Permission(ModuleABC, OnReadyABC, OnMemberUpdateABC):
|
||||
|
||||
ModuleABC.__init__(
|
||||
self,
|
||||
{ OnReadyABC: 1, OnMemberUpdateABC: 0 },
|
||||
{OnReadyABC: 1, OnMemberUpdateABC: 0},
|
||||
PermissionSettings
|
||||
)
|
||||
self._logger.info(__name__, f'Module {type(self)} loaded')
|
||||
|
@ -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:
|
||||
@ -59,7 +59,6 @@ class PermissionService(PermissionServiceABC):
|
||||
for member in role.members:
|
||||
mods.append(member)
|
||||
self._logger.trace(__name__, f'Added moderator {member}')
|
||||
|
||||
|
||||
self._admin_roles[guild.id] = admin_roles
|
||||
self._admins[guild.id] = admins
|
||||
@ -70,7 +69,7 @@ class PermissionService(PermissionServiceABC):
|
||||
g_id = after.guild.id
|
||||
|
||||
for admin_role in self._admin_roles[g_id]:
|
||||
if admin_role in before.roles and admin_role not in after.roles:
|
||||
if admin_role in before.roles and admin_role not in after.roles:
|
||||
self._admins[g_id].remove(after)
|
||||
self._logger.trace(__name__, f'Removed {after.id} from admins')
|
||||
|
||||
@ -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]
|
||||
|
||||
|
Reference in New Issue
Block a user