2023.4 #168
@ -1,15 +1,16 @@
|
|||||||
import traceback
|
|
||||||
|
|
||||||
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
from cpl_core.console import Console
|
|
||||||
|
|
||||||
|
|
||||||
class DiscordBotSettings(ConfigurationModelABC):
|
class DiscordBotSettings(ConfigurationModelABC):
|
||||||
def __init__(self):
|
def __init__(
|
||||||
|
self,
|
||||||
|
token: str = None,
|
||||||
|
prefix: str = None,
|
||||||
|
):
|
||||||
ConfigurationModelABC.__init__(self)
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
self._token = ""
|
self._token = token
|
||||||
self._prefix = ""
|
self._prefix = prefix
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def token(self) -> str:
|
def token(self) -> str:
|
||||||
@ -18,11 +19,3 @@ class DiscordBotSettings(ConfigurationModelABC):
|
|||||||
@property
|
@property
|
||||||
def prefix(self) -> str:
|
def prefix(self) -> str:
|
||||||
return self._prefix
|
return self._prefix
|
||||||
|
|
||||||
def from_dict(self, settings: dict):
|
|
||||||
try:
|
|
||||||
self._token = settings["Token"]
|
|
||||||
self._prefix = settings["Prefix"]
|
|
||||||
except Exception as e:
|
|
||||||
Console.error(f"[ ERROR ] [ {__name__} ]: Reading error in {__name__} settings")
|
|
||||||
Console.error(f"[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user