Skip to content

Commit

Permalink
Fixed issue
Browse files Browse the repository at this point in the history
Fixed issue with ping command crashing while hamzie api is not avaliable
  • Loading branch information
Hamziee committed Aug 10, 2024
1 parent f011ec2 commit 2b7e797
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 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.6.1-beta | :white_check_mark: |
| < 0.6.1-beta | :x: |
| 0.6.2-beta | :white_check_mark: |
| < 0.6.2-beta | :x: |

## Reporting a Vulnerability

Expand Down
19 changes: 12 additions & 7 deletions commands/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ async def ping(self, interaction: discord.Interaction):
embed.set_footer(text=f"Ava | version: {config.AVA_VERSION}", icon_url=config.FOOTER_ICON)
await interaction.response.send_message(embed=embed)
end = time.time()
startapi = time.time()
async with httpx.AsyncClient() as client:
response = await client.get("https://api.hamzie.site/v1/gifs/hug")
response.raise_for_status()
endapi = time.time()
duration = round((end - start) * 100)
durationapi = round((endapi - startapi) * 100)
durationtext = f"{duration}ms"
try:
startapi = time.time()
async with httpx.AsyncClient() as client:
response = await client.get("https://api.hamzie.sitea/v1/gifs/hug")
response.raise_for_status()
endapi = time.time()
durationapi = round((endapi - startapi) * 100)
durationapitext = f"{durationapi}ms"
except:
durationapitext = "No Response"
embed = discord.Embed(
title="Pong!",
description=f"Discord API & Ava Latency: {duration}ms.\nHamzie API Latency: {durationapi}ms. \n\n**What does this mean?**\nLatency is calculated to measure the responsiveness and performance of the bot and the Discord server. It helps users assess the speed at which the bot can send and receive messages, providing valuable feedback on its operational efficiency. \n\nThis information is crucial for bot developers and users to ensure that the bot is functioning optimally and to identify any potential issues that may affect its performance.",
description=f"Discord API & Ava Latency: {durationtext}\nHamzie API Latency: {durationapitext} \n\n**What does this mean?**\nLatency is calculated to measure the responsiveness and performance of the bot and the Discord server. It helps users assess the speed at which the bot can send and receive messages, providing valuable feedback on its operational efficiency. \n\nThis information is crucial for bot developers and users to ensure that the bot is functioning optimally and to identify any potential issues that may affect its performance.",
color=discord.Color.blurple())
embed.set_footer(text=f"Ava | version: {config.AVA_VERSION}", icon_url=config.FOOTER_ICON)
await interaction.edit_original_response(embed=embed)
Expand Down
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.6.1-beta' # Do not change this, it will help with troubleshooting later
AVA_VERSION = 'v0.6.2-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 2b7e797

Please sign in to comment.