From 481b335f2d3adeef15d003d65966846c60c93b04 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 4 Apr 2020 12:45:17 -0400 Subject: [PATCH] Fix various implementation bugs with allowed mentions --- discord/abc.py | 2 ++ discord/client.py | 2 +- discord/webhook.py | 14 ++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index b4a07791c..7ce7224f8 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -838,6 +838,8 @@ class Messageable(metaclass=abc.ABCMeta): mentions = state.mentions.merge(mentions).to_dict() else: mentions = mentions.to_dict() + else: + mentions = state.mentions and state.mentions.to_dict() if file is not None and files is not None: raise InvalidArgument('cannot pass both file and files parameter to send()') diff --git a/discord/client.py b/discord/client.py index bbc323d6a..9a673f79f 100644 --- a/discord/client.py +++ b/discord/client.py @@ -149,7 +149,7 @@ class Client: A status to start your presence with upon logging on to Discord. activity: Optional[:class:`.BaseActivity`] An activity to start your presence with upon logging on to Discord. - mention: Optional[:class:`AllowedMentions`] + mentions: Optional[:class:`AllowedMentions`] Control how the client handles mentions by default on every message sent. .. versionadded:: 1.4 diff --git a/discord/webhook.py b/discord/webhook.py index 058e48553..3218f2abc 100644 --- a/discord/webhook.py +++ b/discord/webhook.py @@ -781,13 +781,15 @@ class Webhook: if username: payload['username'] = username + previous_mentions = getattr(self._state, 'mentions', None) + if mentions: - try: - mentions = self._state.mentions.merge(mentions).to_dict() - except AttributeError: - mentions = mentions.to_dict() - finally: - payload['allowed_mentions'] = mentions + if previous_mentions is not None: + payload['allowed_mentions'] = previous_mentions.merge(mentions).to_dict() + else: + payload['allowed_mentions'] = mentions.to_dict() + elif previous_mentions is not None: + payload['allowed_mentions'] = previous_mentions.to_dict() return self._adapter.execute_webhook(wait=wait, file=file, files=files, payload=payload)