Browse Source

[commands] Make when_mentioned always have both mention formats.

This will allow it to work in mobile clients which don't respect the
<@!id> format in case of nicknames.
pull/546/head
Rapptz 8 years ago
parent
commit
c005ef5d44
  1. 7
      discord/ext/commands/bot.py

7
discord/ext/commands/bot.py

@ -41,10 +41,7 @@ from .formatter import HelpFormatter
def when_mentioned(bot, msg): def when_mentioned(bot, msg):
"""A callable that implements a command prefix equivalent """A callable that implements a command prefix equivalent
to being mentioned, e.g. ``@bot ``.""" to being mentioned, e.g. ``@bot ``."""
guild = msg.guild return [bot.user.mention, '<@!%s>' % bot.user.id]
if guild is not None:
return '{0.me.mention} '.format(guild)
return '{0.user.mention} '.format(bot)
def when_mentioned_or(*prefixes): def when_mentioned_or(*prefixes):
"""A callable that implements when mentioned or other prefixes provided. """A callable that implements when mentioned or other prefixes provided.
@ -62,7 +59,7 @@ def when_mentioned_or(*prefixes):
""" """
def inner(bot, msg): def inner(bot, msg):
r = list(prefixes) r = list(prefixes)
r.append(when_mentioned(bot, msg)) r.extend(when_mentioned(bot, msg))
return r return r
return inner return inner

Loading…
Cancel
Save