[Docs] Clarify documentation for Context.clean_prefix (#4135)

* change docstring for Context.clean_prefix

* "tyop"
This commit is contained in:
Dav 2020-08-06 01:54:48 +00:00 committed by GitHub
parent 068ce24513
commit f65ff87b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,14 +259,18 @@ class Context(DPYContext):
@property
def clean_prefix(self) -> str:
"""str: The command prefix, but a mention prefix is displayed nicer."""
"""
str: The command prefix, but with a sanitized version of the bot's mention if it was used as prefix.
This can be used in a context where discord user mentions might not render properly.
"""
me = self.me
pattern = re.compile(rf"<@!?{me.id}>")
return pattern.sub(f"@{me.display_name}".replace("\\", r"\\"), self.prefix)
@property
def me(self) -> Union[discord.ClientUser, discord.Member]:
"""discord.abc.User: The bot member or user object.
"""
discord.abc.User: The bot member or user object.
If the context is DM, this will be a `discord.User` object.
"""