update docs and add message replies

This commit is contained in:
iDutchy
2020-11-18 17:49:58 -06:00
parent 195bace135
commit 690dcdaf2e
11 changed files with 234 additions and 48 deletions

View File

@ -802,7 +802,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,
allowed_mentions=None):
allowed_mentions=None, message_reference=None):
"""|coro|
Sends a message to the destination with the content given.
@ -847,6 +847,12 @@ class Messageable(metaclass=abc.ABCMeta):
are used instead.
.. versionadded:: 1.4
message_reference: :class:`~discord.MessageReference`
A reference to the :class:`~discord.Message` to which you are replying, i.e. as created using
:meth:`~discord.MessageReference.from_message`. You can control whether this mentions the author
of the referenced Message using :attr:`~discord.AllowedMentions.replied_user`.
.. versionadded:: 1.5.1.5
Raises
--------
@ -878,6 +884,9 @@ class Messageable(metaclass=abc.ABCMeta):
else:
allowed_mentions = state.allowed_mentions and state.allowed_mentions.to_dict()
if message_reference is not None:
message_reference = message_reference.to_dict()
if file is not None and files is not None:
raise InvalidArgument('cannot pass both file and files parameter to send()')
@ -887,7 +896,8 @@ class Messageable(metaclass=abc.ABCMeta):
try:
data = await state.http.send_files(channel.id, files=[file], allowed_mentions=allowed_mentions,
content=content, tts=tts, embed=embed, nonce=nonce)
content=content, tts=tts, embed=embed, nonce=nonce,
message_reference=message_reference)
finally:
file.close()
@ -899,13 +909,15 @@ class Messageable(metaclass=abc.ABCMeta):
try:
data = await state.http.send_files(channel.id, files=files, content=content, tts=tts,
embed=embed, nonce=nonce, allowed_mentions=allowed_mentions)
embed=embed, nonce=nonce, allowed_mentions=allowed_mentions,
message_reference=message_reference)
finally:
for f in files:
f.close()
else:
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
nonce=nonce, allowed_mentions=allowed_mentions)
nonce=nonce, allowed_mentions=allowed_mentions,
message_reference=message_reference)
ret = state.create_message(channel=channel, data=data)
if delete_after is not None: