Skip to content

Commit

Permalink
Filter out mention prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Jan 28, 2024
1 parent 04d0f57 commit 8e225c6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions bot/cogs/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Annotated, Optional
from typing import TYPE_CHECKING, Annotated, Optional, Union

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

def clean_prefixes(self, prefixes: Union[str, list[str]]) -> str:
if isinstance(prefixes, str):
return f"`{prefixes}`"

return ", ".join(f"`{prefix}`" for prefix in prefixes[2:])

@check_permissions(manage_guild=True)
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
@commands.guild_only()
Expand Down Expand Up @@ -355,13 +361,9 @@ async def prefix(self, ctx: GuildContext) -> None:
Passing in no subcommands will effectively show the currently set prefixes.
"""
user_id = self.bot.user.id # type: ignore
prefixes = await get_prefix(self.bot, ctx.message)
cleaned = ", ".join(
f"`{prefix}`" for prefix in prefixes if str(user_id) not in prefix
)
embed = Embed()
embed.add_field(name="Prefixes", value=cleaned)
embed.add_field(name="Prefixes", value=self.clean_prefixes(prefixes))
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon.url) # type: ignore
await ctx.send(embed=embed)

Expand Down

0 comments on commit 8e225c6

Please sign in to comment.