Updated DiscordBotSettings

This commit is contained in:
Sven Heidemann 2023-04-05 18:11:16 +02:00
parent fe9918af16
commit 6751541269

View File

@ -1,15 +1,16 @@
import traceback
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
from cpl_core.console import Console
class DiscordBotSettings(ConfigurationModelABC):
def __init__(self):
def __init__(
self,
token: str = None,
prefix: str = None,
):
ConfigurationModelABC.__init__(self)
self._token = ""
self._prefix = ""
self._token = token
self._prefix = prefix
@property
def token(self) -> str:
@ -18,11 +19,3 @@ class DiscordBotSettings(ConfigurationModelABC):
@property
def prefix(self) -> str:
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()}")