|
| 1 | +import aiohttp |
| 2 | +import discord |
| 3 | +import orjson |
| 4 | +from discord import app_commands |
| 5 | +from discord.ext import commands |
| 6 | +from Libs.utils import Embed |
| 7 | + |
| 8 | + |
| 9 | +class Actions(commands.Cog): |
| 10 | + """Hug, pet, or kiss someone on Discord!""" |
| 11 | + |
| 12 | + def __init__(self, bot: commands.Bot) -> None: |
| 13 | + self.bot = bot |
| 14 | + |
| 15 | + @commands.hybrid_command(name="hug") |
| 16 | + @app_commands.describe(user="The user to hug") |
| 17 | + async def hug(self, ctx: commands.Context, user: discord.Member) -> None: |
| 18 | + """Hug someone on Discord!""" |
| 19 | + async with aiohttp.ClientSession() as session: |
| 20 | + async with session.get("https://nekos.life/api/v2/img/hug") as r: |
| 21 | + data = await r.json(loads=orjson.loads) |
| 22 | + embed = Embed(title=f"{ctx.author.name} hugs {user.name}!") |
| 23 | + embed.set_image(url=data["url"]) |
| 24 | + await ctx.send(embed=embed) |
| 25 | + |
| 26 | + @commands.hybrid_command(name="pat") |
| 27 | + @app_commands.describe(user="The user to pat") |
| 28 | + async def pat(self, ctx: commands.Context, user: discord.Member) -> None: |
| 29 | + """Give someone a headpat!""" |
| 30 | + async with aiohttp.ClientSession() as session: |
| 31 | + async with session.get("https://nekos.life/api/v2/img/pat") as r: |
| 32 | + data = await r.json(loads=orjson.loads) |
| 33 | + embed = Embed(title=f"{ctx.author.name} pats {user.name}!") |
| 34 | + embed.set_image(url=data["url"]) |
| 35 | + await ctx.send(embed=embed) |
| 36 | + |
| 37 | + @commands.hybrid_command(name="kiss") |
| 38 | + @app_commands.describe(user="The user to kiss") |
| 39 | + async def kiss(self, ctx: commands.Context, user: discord.Member) -> None: |
| 40 | + """Give someone a kiss!""" |
| 41 | + async with aiohttp.ClientSession() as session: |
| 42 | + async with session.get("https://nekos.life/api/v2/img/kiss") as r: |
| 43 | + data = await r.json(loads=orjson.loads) |
| 44 | + embed = Embed(title=f"{ctx.author.name} kisses {user.name}!") |
| 45 | + embed.set_image(url=data["url"]) |
| 46 | + await ctx.send(embed=embed) |
| 47 | + |
| 48 | + @commands.hybrid_command(name="cuddle") |
| 49 | + @app_commands.describe(user="The user to cuddle") |
| 50 | + async def cuddle(self, ctx: commands.Context, user: discord.Member) -> None: |
| 51 | + """Cuddle someone on Discord!""" |
| 52 | + async with aiohttp.ClientSession() as session: |
| 53 | + async with session.get("https://nekos.life/api/v2/img/cuddle") as r: |
| 54 | + data = await r.json(loads=orjson.loads) |
| 55 | + embed = Embed(title=f"{ctx.author.name} cuddles {user.name}!") |
| 56 | + embed.set_image(url=data["url"]) |
| 57 | + await ctx.send(embed=embed) |
| 58 | + |
| 59 | + @commands.hybrid_command(name="slap") |
| 60 | + @app_commands.describe(user="The user to slap") |
| 61 | + async def slap(self, ctx: commands.Context, user: discord.Member) -> None: |
| 62 | + """Slaps someone on Discord!""" |
| 63 | + async with aiohttp.ClientSession() as session: |
| 64 | + async with session.get("https://nekos.life/api/v2/img/slap") as r: |
| 65 | + data = await r.json(loads=orjson.loads) |
| 66 | + embed = Embed(title=f"{ctx.author.name} slaps {user.name}!") |
| 67 | + embed.set_image(url=data["url"]) |
| 68 | + await ctx.send(embed=embed) |
| 69 | + |
| 70 | + @commands.hybrid_command(name="tickle") |
| 71 | + @app_commands.describe(user="The user to tickle") |
| 72 | + async def tickles(self, ctx: commands.Context, user: discord.Member) -> None: |
| 73 | + """Tickle someone on Discord!""" |
| 74 | + async with aiohttp.ClientSession() as session: |
| 75 | + async with session.get("https://nekos.life/api/v2/img/tickle") as r: |
| 76 | + data = await r.json(loads=orjson.loads) |
| 77 | + embed = Embed(title=f"{ctx.author.name} tickles {user.name}!") |
| 78 | + embed.set_image(url=data["url"]) |
| 79 | + await ctx.send(embed=embed) |
| 80 | + |
| 81 | + @commands.hybrid_command(name="poke") |
| 82 | + @app_commands.describe(user="The user to poke") |
| 83 | + async def poke(self, ctx: commands.Context, user: discord.Member) -> None: |
| 84 | + """Poke someone on Discord!""" |
| 85 | + async with aiohttp.ClientSession() as session: |
| 86 | + async with session.get("https://nekos.life/api/v2/img/poke") as r: |
| 87 | + data = await r.json(loads=orjson.loads) |
| 88 | + embed = Embed(title=f"{ctx.author.name} pokes {user.name}!") |
| 89 | + embed.set_image(url=data["url"]) |
| 90 | + await ctx.send(embed=embed) |
| 91 | + |
| 92 | + |
| 93 | +async def setup(bot: commands.Bot) -> None: |
| 94 | + await bot.add_cog(Actions(bot)) |
0 commit comments