diff --git a/src/gismo/appsettings.example.json b/src/gismo/appsettings.example.json index c13db34..7bd96f0 100644 --- a/src/gismo/appsettings.example.json +++ b/src/gismo/appsettings.example.json @@ -27,7 +27,9 @@ "MaxVoiceStateHours": 0, "XpPerMessage": 0, "XpPerOntimeHour": 0, - "AFKChannelIds": [] + "AFKChannelIds": [], + "AdminRoleIds": [], + "ModeratorRoleIds": [] } ] } diff --git a/src/gismo_core/configuration/server_settings.py b/src/gismo_core/configuration/server_settings.py index ae21cb0..d9e3402 100644 --- a/src/gismo_core/configuration/server_settings.py +++ b/src/gismo_core/configuration/server_settings.py @@ -14,11 +14,14 @@ class ServerSettings(ConfigurationModelABC): self._login_message_channel_id: int = 0 self._login_message: str = '' self._welcome_message: str = '' + self._welcome_message_for_team: str = '' self._goodbye_message: str = '' self._max_voice_state_hours: int = 0 self._xp_per_message: int = 0 self._xp_per_ontime_hour: int = 0 self._afk_channel_ids: list[int] = [] + self._admin_roles: list[int] = [] + self._moderator_roles: list[int] = [] @property def id(self) -> str: @@ -40,6 +43,10 @@ class ServerSettings(ConfigurationModelABC): def welcome_message(self) -> str: return self._welcome_message + @property + def welcome_message_for_team(self) -> str: + return self._welcome_message_for_team + @property def goodbye_message(self) -> str: return self._goodbye_message @@ -60,6 +67,14 @@ class ServerSettings(ConfigurationModelABC): def afk_channel_ids(self) -> list[int]: return self._afk_channel_ids + @property + def admin_roles(self) -> list[int]: + return self._admin_roles + + @property + def moderator_roles(self) -> list[int]: + return self._moderator_roles + def from_dict(self, settings: dict): try: self._id = int(settings['Id']) @@ -67,12 +82,19 @@ class ServerSettings(ConfigurationModelABC): self._login_message_channel_id = int(settings['LoginMessageChannelId']) self._login_message = settings['LoginMessage'] self._welcome_message = settings['WelcomeMessage'] + self._welcome_message_for_team = settings['WelcomeMessageForTeam'] self._goodbye_message = settings['GoodbyeMessage'] self._max_voice_state_hours = int(settings['MaxVoiceStateHours']) self._xp_per_message = int(settings['XpPerMessage']) self._xp_per_ontime_hour = int(settings['XpPerOntimeHour']) for id in settings['AFKChannelIds']: self._afk_channel_ids.append(int(id)) + + for id in settings['AdminRoleIds']: + self._admin_roles.append(int(id)) + + for id in settings['ModeratorRoleIds']: + self._moderator_roles.append(int(id)) except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') diff --git a/src/modules/base/base.py b/src/modules/base/base.py index 35c53eb..5fd7892 100644 --- a/src/modules/base/base.py +++ b/src/modules/base/base.py @@ -95,6 +95,18 @@ class Base(ModuleABC, OnMemberJoinABC, OnMemberRemoveABC, OnMessageABC, OnVoiceS settings: ServerSettings = self._config.get_configuration(f'DSERVER_{member.guild.id}') await self._messenger.send_dm_message(settings.welcome_message.format(member.guild.name), member) + for roleId in settings.admin_roles: + g: discord.Guild = member.guild + role: discord.Role = g.get_role(roleId) + for admin in role.members: + await self._messenger.send_dm_message(settings.welcome_message_for_team.format(member.name), admin) + + for roleId in settings.moderator_roles: + g: discord.Guild = member.guild + role: discord.Role = g.get_role(roleId) + for mod in role.members: + await self._messenger.send_dm_message(settings.welcome_message_for_team.format(member.name), mod) + try: server = self._servers.get_server_by_discord_id(member.guild.id)