mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-15 02:09:49 +00:00
Mentions are now <@id> *only* - remove mentions array on send and edit message
This commit is contained in:
parent
e8a06b7ee9
commit
ec23434162
@ -206,14 +206,6 @@ class Client:
|
|||||||
def handle_ready(self):
|
def handle_ready(self):
|
||||||
self._is_ready.set()
|
self._is_ready.set()
|
||||||
|
|
||||||
def _resolve_mentions(self, content, mentions):
|
|
||||||
if isinstance(mentions, list):
|
|
||||||
return [user.id for user in mentions]
|
|
||||||
elif mentions == True:
|
|
||||||
return re.findall(r'<@([0-9]+)>', content)
|
|
||||||
else:
|
|
||||||
return []
|
|
||||||
|
|
||||||
def _resolve_invite(self, invite):
|
def _resolve_invite(self, invite):
|
||||||
if isinstance(invite, Invite) or isinstance(invite, Object):
|
if isinstance(invite, Invite) or isinstance(invite, Object):
|
||||||
return invite.id
|
return invite.id
|
||||||
@ -880,7 +872,7 @@ class Client:
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def send_message(self, destination, content, *, mentions=True, tts=False):
|
def send_message(self, destination, content, *, tts=False):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Sends a message to the destination given with the content given.
|
Sends a message to the destination given with the content given.
|
||||||
@ -900,18 +892,12 @@ class Client:
|
|||||||
|
|
||||||
The content must be a type that can convert to a string through ``str(content)``.
|
The content must be a type that can convert to a string through ``str(content)``.
|
||||||
|
|
||||||
The mentions must be either an array of :class:`User` to mention or a boolean. If
|
|
||||||
``mentions`` is ``True`` then all the users mentioned in the content are mentioned, otherwise
|
|
||||||
no one is mentioned. Note that to mention someone in the content, you should use :meth:`User.mention`.
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
------------
|
------------
|
||||||
destination
|
destination
|
||||||
The location to send the message.
|
The location to send the message.
|
||||||
content
|
content
|
||||||
The content of the message to send.
|
The content of the message to send.
|
||||||
mentions
|
|
||||||
A list of :class:`User` to mention in the message or a boolean. Ignored for private messages.
|
|
||||||
tts : bool
|
tts : bool
|
||||||
Indicates if the message should be sent using text-to-speech.
|
Indicates if the message should be sent using text-to-speech.
|
||||||
|
|
||||||
@ -935,12 +921,10 @@ class Client:
|
|||||||
channel_id = yield from self._resolve_destination(destination)
|
channel_id = yield from self._resolve_destination(destination)
|
||||||
|
|
||||||
content = str(content)
|
content = str(content)
|
||||||
mentions = self._resolve_mentions(content, mentions)
|
|
||||||
|
|
||||||
url = '{base}/{id}/messages'.format(base=endpoints.CHANNELS, id=channel_id)
|
url = '{base}/{id}/messages'.format(base=endpoints.CHANNELS, id=channel_id)
|
||||||
payload = {
|
payload = {
|
||||||
'content': content,
|
'content': content
|
||||||
'mentions': mentions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tts:
|
if tts:
|
||||||
@ -1078,7 +1062,7 @@ class Client:
|
|||||||
yield from response.release()
|
yield from response.release()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def edit_message(self, message, new_content, *, mentions=True):
|
def edit_message(self, message, new_content):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Edits a :class:`Message` with the new message content.
|
Edits a :class:`Message` with the new message content.
|
||||||
@ -1091,8 +1075,6 @@ class Client:
|
|||||||
The message to edit.
|
The message to edit.
|
||||||
new_content
|
new_content
|
||||||
The new content to replace the message with.
|
The new content to replace the message with.
|
||||||
mentions
|
|
||||||
The mentions for the user. Same as :meth:`send_message`.
|
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -1110,8 +1092,7 @@ class Client:
|
|||||||
|
|
||||||
url = '{}/{}/messages/{}'.format(endpoints.CHANNELS, channel.id, message.id)
|
url = '{}/{}/messages/{}'.format(endpoints.CHANNELS, channel.id, message.id)
|
||||||
payload = {
|
payload = {
|
||||||
'content': content,
|
'content': content
|
||||||
'mentions': self._resolve_mentions(content, mentions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response = yield from self._rate_limit_helper('edit_message', 'PATCH', url, utils.to_json(payload))
|
response = yield from self._rate_limit_helper('edit_message', 'PATCH', url, utils.to_json(payload))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user