Initial commit
This commit is contained in:
64
mentionhelp.py
Normal file
64
mentionhelp.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import discord
|
||||
from redbot.core import commands
|
||||
|
||||
|
||||
class MentionHelp(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
def build_help_embed(self, message, prefix_text, main_prefix):
|
||||
embed = discord.Embed(
|
||||
title="Pomoc",
|
||||
description=(
|
||||
f"Użyj `{main_prefix}help`, aby zobaczyć wszystkie komendy bota."
|
||||
),
|
||||
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]
|
||||
prefix_text = ", ".join(visible_prefixes) if visible_prefixes else ", ".join(prefixes)
|
||||
|
||||
embed = self.build_help_embed(message, prefix_text, main_prefix)
|
||||
await message.channel.send(embed=embed)
|
||||
Reference in New Issue
Block a user