A-0.1 - Modularer Aufbau #13

Merged
edraft merged 118 commits from 0.1 into Alpha 2021-11-25 21:02:12 +01:00
Showing only changes of commit 81499ef8e6 - Show all commits

View File

@ -39,8 +39,7 @@ class MessageService(MessageServiceABC):
async def send_channel_message(self, channel: discord.TextChannel, message: str):
self._logger.debug(__name__, f'Try to send message {message} to channel {channel.id}')
try:
msg = await channel.send(message)
await self.delete_message(msg)
await self.delete_message(await channel.send(message))
except Exception as e:
self._logger.error(__name__, f'Send message to channel {channel.id} failed', e)
else:
@ -55,4 +54,19 @@ class MessageService(MessageServiceABC):
else:
self._logger.debug(__name__, f'Send message to user {receiver.id}')
async def send_ctx_msg(self, ctx: Context, message: str, file: discord.File = None): pass
async def send_ctx_msg(self, ctx: Context, message: Union[str, discord.File]):
if ctx is None:
self._logger.warn(__name__, 'Message context is empty')
self._logger.debug(__name__, f'Message: {message}')
return
self._logger.debug(__name__, f'Try to send message {message} to channel {ctx.channel.id}')
try:
if isinstance(message, discord.File):
await self.delete_message(await ctx.send(file=message))
else:
await self.delete_message(await ctx.send(message))
except Exception as e:
self._logger.error(__name__, f'Send message to channel {ctx.channel.id} failed', e)
else:
self._logger.debug(__name__, f'Send message to channel {ctx.channel.id}')