import discord from discord.ext import commands from typing import Optional class Music(commands.Cog): def __init__(self, bot): self.bot = bot # This is so you can access Bot instance in your cog # You must have this function for `bot.load_extension` to call def setup(bot): bot.add_cog(Music(bot)) @commands.hybrid_command( name="przytul", description="Przytul kogoś - daj mention po komendzie :)" ) async def przytul(ctx, arg: Optional[discord.Member] = None): """ Generate a text about hugging mentioned user. :param ctx: ctx stands for "context" and is a required parameter in Discord.py commands. It represents the context in which the command was invoked, including information such as the message, the channel, the server, and the user who invoked the command :param arg: arg is a parameter of the function "przytul" that expects a Discord member object. The parameter is optional, meaning that if no member object is provided, it will default to None :type arg: Optional[discord.Member] """ async with ctx.typing(): nieprzytulac = False for mention in ctx.message.mentions: for role in mention.roles: if role.name == "NIEPRZYTULAĆ!": nieprzytulac = True if arg and nieprzytulac: await ctx.send( f"Żebym ja Ciebie nie przytulił {ctx.message.author.mention}" ) elif arg: await ctx.send( # trunk-ignore(codespell/misspelled) f"Już dobrze.... Już dobrze... Ojej.. Biedactwo... :( *W ułamku sekundy {arg.mention} znajduje sie w duszącym uścisku. Żebra trzeszczą - kilka pęka. Pacnięcia po plecach grożą odbiciem nerek, a głaskanie po głowie powoduje wstrząs mózgu*" ) else: await ctx.send( "Kogo mam przytulić? *Wyłamuje kostki i przeciąga się - jego 200 kilowa sylwetka złożona z samych mięśni świadczy o tym że jest gotowy*" )