diff --git a/src/cpl_discord/__init__.py b/src/cpl_discord/__init__.py index 42c512c1..e90a8740 100644 --- a/src/cpl_discord/__init__.py +++ b/src/cpl_discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -55,4 +55,4 @@ def get_discord_collection(services: 'ServiceCollectionABC') -> 'DiscordCollecti # build-ignore-end VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/application/__init__.py b/src/cpl_discord/application/__init__.py index 808b1473..83baa89d 100644 --- a/src/cpl_discord/application/__init__.py +++ b/src/cpl_discord/application/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord.application' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -24,4 +24,4 @@ from collections import namedtuple from .discord_bot_application_abc import DiscordBotApplicationABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/command/__init__.py b/src/cpl_discord/command/__init__.py index f65b58ac..fd981837 100644 --- a/src/cpl_discord/command/__init__.py +++ b/src/cpl_discord/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -25,4 +25,4 @@ from .discord_command_abc import DiscordCommandABC from .discord_commands_meta import DiscordCogMeta VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/configuration/__init__.py b/src/cpl_discord/configuration/__init__.py index 6dac6e19..55376cea 100644 --- a/src/cpl_discord/configuration/__init__.py +++ b/src/cpl_discord/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -24,4 +24,4 @@ from collections import namedtuple from .discord_bot_settings import DiscordBotSettings VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/cpl-discord.json b/src/cpl_discord/cpl-discord.json index fc957cbf..3ffa8ef4 100644 --- a/src/cpl_discord/cpl-discord.json +++ b/src/cpl_discord/cpl-discord.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "7", - "Micro": "0.post2" + "Micro": "0.post4" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/src/cpl_discord/discord_event_types_enum.py b/src/cpl_discord/discord_event_types_enum.py index d963435d..342633a0 100644 --- a/src/cpl_discord/discord_event_types_enum.py +++ b/src/cpl_discord/discord_event_types_enum.py @@ -6,6 +6,7 @@ from cpl_discord.events.on_command_completion_abc import OnCommandCompletionABC from cpl_discord.events.on_command_error_abc import OnCommandErrorABC from cpl_discord.events.on_connect_abc import OnConnectABC from cpl_discord.events.on_disconnect_abc import OnDisconnectABC +from cpl_discord.events.on_error_abc import OnErrorABC from cpl_discord.events.on_group_join_abc import OnGroupJoinABC from cpl_discord.events.on_group_remove_abc import OnGroupRemoveABC from cpl_discord.events.on_guild_available_abc import OnGuildAvailableABC @@ -58,6 +59,7 @@ class DiscordEventTypesEnum(Enum): on_command_completion = OnCommandCompletionABC on_connect = OnConnectABC on_disconnect = OnDisconnectABC + on_error = OnErrorABC on_group_join = OnGroupJoinABC on_group_remove = OnGroupRemoveABC on_guild_available = OnGuildAvailableABC diff --git a/src/cpl_discord/events/__init__.py b/src/cpl_discord/events/__init__.py index ca1a16be..84115097 100644 --- a/src/cpl_discord/events/__init__.py +++ b/src/cpl_discord/events/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -72,4 +72,4 @@ from .on_voice_state_update_abc import OnVoiceStateUpdateABC from .on_webhooks_update_abc import OnWebhooksUpdateABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/service/__init__.py b/src/cpl_discord/service/__init__.py index 04d383e8..859fdc57 100644 --- a/src/cpl_discord/service/__init__.py +++ b/src/cpl_discord/service/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_discord.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de' -__version__ = '2022.7.0.post2' +__version__ = '2022.7.0.post4' from collections import namedtuple @@ -29,4 +29,4 @@ from .discord_service import DiscordService from .discord_service_abc import DiscordServiceABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='7', micro='0.post2') +version_info = VersionInfo(major='2022', minor='7', micro='0.post4') diff --git a/src/cpl_discord/service/discord_service.py b/src/cpl_discord/service/discord_service.py index 2e2a01e1..d2dcf0dc 100644 --- a/src/cpl_discord/service/discord_service.py +++ b/src/cpl_discord/service/discord_service.py @@ -16,6 +16,7 @@ from cpl_discord.events.on_command_completion_abc import OnCommandCompletionABC from cpl_discord.events.on_command_error_abc import OnCommandErrorABC from cpl_discord.events.on_connect_abc import OnConnectABC from cpl_discord.events.on_disconnect_abc import OnDisconnectABC +from cpl_discord.events.on_error_abc import OnErrorABC from cpl_discord.events.on_group_join_abc import OnGroupJoinABC from cpl_discord.events.on_group_remove_abc import OnGroupRemoveABC from cpl_discord.events.on_guild_available_abc import OnGuildAvailableABC @@ -76,7 +77,7 @@ class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta): self._collection = dc_collection self._services = services - async def _handle_event(self, event: Type, *args): + async def _handle_event(self, event: Type, *args, **kwargs): event_collection = self._collection.get_events_by_base(event) if event_collection is None: return @@ -92,7 +93,7 @@ class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta): try: func = getattr(event_instance, func_name) - await func(*args) + await func(*args, **kwargs) except Exception as e: self._logger.error(__name__, f'Cannot execute {func_name} of {type(event_instance).__name__}', e) @@ -138,6 +139,11 @@ class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta): self._logger.trace(__name__, f'Received on_disconnect') await self._handle_event(OnDisconnectABC) + @commands.Cog.listener() + async def on_error(self, event: str, *args, **kwargs): + self._logger.trace(__name__, f'Received on_error') + await self._handle_event(OnErrorABC, event, *args, **kwargs) + async def on_ready(self): self._logger.trace(__name__, f'Received on_ready') await self._handle_event(OnReadyABC) diff --git a/src/cpl_discord/service/discord_service_abc.py b/src/cpl_discord/service/discord_service_abc.py index 6d7c48a3..c0911a05 100644 --- a/src/cpl_discord/service/discord_service_abc.py +++ b/src/cpl_discord/service/discord_service_abc.py @@ -29,6 +29,9 @@ class DiscordServiceABC(ABC): @abstractmethod async def on_disconnect(self): pass + @abstractmethod + async def on_error(self, event: str, *args, **kwargs): pass + @abstractmethod async def on_ready(self): pass