diff options
| author | Rapptz <[email protected]> | 2017-01-26 05:05:04 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-26 05:05:15 -0500 |
| commit | 4016154529677857b324d1d3be74ef8a09e17d9e (patch) | |
| tree | f150fb22ff7153db510457b2207c1b521e379fee | |
| parent | Update examples to use the new generic wait_for. (diff) | |
| download | discord.py-4016154529677857b324d1d3be74ef8a09e17d9e.tar.xz discord.py-4016154529677857b324d1d3be74ef8a09e17d9e.zip | |
[commands] Allow customising the Context class in get_context.
| -rw-r--r-- | discord/ext/commands/bot.py | 12 |
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 |