import discord from redbot.core import commands from redbot.core.i18n import get_locale_from_guild class MentionHelp(commands.Cog): def __init__(self, bot): self.bot = bot @staticmethod def _is_polish_locale(locale: str) -> bool: if not isinstance(locale, str): return False return locale.lower().startswith("pl") def build_help_embed(self, message, main_prefix, locale): is_polish = self._is_polish_locale(locale) title = "Pomoc" if is_polish else "Help" description = ( f"Użyj `{main_prefix}help`, aby zobaczyć wszystkie komendy bota." if is_polish else f"Use `{main_prefix}help` to see all bot commands." ) embed = discord.Embed( title=title, description=description, color=0xEB459E ) author_name = str(message.author) author_icon_url = message.author.display_avatar.url if message.author.display_avatar else None if author_icon_url: embed.set_author(name=author_name, icon_url=author_icon_url) else: embed.set_author(name=author_name) if message.guild: if message.guild.icon: embed.set_thumbnail(url=message.guild.icon.url) embed.set_footer( text=message.guild.name, icon_url=message.guild.icon.url ) else: embed.set_footer(text=message.guild.name) return embed @commands.Cog.listener() async def on_message_without_command(self, message): if message.author.bot: return if message.guild is None: return if self.bot.user is None: return mention_forms = { f"<@{self.bot.user.id}>", f"<@!{self.bot.user.id}>" } content = message.content.strip() if content in mention_forms: prefixes = await self.bot.get_valid_prefixes(message.guild) visible_prefixes = [p for p in prefixes if not p.startswith("<@")] main_prefix = visible_prefixes[0] if visible_prefixes else prefixes[0] try: locale = await get_locale_from_guild(self.bot, message.guild) except Exception: locale = "en-US" if not isinstance(locale, str) or not locale.strip(): locale = "en-US" embed = self.build_help_embed(message, main_prefix, locale) await message.channel.send(embed=embed)