Browse Source

Fix various implementation bugs with allowed mentions

pull/2634/head
Rapptz 5 years ago
parent
commit
481b335f2d
  1. 2
      discord/abc.py
  2. 2
      discord/client.py
  3. 14
      discord/webhook.py

2
discord/abc.py

@ -838,6 +838,8 @@ class Messageable(metaclass=abc.ABCMeta):
mentions = state.mentions.merge(mentions).to_dict() mentions = state.mentions.merge(mentions).to_dict()
else: else:
mentions = mentions.to_dict() mentions = mentions.to_dict()
else:
mentions = state.mentions and state.mentions.to_dict()
if file is not None and files is not None: if file is not None and files is not None:
raise InvalidArgument('cannot pass both file and files parameter to send()') raise InvalidArgument('cannot pass both file and files parameter to send()')

2
discord/client.py

@ -149,7 +149,7 @@ class Client:
A status to start your presence with upon logging on to Discord. A status to start your presence with upon logging on to Discord.
activity: Optional[:class:`.BaseActivity`] activity: Optional[:class:`.BaseActivity`]
An activity to start your presence with upon logging on to Discord. 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. Control how the client handles mentions by default on every message sent.
.. versionadded:: 1.4 .. versionadded:: 1.4

14
discord/webhook.py

@ -781,13 +781,15 @@ class Webhook:
if username: if username:
payload['username'] = username payload['username'] = username
previous_mentions = getattr(self._state, 'mentions', None)
if mentions: if mentions:
try: if previous_mentions is not None:
mentions = self._state.mentions.merge(mentions).to_dict() payload['allowed_mentions'] = previous_mentions.merge(mentions).to_dict()
except AttributeError: else:
mentions = mentions.to_dict() payload['allowed_mentions'] = mentions.to_dict()
finally: elif previous_mentions is not None:
payload['allowed_mentions'] = mentions payload['allowed_mentions'] = previous_mentions.to_dict()
return self._adapter.execute_webhook(wait=wait, file=file, files=files, payload=payload) return self._adapter.execute_webhook(wait=wait, file=file, files=files, payload=payload)

Loading…
Cancel
Save