log.warning("Can't parse {}!".format(text))
return None
+async def parse_user(text, *, author = None):
+ if not re.match(r'^[\d@&<]', text):
+ text = '@' + text
+ parsed = parse_mention(text, author = author)
+ if parsed is None:
+ return None
+ if not re.match(r'^\d+$', parsed):
+ return None
+ user = await client.get_user_info(parsed)
+ return user
+
def format_mention(mention):
if mention in ['everyone', 'here']:
return '@{}'.format(mention)
parsed = bot.parse_mention(who, author = message.author)
if parsed is None:
+ user = await bot.parse_user(who, author = message.author)
+ if user is not None:
+ parsed = user.id
+ if parsed is None:
await bot.say(message.channel, '{}?'.format(who))
return
if parsed[0] == '#':
if parsed[0] == '&':
await client.edit_role(server, target, permissions = permissions)
else:
- await bot.say('Need channel to update member permissions!')
+ await bot.say(message.channel, 'Need channel to update member permissions!')
return
await cat.purr(message.channel)