import traceback from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC from cpl_core.console import Console from gismo_core.configuration.embed_description_settings import EmbedDescriptionSettings class BaseSettings(ConfigurationModelABC): def __init__(self): ConfigurationModelABC.__init__(self) 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._purge_message: str = '' self._no_permissions_message: str = '' self._afk_command_channel_id: int = 0 self._afk_command_channel_missing_message: str = '' self._afk_command_move_message: str = '' self._help_command_reference_url: str = '' self._info_command_message: EmbedDescriptionSettings = EmbedDescriptionSettings() self._user_info_command_message: EmbedDescriptionSettings = EmbedDescriptionSettings() @property 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 @property def max_voice_state_hours(self) -> int: return self._max_voice_state_hours @property def xp_per_message(self) -> int: return self._xp_per_message @property def xp_per_ontime_hour(self) -> int: return self._xp_per_ontime_hour @property def afk_channel_ids(self) -> list[int]: return self._afk_channel_ids @property def purge_message(self) -> str: return self._purge_message @property def no_permissions_message(self) -> str: return self._no_permissions_message @property def afk_command_channel_id(self) -> int: return self._afk_command_channel_id @property def afk_command_channel_missing_message(self) -> str: return self._afk_command_channel_missing_message @property def afk_command_move_message(self) -> str: return self._afk_command_move_message @property def help_command_reference_url(self) -> str: return self._help_command_reference_url @property def info_command_message(self) -> EmbedDescriptionSettings: return self._info_command_message @property def user_info_command_message(self) -> EmbedDescriptionSettings: return self._user_info_command_message def from_dict(self, settings: dict): try: 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 index in settings['AFKChannelIds']: self._afk_channel_ids.append(int(index)) self._purge_message = settings['PurgeMessage'] self._no_permissions_message = settings['NoPermissionsMessage'] self._afk_command_channel_id = settings['AFKCommandChannelId'] self._afk_command_channel_missing_message = settings['AFKCommandChannelMissingMessage'] self._afk_command_move_message = settings['AFKCommandMoveMessage'] self._help_command_reference_url = settings['HelpCommandReferenceUrl'] self._info_command_message.from_dict(settings['InfoCommandMessage']) self._user_info_command_message.from_dict(settings['UserInfoCommandMessage']) except Exception as e: Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {__name__} settings') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')