Skip to content

Commit

Permalink
v0.5.0-beta
Browse files Browse the repository at this point in the history
# Added
* Head pats command.
  • Loading branch information
Hamziee authored May 29, 2024
2 parents 881b756 + 98af383 commit b1266d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
43 changes: 43 additions & 0 deletions commands/headpats.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion ex_config (change me to config.py).py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b1266d5

Please sign in to comment.