aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-16 22:03:16 -0500
committerRapptz <[email protected]>2015-12-16 22:03:16 -0500
commitde1c74a399a5286cd707c6ebc3892e168d628ac0 (patch)
tree5345ed742be917325f0612cdf52e5bc03d9018b6 /discord/message.py
parentChannel.is_default_channel is now a property named is_default. (diff)
downloaddiscord.py-de1c74a399a5286cd707c6ebc3892e168d628ac0.tar.xz
discord.py-de1c74a399a5286cd707c6ebc3892e168d628ac0.zip
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.
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py20
1 files changed, 9 insertions, 11 deletions
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
-
-
-