better prefix
This commit is contained in:
parent
14d8310192
commit
12de975b69
@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
import discord.abc
|
import discord.abc
|
||||||
import discord.utils
|
import discord.utils
|
||||||
|
import re
|
||||||
|
|
||||||
class Context(discord.abc.Messageable):
|
class Context(discord.abc.Messageable):
|
||||||
r"""Represents the context in which a command is being invoked under.
|
r"""Represents the context in which a command is being invoked under.
|
||||||
@ -50,8 +51,6 @@ class Context(discord.abc.Messageable):
|
|||||||
A dictionary of transformed arguments that were passed into the command.
|
A dictionary of transformed arguments that were passed into the command.
|
||||||
Similar to :attr:`args`\, if this is accessed in the
|
Similar to :attr:`args`\, if this is accessed in the
|
||||||
:func:`on_command_error` event then this dict could be incomplete.
|
:func:`on_command_error` event then this dict could be incomplete.
|
||||||
prefix: :class:`str`
|
|
||||||
The prefix that was used to invoke the command.
|
|
||||||
command: :class:`Command`
|
command: :class:`Command`
|
||||||
The command that is being invoked currently.
|
The command that is being invoked currently.
|
||||||
invoked_with: :class:`str`
|
invoked_with: :class:`str`
|
||||||
@ -75,7 +74,7 @@ class Context(discord.abc.Messageable):
|
|||||||
self.bot = attrs.pop('bot', None)
|
self.bot = attrs.pop('bot', None)
|
||||||
self.args = attrs.pop('args', [])
|
self.args = attrs.pop('args', [])
|
||||||
self.kwargs = attrs.pop('kwargs', {})
|
self.kwargs = attrs.pop('kwargs', {})
|
||||||
self.prefix = attrs.pop('prefix')
|
self._prefix = attrs.pop('prefix')
|
||||||
self.command = attrs.pop('command', None)
|
self.command = attrs.pop('command', None)
|
||||||
self.view = attrs.pop('view', None)
|
self.view = attrs.pop('view', None)
|
||||||
self.invoked_with = attrs.pop('invoked_with', None)
|
self.invoked_with = attrs.pop('invoked_with', None)
|
||||||
@ -84,6 +83,13 @@ class Context(discord.abc.Messageable):
|
|||||||
self.command_failed = attrs.pop('command_failed', False)
|
self.command_failed = attrs.pop('command_failed', False)
|
||||||
self._state = self.message._state
|
self._state = self.message._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def prefix(self):
|
||||||
|
""":class:`str`: The cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``."""
|
||||||
|
user = self.guild.me if self.guild else self.bot.user
|
||||||
|
pattern = re.compile(r"<@!?%s>" % user.id)
|
||||||
|
return pattern.sub("@%s" % user.display_name.replace('\\', r'\\'), self._prefix)
|
||||||
|
|
||||||
async def invoke(self, *args, **kwargs):
|
async def invoke(self, *args, **kwargs):
|
||||||
r"""|coro|
|
r"""|coro|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user