Added logic to send context messages
This commit is contained in:
parent
b0b646bb2b
commit
81499ef8e6
@ -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}')
|
||||
|
Reference in New Issue
Block a user