Skip to content
This repository was archived by the owner on Aug 28, 2019. It is now read-only.

Commit d853a57

Browse files
committed
Rename allowed mention parameters to allowed_mentions
1 parent 730d79d commit d853a57

File tree

5 files changed

+35
-34
lines changed

5 files changed

+35
-34
lines changed

discord/abc.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ async def _get_channel(self):
770770

771771
async def send(self, content=None, *, tts=False, embed=None, file=None,
772772
files=None, delete_after=None, nonce=None,
773-
mentions=None):
773+
allowed_mentions=None):
774774
"""|coro|
775775
776776
Sends a message to the destination with the content given.
@@ -806,7 +806,7 @@ async def send(self, content=None, *, tts=False, embed=None, file=None,
806806
If provided, the number of seconds to wait in the background
807807
before deleting the message we just sent. If the deletion fails,
808808
then it is silently ignored.
809-
mentions: :class:`AllowedMentions`
809+
allowed_mentions: :class:`AllowedMentions`
810810
Controls the mentions being processed in this message.
811811
812812
.. versionadded:: 1.4
@@ -833,13 +833,13 @@ async def send(self, content=None, *, tts=False, embed=None, file=None,
833833
if embed is not None:
834834
embed = embed.to_dict()
835835

836-
if mentions is not None:
837-
if state.mentions is not None:
838-
mentions = state.mentions.merge(mentions).to_dict()
836+
if allowed_mentions is not None:
837+
if state.allowed_mentions is not None:
838+
allowed_mentions = state.allowed_mentions.merge(allowed_mentions).to_dict()
839839
else:
840-
mentions = mentions.to_dict()
840+
allowed_mentions = allowed_mentions.to_dict()
841841
else:
842-
mentions = state.mentions and state.mentions.to_dict()
842+
allowed_mentions = state.allowed_mentions and state.allowed_mentions.to_dict()
843843

844844
if file is not None and files is not None:
845845
raise InvalidArgument('cannot pass both file and files parameter to send()')
@@ -862,12 +862,13 @@ async def send(self, content=None, *, tts=False, embed=None, file=None,
862862

863863
try:
864864
data = await state.http.send_files(channel.id, files=files, content=content, tts=tts,
865-
embed=embed, nonce=nonce, mentions=mentions)
865+
embed=embed, nonce=nonce, allowed_mentions=allowed_mentions)
866866
finally:
867867
for f in files:
868868
f.close()
869869
else:
870-
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce, mentions=mentions)
870+
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
871+
nonce=nonce, allowed_mentions=allowed_mentions)
871872

872873
ret = state.create_message(channel=channel, data=data)
873874
if delete_after is not None:

discord/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Client:
150150
A status to start your presence with upon logging on to Discord.
151151
activity: Optional[:class:`.BaseActivity`]
152152
An activity to start your presence with upon logging on to Discord.
153-
mentions: Optional[:class:`AllowedMentions`]
153+
allowed_mentions: Optional[:class:`AllowedMentions`]
154154
Control how the client handles mentions by default on every message sent.
155155
156156
.. versionadded:: 1.4
@@ -667,21 +667,21 @@ def activity(self, value):
667667
raise TypeError('activity must derive from BaseActivity.')
668668

669669
@property
670-
def mentions(self):
670+
def allowed_mentions(self):
671671
"""Optional[:class:`AllowedMentions`]: The allowed mention configuration.
672672
673673
.. versionadded:: 1.4
674674
"""
675-
return self._connection.mentions
675+
return self._connection.allowed_mentions
676676

677-
@mentions.setter
678-
def mentions(self, value):
677+
@allowed_mentions.setter
678+
def allowed_mentions(self, value):
679679
if value is None:
680-
self._connection.mentions = value
680+
self._connection.allowed_mentions = value
681681
elif isinstance(value, AllowedMentions):
682-
self._connection.mentions = value
682+
self._connection.allowed_mentions = value
683683
else:
684-
raise TypeError('mentions must be AllowedMentions not {0.__class__!r}'.format(value))
684+
raise TypeError('allowed_mentions must be AllowedMentions not {0.__class__!r}'.format(value))
685685

686686
# helpers/getters
687687

discord/http.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def start_private_message(self, user_id):
310310

311311
return self.request(Route('POST', '/users/@me/channels'), json=payload)
312312

313-
def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None, mentions=None):
313+
def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None, allowed_mentions=None):
314314
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
315315
payload = {}
316316

@@ -326,15 +326,15 @@ def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None
326326
if nonce:
327327
payload['nonce'] = nonce
328328

329-
if mentions:
330-
payload['allowed_mentions'] = mentions
329+
if allowed_mentions:
330+
payload['allowed_mentions'] = allowed_mentions
331331

332332
return self.request(r, json=payload)
333333

334334
def send_typing(self, channel_id):
335335
return self.request(Route('POST', '/channels/{channel_id}/typing', channel_id=channel_id))
336336

337-
def send_files(self, channel_id, *, files, content=None, tts=False, embed=None, nonce=None, mentions=None):
337+
def send_files(self, channel_id, *, files, content=None, tts=False, embed=None, nonce=None, allowed_mentions=None):
338338
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
339339
form = aiohttp.FormData()
340340

@@ -345,8 +345,8 @@ def send_files(self, channel_id, *, files, content=None, tts=False, embed=None,
345345
payload['embed'] = embed
346346
if nonce:
347347
payload['nonce'] = nonce
348-
if mentions:
349-
payload['allowed_mentions'] = mentions
348+
if allowed_mentions:
349+
payload['allowed_mentions'] = allowed_mentions
350350

351351
form.add_field('payload_json', utils.to_json(payload))
352352
if len(files) == 1:

discord/state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ def __init__(self, *, dispatch, chunker, handlers, syncer, http, loop, **options
7979
self._fetch_offline = options.get('fetch_offline_members', True)
8080
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
8181
self.guild_subscriptions = options.get('guild_subscriptions', True)
82-
mentions = options.get('mentions')
82+
allowed_mentions = options.get('allowed_mentions')
8383

84-
if mentions is not None and not isinstance(mentions, AllowedMentions):
85-
raise TypeError('mentions parameter must be AllowedMentions')
84+
if allowed_mentions is not None and not isinstance(allowed_mentions, AllowedMentions):
85+
raise TypeError('allowed_mentions parameter must be AllowedMentions')
8686

87-
self.mentions = mentions
87+
self.allowed_mentions = allowed_mentions
8888
# Only disable cache if both fetch_offline and guild_subscriptions are off.
8989
self._cache_members = (self._fetch_offline or self.guild_subscriptions)
9090
self._listeners = []

discord/webhook.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def edit(self, **kwargs):
688688
return self._adapter.edit_webhook(**payload)
689689

690690
def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=False,
691-
file=None, files=None, embed=None, embeds=None, mentions=None):
691+
file=None, files=None, embed=None, embeds=None, allowed_mentions=None):
692692
"""|maybecoro|
693693
694694
Sends a message using the webhook.
@@ -732,8 +732,8 @@ def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=
732732
embeds: List[:class:`Embed`]
733733
A list of embeds to send with the content. Maximum of 10. This cannot
734734
be mixed with the ``embed`` parameter.
735-
mentions: :class:`AllowedMentions`
736-
Controls the mentions being processed in this message.
735+
allowed_mentions: :class:`AllowedMentions`
736+
Controls the allowed_mentions being processed in this message.
737737
738738
.. versionadded:: 1.4
739739
@@ -781,13 +781,13 @@ def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=
781781
if username:
782782
payload['username'] = username
783783

784-
previous_mentions = getattr(self._state, 'mentions', None)
784+
previous_mentions = getattr(self._state, 'allowed_mentions', None)
785785

786-
if mentions:
786+
if allowed_mentions:
787787
if previous_mentions is not None:
788-
payload['allowed_mentions'] = previous_mentions.merge(mentions).to_dict()
788+
payload['allowed_mentions'] = previous_mentions.merge(allowed_mentions).to_dict()
789789
else:
790-
payload['allowed_mentions'] = mentions.to_dict()
790+
payload['allowed_mentions'] = allowed_mentions.to_dict()
791791
elif previous_mentions is not None:
792792
payload['allowed_mentions'] = previous_mentions.to_dict()
793793

0 commit comments

Comments
 (0)