Skip to content

Commit 8e225c6

Browse files
committed
Filter out mention prefixes
1 parent 04d0f57 commit 8e225c6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

bot/cogs/config.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Annotated, Optional
3+
from typing import TYPE_CHECKING, Annotated, Optional, Union
44

55
import asyncpg
66
import discord
@@ -133,6 +133,12 @@ async def get_guild_config(self, guild_id: int) -> Optional[GuildConfig]:
133133
config = GuildConfig(bot=self.bot, **dict(rows))
134134
return config
135135

136+
def clean_prefixes(self, prefixes: Union[str, list[str]]) -> str:
137+
if isinstance(prefixes, str):
138+
return f"`{prefixes}`"
139+
140+
return ", ".join(f"`{prefix}`" for prefix in prefixes[2:])
141+
136142
@check_permissions(manage_guild=True)
137143
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
138144
@commands.guild_only()
@@ -355,13 +361,9 @@ async def prefix(self, ctx: GuildContext) -> None:
355361
356362
Passing in no subcommands will effectively show the currently set prefixes.
357363
"""
358-
user_id = self.bot.user.id # type: ignore
359364
prefixes = await get_prefix(self.bot, ctx.message)
360-
cleaned = ", ".join(
361-
f"`{prefix}`" for prefix in prefixes if str(user_id) not in prefix
362-
)
363365
embed = Embed()
364-
embed.add_field(name="Prefixes", value=cleaned)
366+
embed.add_field(name="Prefixes", value=self.clean_prefixes(prefixes))
365367
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon.url) # type: ignore
366368
await ctx.send(embed=embed)
367369

0 commit comments

Comments
 (0)