Skip to content

Commit

Permalink
Merge pull request #41 from Hamziee/dev
Browse files Browse the repository at this point in the history
Fix the tech info command
  • Loading branch information
Hamziee authored Nov 1, 2024
2 parents 39f282f + 0500834 commit 29e0d8c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 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.8.0-beta | :white_check_mark: |
| < 0.8.0-beta | :x: |
| 0.8.1-beta | :white_check_mark: |
| < 0.8.1-beta | :x: |

## Reporting a Vulnerability

Expand Down
43 changes: 22 additions & 21 deletions commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from discord import app_commands
import config
import sys
import pkg_resources
import requests
from importlib.metadata import distributions

class info(commands.Cog):
def __init__(self, client: commands.Bot):
Expand All @@ -14,41 +14,42 @@ def __init__(self, client: commands.Bot):
async def info(self, interaction: discord.Interaction):
try:
# Version Checker
# Get the content from the URL
url = "https://cdn.hamzie.site/Ava/VRC/core.txt"
response = requests.get(url)

# Check if the content matches the AVA_VERSION
if response.status_code == 200: # Make sure the request was successful
remote_version = response.text.strip()
else:
remote_version = "Failed to fetch."
remote_version = response.text.strip() if response.status_code == 200 else "Failed to fetch."

# TheCatAPI Check
if config.THECATAPI_KEY == 'your thecatapi key here':
cats_string = 'Disabled'
else:
cats_string = 'Enabled'

cats_string = 'Enabled' if config.THECATAPI_KEY != 'your thecatapi key here' else 'Disabled'

# Python Version
python_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"

# Get installed packages and format them
installed_packages = pkg_resources.working_set
package_list = "\n".join([f"{package.project_name} {package.version}" for package in installed_packages])

# Get installed packages and format them as a comma-separated list
package_list = [f"{dist.metadata['Name']} {dist.metadata['Version']}" for dist in distributions()]
package_string = ", ".join(package_list)

# Truncate the package string if it's too long
if len(package_string) > 1024:
package_string = package_string[:1021] + "..."

embed = discord.Embed(
color=discord.Colour.blurple(),
title="Technical Details",
description="If you are looking for information about the bot, run the command: '/about'")
embed.add_field(name='Core', value=f'Running Ava {config.AVA_VERSION} | (Latest: {remote_version})\nAva Config Version: {config.CONFIG_VERSION}\nPython {python_version}', inline=False)
embed.add_field(name="Python Packages", value=package_list, inline=False)
embed.add_field(name="Ava Optional Modules", value=f'AvaAI: Disabled - In Development | (Being Rewritten)\nTheCatAPI: {cats_string} | (Will be removed in favor of a new system that will be provided by Hamzie API)', inline=False)
embed.add_field(name="Python Packages", value=package_string, inline=False)
AvaAIver = "Disabled"
try:
import commands.AvaAI as AvaAI
AvaAIver = AvaAI.AvaAIver
except:
pass
embed.add_field(name="Ava Optional Modules", value=f'AvaAI: {AvaAIver} - In Development | (Being Rewritten)\nTheCatAPI: {cats_string} | (Will be removed in the future in favor of a new system that will be provided by Hamzie API)', inline=False)
embed.set_footer(text=f"Ava | version: {config.AVA_VERSION}", icon_url=config.FOOTER_ICON)
await interaction.response.send_message(embed=embed)
except Exception as e:
print(e)
await interaction.followup.send(content='Error occured.')
await interaction.followup.send(content='Error occurred.')

async def setup(client:commands.Bot) -> None:
await client.add_cog(info(client))
await client.add_cog(info(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.8.0-beta' # Do not change this, it will help with troubleshooting later
AVA_VERSION = 'v0.8.1-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 29e0d8c

Please sign in to comment.