aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-11-19 23:10:15 -0500
committerRapptz <[email protected]>2015-11-19 23:10:15 -0500
commitacbbaa39ad121ce31c952597cd9a2a034a2927f4 (patch)
tree700c5e77adead7bb6eec95975c89e28a99c76ea5
parentAdd get_raw_[channel_]mentions to Message (diff)
downloaddiscord.py-acbbaa39ad121ce31c952597cd9a2a034a2927f4.tar.xz
discord.py-acbbaa39ad121ce31c952597cd9a2a034a2927f4.zip
Add Message.channel_mentions
-rw-r--r--discord/message.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/discord/message.py b/discord/message.py
index b70af032..13526f4a 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -72,6 +72,10 @@ class Message(object):
A list of :class:`Member` that were mentioned. If the message is in a private message
then the list is always empty.
+ .. attribute:: channel_mentions
+
+ A list of :class:`Channel` that were mentioned. If the message is in a private message
+ then the list is always empty.
.. attribute:: id
The message ID.
@@ -100,6 +104,7 @@ class Message(object):
def _handle_mentions(self, mentions):
self.mentions = []
+ self.channel_mentions = []
if getattr(self.channel, 'is_private', True):
return
@@ -110,6 +115,13 @@ class Message(object):
if member is not None:
self.mentions.append(member)
+ if self.server is not None:
+ channel_mentions = self.get_raw_channel_mentions()
+ for mention in 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.