mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
Add Message.nonce attribute.
This commit is contained in:
parent
0fbb58cde9
commit
5ca13cac8e
@ -51,6 +51,7 @@ import sys, time, re, json
|
|||||||
import tempfile, os, hashlib
|
import tempfile, os, hashlib
|
||||||
import itertools
|
import itertools
|
||||||
import zlib
|
import zlib
|
||||||
|
from random import randint as random_integer
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
request_logging_format = '{method} {response.url} has returned {response.status}'
|
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)
|
url = '{base}/{id}/messages'.format(base=endpoints.CHANNELS, id=channel_id)
|
||||||
payload = {
|
payload = {
|
||||||
'content': content
|
'content': content,
|
||||||
|
'nonce': random_integer(-2**63, 2**63 - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tts:
|
if tts:
|
||||||
|
@ -26,7 +26,6 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .user import User
|
from .user import User
|
||||||
from .member import Member
|
|
||||||
from .object import Object
|
from .object import Object
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -48,6 +47,9 @@ class Message:
|
|||||||
private channel, then it is a :class:`User` instead.
|
private channel, then it is a :class:`User` instead.
|
||||||
content : str
|
content : str
|
||||||
The actual contents of the message.
|
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
|
embeds : list
|
||||||
A list of embedded objects. The elements are objects that meet oEmbed's specification_.
|
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',
|
__slots__ = [ 'edited_timestamp', 'timestamp', 'tts', 'content', 'channel',
|
||||||
'mention_everyone', 'embeds', 'id', 'mentions', 'author',
|
'mention_everyone', 'embeds', 'id', 'mentions', 'author',
|
||||||
'channel_mentions', 'server', '_raw_mentions', 'attachments',
|
'channel_mentions', 'server', '_raw_mentions', 'attachments',
|
||||||
'_clean_content', '_raw_channel_mentions' ]
|
'_clean_content', '_raw_channel_mentions', 'nonce' ]
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
# at the moment, the timestamps seem to be naive so they have no time zone and operate on UTC time.
|
# 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.id = kwargs.get('id')
|
||||||
self.channel = kwargs.get('channel')
|
self.channel = kwargs.get('channel')
|
||||||
self.author = User(**kwargs.get('author', {}))
|
self.author = User(**kwargs.get('author', {}))
|
||||||
|
self.nonce = kwargs.get('nonce')
|
||||||
self.attachments = kwargs.get('attachments')
|
self.attachments = kwargs.get('attachments')
|
||||||
self._handle_upgrades(kwargs.get('channel_id'))
|
self._handle_upgrades(kwargs.get('channel_id'))
|
||||||
self._handle_mentions(kwargs.get('mentions', []))
|
self._handle_mentions(kwargs.get('mentions', []))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user