Improved event handling with commands.Cog.listener
This commit is contained in:
@@ -8,11 +8,12 @@ from gismo_core.configuration.bot_settings import BotSettings
|
||||
from gismo_core.configuration.discord_settings import DiscordSettings
|
||||
from gismo_core.configuration.server_settings import ServerSettings
|
||||
from modules_core.abc.module_service_abc import ModuleServiceABC
|
||||
from modules_core.service.module_service import ModuleService
|
||||
|
||||
|
||||
class BotService(BotServiceABC, commands.Bot):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleServiceABC, discord_settings: DiscordSettings, bot_settings: BotSettings):
|
||||
def __init__(self, config: ConfigurationABC, logger: LoggerABC, modules: ModuleService, discord_settings: DiscordSettings, bot_settings: BotSettings):
|
||||
# services
|
||||
self._config = config
|
||||
self._logger = logger
|
||||
@@ -27,6 +28,9 @@ class BotService(BotServiceABC, commands.Bot):
|
||||
|
||||
async def start_async(self):
|
||||
self._logger.trace(__name__, 'Try to connect to discord')
|
||||
|
||||
self.add_cog(self._modules)
|
||||
|
||||
await self.start(self._discord_settings.token)
|
||||
# continue at on_ready
|
||||
|
||||
@@ -50,7 +54,3 @@ class BotService(BotServiceABC, commands.Bot):
|
||||
|
||||
|
||||
await self._modules.on_ready()
|
||||
|
||||
async def on_message(self, message: discord.Message):
|
||||
self._logger.debug(__name__, f'Received message:\n{message}:\n{message.content}')
|
||||
await self._modules.on_message(message)
|
||||
|
Reference in New Issue
Block a user