From 0500834b8b37620d4f8948c2d1f0bfbfb6d0b1c5 Mon Sep 17 00:00:00 2001 From: Hamza Date: Fri, 1 Nov 2024 16:55:55 +0100 Subject: [PATCH] Fix the tech info command --- SECURITY.md | 4 +-- commands/info.py | 43 ++++++++++++++------------- ex_config (change me to config.py).py | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index dfbdd78..8a1dc7e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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 diff --git a/commands/info.py b/commands/info.py index ce61f56..2daec78 100644 --- a/commands/info.py +++ b/commands/info.py @@ -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): @@ -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)) \ No newline at end of file + await client.add_cog(info(client)) diff --git a/ex_config (change me to config.py).py b/ex_config (change me to config.py).py index aa57f1f..3cc8d21 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.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