aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-08-24 06:26:53 -0400
committerRapptz <[email protected]>2015-08-24 06:34:38 -0400
commitde3bce2b3265a4940ba79580fd191b5517ef96cb (patch)
tree82482b19793c2988cf786eba8335c56a8e1a0340 /discord/message.py
parentVersion bump to v0.2.0 (diff)
downloaddiscord.py-de3bce2b3265a4940ba79580fd191b5517ef96cb.tar.xz
discord.py-de3bce2b3265a4940ba79580fd191b5517ef96cb.zip
Fix issue with some MESSAGE_UPDATE events.v0.2.1
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/discord/message.py b/discord/message.py
index 91140af1..0f7006cb 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -65,6 +65,9 @@ class Message(object):
.. attribute:: id
The message ID.
+ .. attribute:: attachments
+
+ An array of attachments given to a message.
"""
def __init__(self, edited_timestamp, timestamp, tts, content, mention_everyone, mentions, embeds, attachments, id, channel, author, **kwargs):
@@ -72,13 +75,11 @@ class Message(object):
# we can use this to our advantage to use strptime instead of a complicated parsing routine.
# example timestamp: 2015-08-21T12:03:45.782000+00:00
# sometimes the .%f modifier is missing
- time_format = "%Y-%m-%dT%H:%M:%S.%f+00:00"
self.edited_timestamp = None
if edited_timestamp is not None:
- temp = edited_timestamp.replace('+00:00', '')
- self.edited_timestamp = datetime.datetime(*map(int, re.split(r'[^\d]', temp)))
+ self.edited_timestamp = self._parse_time(edited_timestamp)
- self.timestamp = datetime.datetime(*map(int, re.split(r'[^\d]', timestamp.replace('+00:00', ''))))
+ self.timestamp = self._parse_time(timestamp)
self.tts = tts
self.content = content
self.mention_everyone = mention_everyone
@@ -87,6 +88,8 @@ class Message(object):
self.channel = channel
self.author = User(**author)
self.mentions = [User(**mention) for mention in mentions]
+ self.attachments = attachments
-
+ def _parse_time(self, time_string):
+ return datetime.datetime(*map(int, re.split(r'[^\d]', time_string.replace('+00:00', ''))))