[commands] Allow customising the Context class in get_context.
This commit is contained in:
parent
1e09432c45
commit
4016154529
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user