From 98af383a688f5d4e5f23391efb0846af9d6a76ef Mon Sep 17 00:00:00 2001 From: Hamza Date: Thu, 30 May 2024 00:53:47 +0200 Subject: [PATCH] v0.5.0-beta --- SECURITY.md | 4 +-- commands/headpats.py | 43 +++++++++++++++++++++++++++ ex_config (change me to config.py).py | 2 +- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 commands/headpats.py diff --git a/SECURITY.md b/SECURITY.md index f11799c..1057947 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,8 +6,8 @@ The following versions will receive security updates as needed: | Version | Supported | | ------------ | ------------------ | -| 0.4.1-beta | :white_check_mark: | -| < 0.4.1-beta | :x: | +| 0.5.0-beta | :white_check_mark: | +| < 0.5.0-beta | :x: | ## Reporting a Vulnerability diff --git a/commands/headpats.py b/commands/headpats.py new file mode 100644 index 0000000..f40587c --- /dev/null +++ b/commands/headpats.py @@ -0,0 +1,43 @@ +import discord +from discord.ext import commands +from discord import app_commands +import httpx +from datetime import datetime +import config + +class headpats(commands.Cog): + def __init__(self, client: commands.Bot): + self.client = client + + @app_commands.command(name="headpats", description="Give headpats to your friend/lover!") + @app_commands.rename(member='person') + async def headpats(self, interaction: discord.Interaction, member: discord.Member): + try: + async with httpx.AsyncClient() as client: + response = await client.get("https://api.hamzie.site/v1/gifs/headpats") + response.raise_for_status() + data = response.json() + image_url = data["link"] + embed = discord.Embed( + color=discord.Colour.blurple() + ) + embed.set_image(url=image_url) + embed.set_footer(text=f"Ava | version: {config.AVA_VERSION} - Image by: api.hamzie.site", icon_url=config.FOOTER_ICON) + + if member.id == interaction.user.id: + await interaction.response.send_message(content="You can't give headpats to yourself! But here, let me give you some headpats! <:AVA_headpat:1245509705703362560>", embed=embed) + return + if member.id == config.BOT_ID: + await interaction.response.send_message(content="Here, let me give you some headpats! <:AVA_headpat:1245509705703362560>", embed=embed) + return + if member.bot: + await interaction.response.send_message(content="Bots don't need headpats! But I do, so here are some headpats for you! <:AVA_headpat:1245509705703362560>", embed=embed) + return + await interaction.response.send_message(content= f"{interaction.user.mention} gives headpats to {member.mention} <:AVA_headpat:1245509705703362560>", embed=embed) + except httpx.HTTPError as http_err: + print(f'HTTP error occurred: {http_err}') + except Exception as err: + print(f'An error occurred: {err}') + +async def setup(client:commands.Bot) -> None: + await client.add_cog(headpats(client)) \ No newline at end of file diff --git a/ex_config (change me to config.py).py b/ex_config (change me to config.py).py index 3755a3a..943cb5b 100644 --- a/ex_config (change me to config.py).py +++ b/ex_config (change me to config.py).py @@ -1,4 +1,4 @@ -AVA_VERSION = 'v0.4.1-beta' # Do not change this, it will help with troubleshooting later +AVA_VERSION = 'v0.5.0-beta' # Do not change this, it will help with troubleshooting later CONFIG_VERSION = 3 # Do not change this, it will help with troubleshooting later # Required Bot Configuration