diff --git a/changelog.d/3249.bugfix.rst b/changelog.d/3249.bugfix.rst new file mode 100644 index 000000000..9af43d8a6 --- /dev/null +++ b/changelog.d/3249.bugfix.rst @@ -0,0 +1 @@ +Fix ``ctx.clean_prefix`` for undocumented changes from discord diff --git a/redbot/core/commands/context.py b/redbot/core/commands/context.py index a4e999f3b..d07f73103 100644 --- a/redbot/core/commands/context.py +++ b/redbot/core/commands/context.py @@ -1,5 +1,6 @@ import asyncio import contextlib +import re from typing import Iterable, List, Union import discord from discord.ext import commands @@ -249,7 +250,8 @@ class Context(commands.Context): def clean_prefix(self) -> str: """str: The command prefix, but a mention prefix is displayed nicer.""" me = self.me - return self.prefix.replace(me.mention, f"@{me.display_name}") + pattern = re.compile(rf"<@!?{me.id}>") + return pattern.sub(f"@{me.display_name}", self.prefix) @property def me(self) -> discord.abc.User: