aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-09-04 21:16:27 -0400
committerRapptz <[email protected]>2015-09-04 21:16:27 -0400
commitb00ad4ad790fb4ae0878572f27ee01cf25226843 (patch)
treeb7c453cfa900b0c479b4628217e2fc05b73b1fab /discord/message.py
parentAdd ability to delete channels. (diff)
downloaddiscord.py-b00ad4ad790fb4ae0878572f27ee01cf25226843.tar.xz
discord.py-b00ad4ad790fb4ae0878572f27ee01cf25226843.zip
Use kwargs if the number of arguments needed is too many.
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/discord/message.py b/discord/message.py
index 2f529e09..5fe871cd 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -70,25 +70,25 @@ class Message(object):
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):
+ def __init__(self, **kwargs):
# at the moment, the timestamps seem to be naive so they have no time zone and operate on UTC time.
# 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
- self.edited_timestamp = None
- if edited_timestamp is not None:
+ self.edited_timestamp = kwargs.get('edited_timestamp')
+ if self.edited_timestamp is not None:
self.edited_timestamp = self._parse_time(edited_timestamp)
- self.timestamp = self._parse_time(timestamp)
- self.tts = tts
- self.content = content
- self.mention_everyone = mention_everyone
- self.embeds = embeds
- self.id = id
- self.channel = channel
- self.author = User(**author)
- self.mentions = [User(**mention) for mention in mentions]
- self.attachments = attachments
+ self.timestamp = self._parse_time(kwargs.get('timestamp'))
+ self.tts = kwargs.get('tts')
+ self.content = kwargs.get('content')
+ self.mention_everyone = kwargs.get('mention_everyone')
+ self.embeds = kwargs.get('embeds')
+ self.id = kwargs.get('id')
+ self.channel = kwargs.get('channel')
+ self.author = User(**kwargs.get('author', {}))
+ self.mentions = [User(**mention) for mention in kwargs.get('mentions', {})]
+ self.attachments = kwargs.get('attachments')
def _parse_time(self, time_string):
return datetime.datetime(*map(int, re.split(r'[^\d]', time_string.replace('+00:00', ''))))