mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
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:
parent
f2d2b9a682
commit
9ec78d1455
1
changelog.d/3249.bugfix.rst
Normal file
1
changelog.d/3249.bugfix.rst
Normal file
@ -0,0 +1 @@
|
||||
Fix ``ctx.clean_prefix`` for undocumented changes from discord
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user