aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/ext/commands/bot.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index 589e4a6b..5eb40f1c 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -555,7 +555,7 @@ class BotBase(GroupMixin):
return prefix
@asyncio.coroutine
- def get_context(self, message):
+ def get_context(self, message, *, cls=Context):
"""|coro|
Returns the invocation context from the message.
@@ -572,15 +572,21 @@ class BotBase(GroupMixin):
-----------
message: :class:`discord.Message`
The message to get the invocation context from.
+ cls: type
+ The factory class that will be used to create the context.
+ By default, this is :class:`Context`. Should a custom
+ class be provided, it must be similar enough to :class:`Context`\'s
+ interface.
Returns
--------
:class:`Context`
- The invocation context.
+ The invocation context. The type of this can change via the
+ ``cls`` parameter.
"""
view = StringView(message.content)
- ctx = Context(prefix=None, view=view, bot=self, message=message)
+ ctx = cls(prefix=None, view=view, bot=self, message=message)
if self._skip_check(message.author.id, self.user.id):
return ctx