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 9584b34f8f - Show all commits

View File

@ -38,12 +38,14 @@ 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}')
msg = None
try:
await self.delete_message(await channel.send(message))
msg = await channel.send(message)
except Exception as e:
self._logger.error(__name__, f'Send message to channel {channel.id} failed', e)
else:
self._logger.info(__name__, f'Sent message to channel {channel.id}')
await self.delete_message(msg)
async def send_dm_message(self, message: str, receiver: Union[discord.User, discord.Member]):
self._logger.debug(__name__, f'Try to send message {message} to user {receiver.id}')
@ -61,12 +63,14 @@ class MessageService(MessageServiceABC):
return
self._logger.debug(__name__, f'Try to send message {message} to channel {ctx.channel.id}')
msg = None
try:
if isinstance(message, discord.File):
await self.delete_message(await ctx.send(file=message))
msg = await ctx.send(file=message)
else:
await self.delete_message(await ctx.send(message))
msg = 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.info(__name__, f'Sent message to channel {ctx.channel.id}')
await self.delete_message(msg)