import discord from discord.ext import commands import aiohttp bot_embed_color = 0x4548A8 class Roleplay(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot async def _fetch_waifu(self, endpoint: str) -> str | None: """Fetch an image URL from waifu.pics for the given endpoint.""" url = f"https://api.waifu.pics/sfw/{endpoint}" try: async with aiohttp.ClientSession() as session: async with session.get(url, timeout=10) as resp: if resp.status != 200: return None data = await resp.json() return data.get("url") except Exception: return None @commands.hybrid_command(name="pat", aliases=["patting"]) async def pat(self, ctx: commands.Context, mentioned_member: discord.Member): """Pat someone""" image_url = await self._fetch_waifu("pat") em = discord.Embed( description=f"**{ctx.author.mention} _pats_ {mentioned_member.mention}**", color=bot_embed_color, ) if image_url: em.set_image(url=image_url) await ctx.reply(embed=em) @commands.hybrid_command(name="kiss", aliases=["kissing", "kisss"]) async def kiss(self, ctx: commands.Context, mentioned_member: discord.Member): """Kiss someone""" image_url = await self._fetch_waifu("kiss") em = discord.Embed( description=f"**{ctx.author.mention} _kisses_ {mentioned_member.mention}**", color=bot_embed_color, ) if image_url: em.set_image(url=image_url) await ctx.reply(embed=em) @commands.hybrid_command(name="highfive", aliases=["hfive", "hfv"]) async def highfive(self, ctx: commands.Context, mentioned_member: discord.Member): """Give someone a high five""" image_url = await self._fetch_waifu("highfive") if not image_url: image_url = await self._fetch_waifu("hug") em = discord.Embed( description=f"**{ctx.author.mention} _gives a high five to_ {mentioned_member.mention}**", color=bot_embed_color, ) if image_url: em.set_image(url=image_url) await ctx.reply(embed=em) async def setup(bot: commands.Bot): await bot.add_cog(Roleplay(bot))