add support for allowed_mentions with message edit

This commit is contained in:
StarrFox 2020-05-07 09:06:25 -05:00 committed by Rapptz
parent fbb7add01a
commit 6e8d538f09

View File

@ -800,6 +800,10 @@ class Message:
If provided, the number of seconds to wait in the background
before deleting the message we just edited. If the deletion fails,
then it is silently ignored.
allowed_mentions: Optional[:class:`~discord.AllowedMentions`]
Controls the mentions being processed in this message.
.. versionadded:: 1.4
Raises
-------
@ -837,6 +841,18 @@ class Message:
delete_after = fields.pop('delete_after', None)
try:
allowed_mentions = fields.pop('allowed_mentions')
except KeyError:
pass
else:
if allowed_mentions is not None:
if self._state.allowed_mentions is not None:
allowed_mentions = self._state.allowed_mentions.merge(allowed_mentions).to_dict()
else:
allowed_mentions = allowed_mentions.to_dict()
fields['allowed_mentions'] = allowed_mentions
if fields:
data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
self._update(data)