mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-12 08:49:48 +00:00
parent
434d6dc347
commit
fce2ef5534
@ -785,20 +785,33 @@ class BotBase(GroupMixin):
|
|||||||
message: :class:`discord.Message`
|
message: :class:`discord.Message`
|
||||||
The message context to get the prefix of.
|
The message context to get the prefix of.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
--------
|
||||||
|
:exc:`.ClientException`
|
||||||
|
The prefix was invalid. This could be if the prefix
|
||||||
|
function returned None, the prefix list returned no
|
||||||
|
elements that aren't None, or the prefix string is
|
||||||
|
empty.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
--------
|
--------
|
||||||
Union[List[str], str]
|
Union[List[str], str]
|
||||||
A list of prefixes or a single prefix that the bot is
|
A list of prefixes or a single prefix that the bot is
|
||||||
listening for.
|
listening for.
|
||||||
"""
|
"""
|
||||||
prefix = self.command_prefix
|
prefix = ret = self.command_prefix
|
||||||
if callable(prefix):
|
if callable(prefix):
|
||||||
ret = prefix(self, message)
|
ret = prefix(self, message)
|
||||||
if asyncio.iscoroutine(ret):
|
if asyncio.iscoroutine(ret):
|
||||||
ret = yield from ret
|
ret = yield from ret
|
||||||
return ret
|
|
||||||
else:
|
if isinstance(ret, (list, tuple)):
|
||||||
return prefix
|
ret = [p for p in ret if p]
|
||||||
|
|
||||||
|
if not ret:
|
||||||
|
raise ClientException('invalid prefix (could be an empty string, empty list, or None)')
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def get_context(self, message, *, cls=Context):
|
def get_context(self, message, *, cls=Context):
|
||||||
@ -840,7 +853,7 @@ class BotBase(GroupMixin):
|
|||||||
prefix = yield from self.get_prefix(message)
|
prefix = yield from self.get_prefix(message)
|
||||||
invoked_prefix = prefix
|
invoked_prefix = prefix
|
||||||
|
|
||||||
if not isinstance(prefix, (tuple, list)):
|
if isinstance(prefix, str):
|
||||||
if not view.skip_string(prefix):
|
if not view.skip_string(prefix):
|
||||||
return ctx
|
return ctx
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user