aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-07-01 16:32:36 -0400
committerRapptz <[email protected]>2017-07-01 16:32:36 -0400
commit0b9d402272e68b883947a63162ba660fc71a2895 (patch)
treeac51d2032317a736b9d879bd0f8613e32b8357b4
parentAdd when_mentioned and when_mentioned_or to the documentation. (diff)
downloaddiscord.py-0b9d402272e68b883947a63162ba660fc71a2895.tar.xz
discord.py-0b9d402272e68b883947a63162ba660fc71a2895.zip
[commands] Improve commands.when_mentioned_or documentation.
-rw-r--r--discord/ext/commands/bot.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index ee38bfc8..7157319d 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -39,13 +39,17 @@ from .errors import CommandNotFound, CommandError
from .formatter import HelpFormatter
def when_mentioned(bot, msg):
- """A callable that implements a command prefix equivalent
- to being mentioned, e.g. ``@bot ``."""
+ """A callable that implements a command prefix equivalent to being mentioned.
+
+ These are meant to be passed into the :attr:`.Bot.command_prefix` attribute.
+ """
return [bot.user.mention + ' ', '<@!%s> ' % bot.user.id]
def when_mentioned_or(*prefixes):
"""A callable that implements when mentioned or other prefixes provided.
+ These are meant to be passed into the :attr:`.Bot.command_prefix` attribute.
+
Example
--------
@@ -53,6 +57,19 @@ def when_mentioned_or(*prefixes):
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
+
+ .. note::
+
+ This callable returns another callable, so if this is done inside a custom
+ callable, you must call the returned callable, for example:
+
+ .. code-block:: python3
+
+ async def get_prefix(bot, message):
+ extras = await prefixes_for(message.guild) # returns a list
+ return commands.when_mentioned_or(*extras)(bot, message)
+
+
See Also
----------
:func:`.when_mentioned`