aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/abc.py12
-rw-r--r--discord/http.py9
2 files changed, 15 insertions, 6 deletions
diff --git a/discord/abc.py b/discord/abc.py
index d9fb03f4..ef43870d 100644
--- a/discord/abc.py
+++ b/discord/abc.py
@@ -628,7 +628,7 @@ class Messageable(metaclass=abc.ABCMeta):
raise NotImplementedError
@asyncio.coroutine
- def send(self, content=None, *, tts=False, embed=None, file=None, files=None, reason=None, delete_after=None):
+ def send(self, content=None, *, tts=False, embed=None, file=None, files=None, reason=None, delete_after=None, nonce=None):
"""|coro|
Sends a message to the destination with the content given.
@@ -658,6 +658,9 @@ class Messageable(metaclass=abc.ABCMeta):
files: List[:class:`File`]
A list of files to upload. Must be a minimum of 2 and a
maximum of 10.
+ nonce: int
+ The nonce to use for sending this message. If the message was successfully sent,
+ then the message will have a nonce with this value.
delete_after: float
If provided, the number of seconds to wait in the background
before deleting the message we just sent. If the deletion fails,
@@ -697,7 +700,7 @@ class Messageable(metaclass=abc.ABCMeta):
try:
data = yield from state.http.send_files(channel.id, files=[(file.open_file(), file.filename)],
- content=content, tts=tts, embed=embed)
+ content=content, tts=tts, embed=embed, nonce=nonce)
finally:
file.close()
@@ -707,12 +710,13 @@ class Messageable(metaclass=abc.ABCMeta):
try:
param = [(f.open_file(), f.filename) for f in files]
- data = yield from state.http.send_files(channel.id, files=param, content=content, tts=tts, embed=embed)
+ data = yield from state.http.send_files(channel.id, files=param, content=content, tts=tts,
+ embed=embed, nonce=nonce)
finally:
for f in files:
f.close()
else:
- data = yield from state.http.send_message(channel.id, content, tts=tts, embed=embed)
+ data = yield from state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
ret = state.create_message(channel=channel, data=data)
if delete_after is not None:
diff --git a/discord/http.py b/discord/http.py
index ae816043..3f8c5241 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -294,7 +294,7 @@ class HTTPClient:
return self.request(Route('POST', '/users/@me/channels'), json=payload)
- def send_message(self, channel_id, content, *, tts=False, embed=None):
+ def send_message(self, channel_id, content, *, tts=False, embed=None, nonce=None):
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
payload = {}
@@ -307,12 +307,15 @@ class HTTPClient:
if embed:
payload['embed'] = embed
+ if nonce:
+ payload['nonce'] = nonce
+
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):
+ def send_files(self, channel_id, *, files, content=None, tts=False, embed=None, nonce=None):
r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id)
form = aiohttp.FormData()
@@ -321,6 +324,8 @@ class HTTPClient:
payload['content'] = content
if embed:
payload['embed'] = embed
+ if nonce:
+ payload['nonce'] = nonce
form.add_field('payload_json', utils.to_json(payload))
if len(files) == 1: