From 2b7e797f4a551823f3a6d8e6c09a0e4cc8c74fcd Mon Sep 17 00:00:00 2001 From: Hamza Date: Sat, 10 Aug 2024 22:43:59 +0200 Subject: [PATCH] Fixed issue Fixed issue with ping command crashing while hamzie api is not avaliable --- SECURITY.md | 4 ++-- commands/ping.py | 19 ++++++++++++------- ex_config (change me to config.py).py | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 4e1b233..48d583f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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 diff --git a/commands/ping.py b/commands/ping.py index 55f5216..57a8188 100644 --- a/commands/ping.py +++ b/commands/ping.py @@ -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) diff --git a/ex_config (change me to config.py).py b/ex_config (change me to config.py).py index 49ee01b..67c4ae3 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.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