mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-31 13:32:57 +00:00 
			
		
		
		
	Rename allowed mention parameters to allowed_mentions
This commit is contained in:
		| @@ -770,7 +770,7 @@ class Messageable(metaclass=abc.ABCMeta): | ||||
|  | ||||
|     async def send(self, content=None, *, tts=False, embed=None, file=None, | ||||
|                                           files=None, delete_after=None, nonce=None, | ||||
|                                           mentions=None): | ||||
|                                           allowed_mentions=None): | ||||
|         """|coro| | ||||
|  | ||||
|         Sends a message to the destination with the content given. | ||||
| @@ -806,7 +806,7 @@ class Messageable(metaclass=abc.ABCMeta): | ||||
|             If provided, the number of seconds to wait in the background | ||||
|             before deleting the message we just sent. If the deletion fails, | ||||
|             then it is silently ignored. | ||||
|         mentions: :class:`AllowedMentions` | ||||
|         allowed_mentions: :class:`AllowedMentions` | ||||
|             Controls the mentions being processed in this message. | ||||
|  | ||||
|             .. versionadded:: 1.4 | ||||
| @@ -833,13 +833,13 @@ class Messageable(metaclass=abc.ABCMeta): | ||||
|         if embed is not None: | ||||
|             embed = embed.to_dict() | ||||
|  | ||||
|         if mentions is not None: | ||||
|             if state.mentions is not None: | ||||
|                 mentions = state.mentions.merge(mentions).to_dict() | ||||
|         if allowed_mentions is not None: | ||||
|             if state.allowed_mentions is not None: | ||||
|                 allowed_mentions = state.allowed_mentions.merge(allowed_mentions).to_dict() | ||||
|             else: | ||||
|                 mentions = mentions.to_dict() | ||||
|                 allowed_mentions = allowed_mentions.to_dict() | ||||
|         else: | ||||
|             mentions = state.mentions and state.mentions.to_dict() | ||||
|             allowed_mentions = state.allowed_mentions and state.allowed_mentions.to_dict() | ||||
|  | ||||
|         if file is not None and files is not None: | ||||
|             raise InvalidArgument('cannot pass both file and files parameter to send()') | ||||
| @@ -862,12 +862,13 @@ class Messageable(metaclass=abc.ABCMeta): | ||||
|  | ||||
|             try: | ||||
|                 data = await state.http.send_files(channel.id, files=files, content=content, tts=tts, | ||||
|                                                    embed=embed, nonce=nonce, mentions=mentions) | ||||
|                                                    embed=embed, nonce=nonce, allowed_mentions=allowed_mentions) | ||||
|             finally: | ||||
|                 for f in files: | ||||
|                     f.close() | ||||
|         else: | ||||
|             data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce, mentions=mentions) | ||||
|             data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, | ||||
|                                                                       nonce=nonce, allowed_mentions=allowed_mentions) | ||||
|  | ||||
|         ret = state.create_message(channel=channel, data=data) | ||||
|         if delete_after is not None: | ||||
|   | ||||
| @@ -150,7 +150,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. | ||||
|     mentions: Optional[:class:`AllowedMentions`] | ||||
|     allowed_mentions: Optional[:class:`AllowedMentions`] | ||||
|         Control how the client handles mentions by default on every message sent. | ||||
|  | ||||
|         .. versionadded:: 1.4 | ||||
| @@ -667,21 +667,21 @@ class Client: | ||||
|             raise TypeError('activity must derive from BaseActivity.') | ||||
|  | ||||
|     @property | ||||
|     def mentions(self): | ||||
|     def allowed_mentions(self): | ||||
|         """Optional[:class:`AllowedMentions`]: The allowed mention configuration. | ||||
|  | ||||
|         .. versionadded:: 1.4 | ||||
|         """ | ||||
|         return self._connection.mentions | ||||
|         return self._connection.allowed_mentions | ||||
|  | ||||
|     @mentions.setter | ||||
|     def mentions(self, value): | ||||
|     @allowed_mentions.setter | ||||
|     def allowed_mentions(self, value): | ||||
|         if value is None: | ||||
|             self._connection.mentions = value | ||||
|             self._connection.allowed_mentions = value | ||||
|         elif isinstance(value, AllowedMentions): | ||||
|             self._connection.mentions = value | ||||
|             self._connection.allowed_mentions = value | ||||
|         else: | ||||
|             raise TypeError('mentions must be AllowedMentions not {0.__class__!r}'.format(value)) | ||||
|             raise TypeError('allowed_mentions must be AllowedMentions not {0.__class__!r}'.format(value)) | ||||
|  | ||||
|     # helpers/getters | ||||
|  | ||||
|   | ||||
| @@ -310,7 +310,7 @@ class HTTPClient: | ||||
|  | ||||
|         return self.request(Route('POST', '/users/@me/channels'), json=payload) | ||||
|  | ||||
|     def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None, mentions=None): | ||||
|     def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None, allowed_mentions=None): | ||||
|         r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id) | ||||
|         payload = {} | ||||
|  | ||||
| @@ -326,15 +326,15 @@ class HTTPClient: | ||||
|         if nonce: | ||||
|             payload['nonce'] = nonce | ||||
|  | ||||
|         if mentions: | ||||
|             payload['allowed_mentions'] = mentions | ||||
|         if allowed_mentions: | ||||
|             payload['allowed_mentions'] = allowed_mentions | ||||
|  | ||||
|         return self.request(r, json=payload) | ||||
|  | ||||
|     def send_typing(self, channel_id): | ||||
|         return self.request(Route('POST', '/channels/{channel_id}/typing', channel_id=channel_id)) | ||||
|  | ||||
|     def send_files(self, channel_id, *, files, content=None, tts=False, embed=None, nonce=None, mentions=None): | ||||
|     def send_files(self, channel_id, *, files, content=None, tts=False, embed=None, nonce=None, allowed_mentions=None): | ||||
|         r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id) | ||||
|         form = aiohttp.FormData() | ||||
|  | ||||
| @@ -345,8 +345,8 @@ class HTTPClient: | ||||
|             payload['embed'] = embed | ||||
|         if nonce: | ||||
|             payload['nonce'] = nonce | ||||
|         if mentions: | ||||
|             payload['allowed_mentions'] = mentions | ||||
|         if allowed_mentions: | ||||
|             payload['allowed_mentions'] = allowed_mentions | ||||
|  | ||||
|         form.add_field('payload_json', utils.to_json(payload)) | ||||
|         if len(files) == 1: | ||||
|   | ||||
| @@ -79,12 +79,12 @@ class ConnectionState: | ||||
|         self._fetch_offline = options.get('fetch_offline_members', True) | ||||
|         self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0) | ||||
|         self.guild_subscriptions = options.get('guild_subscriptions', True) | ||||
|         mentions = options.get('mentions') | ||||
|         allowed_mentions = options.get('allowed_mentions') | ||||
|  | ||||
|         if mentions is not None and not isinstance(mentions, AllowedMentions): | ||||
|             raise TypeError('mentions parameter must be AllowedMentions') | ||||
|         if allowed_mentions is not None and not isinstance(allowed_mentions, AllowedMentions): | ||||
|             raise TypeError('allowed_mentions parameter must be AllowedMentions') | ||||
|  | ||||
|         self.mentions = mentions | ||||
|         self.allowed_mentions = allowed_mentions | ||||
|         # Only disable cache if both fetch_offline and guild_subscriptions are off. | ||||
|         self._cache_members = (self._fetch_offline or self.guild_subscriptions) | ||||
|         self._listeners = [] | ||||
|   | ||||
| @@ -688,7 +688,7 @@ class Webhook: | ||||
|         return self._adapter.edit_webhook(**payload) | ||||
|  | ||||
|     def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=False, | ||||
|                                     file=None, files=None, embed=None, embeds=None, mentions=None): | ||||
|                                     file=None, files=None, embed=None, embeds=None, allowed_mentions=None): | ||||
|         """|maybecoro| | ||||
|  | ||||
|         Sends a message using the webhook. | ||||
| @@ -732,8 +732,8 @@ class Webhook: | ||||
|         embeds: List[:class:`Embed`] | ||||
|             A list of embeds to send with the content. Maximum of 10. This cannot | ||||
|             be mixed with the ``embed`` parameter. | ||||
|         mentions: :class:`AllowedMentions` | ||||
|             Controls the mentions being processed in this message. | ||||
|         allowed_mentions: :class:`AllowedMentions` | ||||
|             Controls the allowed_mentions being processed in this message. | ||||
|  | ||||
|             .. versionadded:: 1.4 | ||||
|  | ||||
| @@ -781,13 +781,13 @@ class Webhook: | ||||
|         if username: | ||||
|             payload['username'] = username | ||||
|  | ||||
|         previous_mentions = getattr(self._state, 'mentions', None) | ||||
|         previous_mentions = getattr(self._state, 'allowed_mentions', None) | ||||
|  | ||||
|         if mentions: | ||||
|         if allowed_mentions: | ||||
|             if previous_mentions is not None: | ||||
|                 payload['allowed_mentions'] = previous_mentions.merge(mentions).to_dict() | ||||
|                 payload['allowed_mentions'] = previous_mentions.merge(allowed_mentions).to_dict() | ||||
|             else: | ||||
|                 payload['allowed_mentions'] = mentions.to_dict() | ||||
|                 payload['allowed_mentions'] = allowed_mentions.to_dict() | ||||
|         elif previous_mentions is not None: | ||||
|             payload['allowed_mentions'] = previous_mentions.to_dict() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user