Fix ctx.clean_prefix for *new* discord behavior (#3249)

* I just love when discord changes important syntax without warning

  - sarcasm approaching dangerous levels

* changelog
This commit is contained in:
Michael H 2020-01-04 14:08:35 -05:00 committed by GitHub
parent f2d2b9a682
commit 9ec78d1455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix ``ctx.clean_prefix`` for undocumented changes from discord

View File

@ -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: