Renamed some functions & fixed list return context #54
This commit is contained in:
parent
2df4f90802
commit
f2e6be530b
@ -9,19 +9,19 @@
|
||||
"Command": {
|
||||
"Path": "logs/",
|
||||
"Filename": "commands.log",
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"ConsoleLogLevel": "DEBUG",
|
||||
"FileLogLevel": "TRACE"
|
||||
},
|
||||
"Database": {
|
||||
"Path": "logs/",
|
||||
"Filename": "database.log",
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"ConsoleLogLevel": "DEBUG",
|
||||
"FileLogLevel": "TRACE"
|
||||
},
|
||||
"Message": {
|
||||
"Path": "logs/",
|
||||
"Filename": "message.log",
|
||||
"ConsoleLogLevel": "TRACE",
|
||||
"ConsoleLogLevel": "DEBUG",
|
||||
"FileLogLevel": "TRACE"
|
||||
}
|
||||
},
|
||||
|
@ -25,13 +25,10 @@ class AutoRoleRepositoryABC(ABC):
|
||||
def get_auto_roles_by_server_id(self, id: int) -> AutoRole: pass
|
||||
|
||||
@abstractmethod
|
||||
def find_auto_roles_by_server_id(self, id: int) -> Optional[AutoRole]: pass
|
||||
def get_auto_role_by_message_id(self, id: int) -> AutoRole: pass
|
||||
|
||||
@abstractmethod
|
||||
def get_auto_roles_by_message_id(self, id: int) -> AutoRole: pass
|
||||
|
||||
@abstractmethod
|
||||
def find_auto_roles_by_message_id(self, id: int) -> Optional[AutoRole]: pass
|
||||
def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]: pass
|
||||
|
||||
@abstractmethod
|
||||
def add_auto_role(self, auto_role: AutoRole): pass
|
||||
|
@ -59,34 +59,22 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def get_auto_roles_by_server_id(self, id: int) -> AutoRole:
|
||||
def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]:
|
||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_server_id_string(id)}')
|
||||
result = self._context.select(AutoRole.get_select_by_server_id_string(id))[0]
|
||||
return AutoRole(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
id=result[0]
|
||||
)
|
||||
auto_roles = List(AutoRole)
|
||||
results = self._context.select(AutoRole.get_select_by_server_id_string(id))
|
||||
for result in results:
|
||||
auto_roles.append(AutoRole(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
id=result[0]
|
||||
))
|
||||
|
||||
def find_auto_roles_by_server_id(self, id: int) -> Optional[AutoRole]:
|
||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_server_id_string(id)}')
|
||||
result = self._context.select(AutoRole.get_select_by_server_id_string(id))
|
||||
if result is None or len(result) == 0:
|
||||
return None
|
||||
return auto_roles
|
||||
|
||||
result = result[0]
|
||||
|
||||
return AutoRole(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def get_auto_roles_by_message_id(self, id: int) -> AutoRole:
|
||||
def get_auto_role_by_message_id(self, id: int) -> AutoRole:
|
||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
||||
result = self._context.select(AutoRole.get_select_by_message_id_string(id))[0]
|
||||
return AutoRole(
|
||||
@ -97,7 +85,7 @@ class AutoRoleRepositoryService(AutoRoleRepositoryABC):
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def find_auto_roles_by_message_id(self, id: int) -> Optional[AutoRole]:
|
||||
def find_auto_role_by_message_id(self, id: int) -> Optional[AutoRole]:
|
||||
self._logger.trace(__name__, f'Send SQL command: {AutoRole.get_select_by_message_id_string(id)}')
|
||||
result = self._context.select(AutoRole.get_select_by_message_id_string(id))
|
||||
if result is None or len(result) == 0:
|
||||
|
@ -107,7 +107,7 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
self._logger.trace(__name__, f'Finished command auto-role add')
|
||||
return
|
||||
|
||||
if self._auto_roles.find_auto_roles_by_message_id(int(message_id)) is not None:
|
||||
if self._auto_roles.find_auto_role_by_message_id(int(message_id)) is not None:
|
||||
self._logger.debug(__name__, f'auto-role for message {message_id} already exists')
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.add.error.already_exists').format(message_id))
|
||||
self._logger.trace(__name__, f'Finished command auto-role add')
|
||||
|
@ -1,5 +1,4 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events.on_raw_reaction_add_abc import OnRawReactionAddABC
|
||||
from cpl_discord.events.on_raw_reaction_remove_abc import OnRawReactionRemoveABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
Loading…
Reference in New Issue
Block a user