Skip to content

Commit

Permalink
Merge pull request #31 from Hamziee/dev
Browse files Browse the repository at this point in the history
v0.6.0-beta
# Added
* Slap command.
  • Loading branch information
Hamziee authored May 30, 2024
2 parents ec9974c + fdb1053 commit dcd4a4a
Show file tree
Hide file tree
Showing 3 changed files with 60 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.5.1-beta | :white_check_mark: |
| < 0.5.1-beta | :x: |
| 0.6.0-beta | :white_check_mark: |
| < 0.6.0-beta | :x: |

## Reporting a Vulnerability

Expand Down
57 changes: 57 additions & 0 deletions commands/slap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import discord
from discord.ext import commands
from discord import app_commands
import httpx
from datetime import datetime
import config

class Slap(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@app_commands.command(name="slap", description="Slap your friend/lover!")
@app_commands.rename(member='person')
async def slap(self, interaction: discord.Interaction, member: discord.Member):
try:
async with httpx.AsyncClient() as client:
if member.id == interaction.user.id:
response = await client.get("https://api.hamzie.site/v1/gifs/hug")
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)
await interaction.response.send_message(content="You don't need to slap yourself! How about a hug instead?", embed=embed)
return
if member.id == config.BOT_ID:
response = await client.get("https://api.hamzie.site/v1/gifs/hug")
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)
await interaction.response.send_message(content="Hey, you can't slap me! But it's okay, here's a hug for you.", embed=embed)
return
response = await client.get("https://api.hamzie.site/v1/gifs/slap")
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)
await interaction.response.send_message(content=f"{interaction.user.mention} slaps {member.mention}", 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(Slap(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.5.1-beta' # Do not change this, it will help with troubleshooting later
AVA_VERSION = 'v0.6.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 dcd4a4a

Please sign in to comment.