aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-01-07 02:06:11 -0500
committerRapptz <[email protected]>2016-01-07 02:06:11 -0500
commit5ca13cac8e920592c92acf5dc9ad4f89d2abbd06 (patch)
tree9a1adb0933cefa6108697036ea8a3ae9c32a6572
parentChange the way MESSAGE_UPDATE events are handled. (diff)
downloaddiscord.py-5ca13cac8e920592c92acf5dc9ad4f89d2abbd06.tar.xz
discord.py-5ca13cac8e920592c92acf5dc9ad4f89d2abbd06.zip
Add Message.nonce attribute.
-rw-r--r--discord/client.py4
-rw-r--r--discord/message.py7
2 files changed, 8 insertions, 3 deletions
diff --git a/discord/client.py b/discord/client.py
index dcec1ae2..bfdabf3d 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -51,6 +51,7 @@ import sys, time, re, json
import tempfile, os, hashlib
import itertools
import zlib
+from random import randint as random_integer
log = logging.getLogger(__name__)
request_logging_format = '{method} {response.url} has returned {response.status}'
@@ -922,7 +923,8 @@ class Client:
url = '{base}/{id}/messages'.format(base=endpoints.CHANNELS, id=channel_id)
payload = {
- 'content': content
+ 'content': content,
+ 'nonce': random_integer(-2**63, 2**63 - 1)
}
if tts:
diff --git a/discord/message.py b/discord/message.py
index 3db7bdb3..af431f03 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -26,7 +26,6 @@ DEALINGS IN THE SOFTWARE.
from . import utils
from .user import User
-from .member import Member
from .object import Object
import re
@@ -48,6 +47,9 @@ class Message:
private channel, then it is a :class:`User` instead.
content : str
The actual contents of the message.
+ nonce
+ The value used by the discord server and the client to verify that the message is successfully sent.
+ This is typically non-important.
embeds : list
A list of embedded objects. The elements are objects that meet oEmbed's specification_.
@@ -90,7 +92,7 @@ class Message:
__slots__ = [ 'edited_timestamp', 'timestamp', 'tts', 'content', 'channel',
'mention_everyone', 'embeds', 'id', 'mentions', 'author',
'channel_mentions', 'server', '_raw_mentions', 'attachments',
- '_clean_content', '_raw_channel_mentions' ]
+ '_clean_content', '_raw_channel_mentions', 'nonce' ]
def __init__(self, **kwargs):
# at the moment, the timestamps seem to be naive so they have no time zone and operate on UTC time.
@@ -106,6 +108,7 @@ class Message:
self.id = kwargs.get('id')
self.channel = kwargs.get('channel')
self.author = User(**kwargs.get('author', {}))
+ self.nonce = kwargs.get('nonce')
self.attachments = kwargs.get('attachments')
self._handle_upgrades(kwargs.get('channel_id'))
self._handle_mentions(kwargs.get('mentions', []))