diff --git a/discord/message.py b/discord/message.py index 209c14197..b70af0324 100644 --- a/discord/message.py +++ b/discord/message.py @@ -28,6 +28,7 @@ from . import utils from .user import User from .member import Member from .object import Object +import re class Message(object): """Represents a message from Discord. @@ -109,6 +110,24 @@ class Message(object): if member is not None: self.mentions.append(member) + def get_raw_mentions(self): + """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. + + This allows you receive the channel IDs of mentioned users + even in a private message context. + """ + return re.findall(r'<#(\d+)>', self.content) + def _handle_upgrades_and_server(self, channel_id): self.server = None if self.channel is None: