From de1c74a399a5286cd707c6ebc3892e168d628ac0 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 16 Dec 2015 22:03:16 -0500 Subject: Make more things into properties. A lot of the expensive getters were transformed into cached properties instead. A lot of things that were properties were transformed into properties as well. --- discord/message.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'discord/message.py') diff --git a/discord/message.py b/discord/message.py index 8601e3cd..496cd75e 100644 --- a/discord/message.py +++ b/discord/message.py @@ -131,24 +131,25 @@ class Message(object): self.mentions.append(member) if self.server is not None: - channel_mentions = self.get_raw_channel_mentions() - for mention in channel_mentions: + for mention in self.raw_channel_mentions: channel = utils.find(lambda m: m.id == mention, self.server.channels) if channel is not None: self.channel_mentions.append(channel) - def get_raw_mentions(self): - """Returns an array of user IDs matched with the syntax of - <@user_id> in the message content. + @utils.cached_property + def raw_mentions(self): + """A property that returns an array of user IDs matched with + the syntax of <@user_id> in the message content. This allows you receive the user IDs of mentioned users even in a private message context. """ return re.findall(r'<@(\d+)>', self.content) - def get_raw_channel_mentions(self): - """Returns an array of channel IDs matched with the syntax of - <#channel_id> in the message content. + @utils.cached_property + def raw_channel_mentions(self): + """A property that returns an array of channel IDs matched with + the syntax of <#channel_id> in the message content. This allows you receive the channel IDs of mentioned users even in a private message context. @@ -168,6 +169,3 @@ class Message(object): found = utils.find(lambda m: m.id == self.author.id, self.server.members) if found is not None: self.author = found - - - -- cgit v1.2.3