storage: better fix for message.webhook_id

the old fix only works for the return value in message create, where as
it should be in Storage.get_message instead so that the bug doesn't
happen to the other routes
This commit is contained in:
Luna 2019-03-05 16:30:38 -03:00
parent 67ae2385b5
commit 7b4aaabcbf
2 changed files with 2 additions and 4 deletions

View File

@ -408,9 +408,6 @@ async def _create_message(channel_id):
await _dm_pre_dispatch(channel_id, user_id) await _dm_pre_dispatch(channel_id, user_id)
await _dm_pre_dispatch(channel_id, guild_id) await _dm_pre_dispatch(channel_id, guild_id)
if payload['webhook_id'] == None:
payload.pop('webhook_id', None)
await app.dispatcher.dispatch('channel', channel_id, await app.dispatcher.dispatch('channel', channel_id,
'MESSAGE_CREATE', payload) 'MESSAGE_CREATE', payload)

View File

@ -763,12 +763,13 @@ class Storage:
return res return res
async def _inject_author(self, res): async def _inject_author(self, res: dict):
"""Inject a pseudo-user object when the message is made by a webhook.""" """Inject a pseudo-user object when the message is made by a webhook."""
author_id, webhook_id = res['author_id'], res['webhook_id'] author_id, webhook_id = res['author_id'], res['webhook_id']
if author_id is not None: if author_id is not None:
res['author'] = await self.get_user(res['author_id']) res['author'] = await self.get_user(res['author_id'])
res.pop('webhook_id')
elif webhook_id is not None: elif webhook_id is not None:
res['author'] = { res['author'] = {
'id': webhook_id, 'id': webhook_id,