From 0134ce240f1ddd25a574cb713dd76555c129b05f Mon Sep 17 00:00:00 2001 From: Migatu Date: Sun, 21 Apr 2024 16:21:32 +0200 Subject: [PATCH] First step towards cogization --- cogs/music.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cogs/music.py diff --git a/cogs/music.py b/cogs/music.py new file mode 100644 index 0000000..8d77915 --- /dev/null +++ b/cogs/music.py @@ -0,0 +1,46 @@ +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*" + )