diff --git a/localization/strings.en-US.json b/localization/strings.en-US.json index 1368788..c4eea1b 100644 --- a/localization/strings.en-US.json +++ b/localization/strings.en-US.json @@ -178,7 +178,7 @@ "greet_default_description": "_ _\n**Welcome** to **{0}**", "greet_template_description": "↓↓↓\n{0}", "help_use_prefix": "Please use Lumi's prefix to get help. Type `{0}help`", - "info_api_version": "**API:** v{0}\n", + "info_api_version": "**discord.py:** v{0}\n", "info_database_records": "**Database:** {0} records", "info_latency": "**Latency:** {0}ms\n", "info_memory": "**Memory:** {0:.2f} MB\n", diff --git a/modules/misc/info.py b/modules/misc/info.py new file mode 100644 index 0000000..ffadf88 --- /dev/null +++ b/modules/misc/info.py @@ -0,0 +1,49 @@ +from discord.ext import commands +from lib.const import CONST +from ui.embeds import builder +import discord +import os +import platform +import psutil + + +class Info(commands.Cog): + def __init__(self, bot: commands.Bot): + self.bot = bot + + @commands.hybrid_command( + name="info", + usage="info", + ) + async def info(self, ctx: commands.Context[commands.Bot]) -> None: + memory_usage_in_mb: float = psutil.Process().memory_info().rss / (1024 * 1024) + # total_rows: str = Currency.format(BlackJackStats.get_total_rows_count()) + + description: str = "".join( + [ + CONST.STRINGS["info_latency"].format(round(1000 * self.bot.latency)), + CONST.STRINGS["info_memory"].format(memory_usage_in_mb), + CONST.STRINGS["info_system"].format(platform.system(), os.name), + CONST.STRINGS["info_api_version"].format(discord.__version__), + # CONST.STRINGS["info_database_records"].format(total_rows), + ], + ) + + embed: discord.Embed = builder.create_success_embed( + ctx, + description=description, + footer_text=CONST.STRINGS["info_service_footer"], + show_name=False, + ) + embed.set_author( + name=f"{CONST.TITLE} v{CONST.VERSION}", + url=CONST.REPO_URL, + icon_url=CONST.CHECK_ICON, + ) + embed.set_thumbnail(url=CONST.LUMI_LOGO_OPAQUE) + + await ctx.send(embed=embed) + + +async def setup(bot: commands.Bot) -> None: + await bot.add_cog(Info(bot)) diff --git a/poetry.lock b/poetry.lock index 98a689d..ac0753e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -664,6 +664,35 @@ nodeenv = ">=0.11.1" pyyaml = ">=5.1" virtualenv = ">=20.10.0" +[[package]] +name = "psutil" +version = "6.0.0" +description = "Cross-platform lib for process and system monitoring in Python." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" +files = [ + {file = "psutil-6.0.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a021da3e881cd935e64a3d0a20983bda0bb4cf80e4f74fa9bfcb1bc5785360c6"}, + {file = "psutil-6.0.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:1287c2b95f1c0a364d23bc6f2ea2365a8d4d9b726a3be7294296ff7ba97c17f0"}, + {file = "psutil-6.0.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:a9a3dbfb4de4f18174528d87cc352d1f788b7496991cca33c6996f40c9e3c92c"}, + {file = "psutil-6.0.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:6ec7588fb3ddaec7344a825afe298db83fe01bfaaab39155fa84cf1c0d6b13c3"}, + {file = "psutil-6.0.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:1e7c870afcb7d91fdea2b37c24aeb08f98b6d67257a5cb0a8bc3ac68d0f1a68c"}, + {file = "psutil-6.0.0-cp27-none-win32.whl", hash = "sha256:02b69001f44cc73c1c5279d02b30a817e339ceb258ad75997325e0e6169d8b35"}, + {file = "psutil-6.0.0-cp27-none-win_amd64.whl", hash = "sha256:21f1fb635deccd510f69f485b87433460a603919b45e2a324ad65b0cc74f8fb1"}, + {file = "psutil-6.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:c588a7e9b1173b6e866756dde596fd4cad94f9399daf99ad8c3258b3cb2b47a0"}, + {file = "psutil-6.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ed2440ada7ef7d0d608f20ad89a04ec47d2d3ab7190896cd62ca5fc4fe08bf0"}, + {file = "psutil-6.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fd9a97c8e94059b0ef54a7d4baf13b405011176c3b6ff257c247cae0d560ecd"}, + {file = "psutil-6.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e2e8d0054fc88153ca0544f5c4d554d42e33df2e009c4ff42284ac9ebdef4132"}, + {file = "psutil-6.0.0-cp36-cp36m-win32.whl", hash = "sha256:fc8c9510cde0146432bbdb433322861ee8c3efbf8589865c8bf8d21cb30c4d14"}, + {file = "psutil-6.0.0-cp36-cp36m-win_amd64.whl", hash = "sha256:34859b8d8f423b86e4385ff3665d3f4d94be3cdf48221fbe476e883514fdb71c"}, + {file = "psutil-6.0.0-cp37-abi3-win32.whl", hash = "sha256:a495580d6bae27291324fe60cea0b5a7c23fa36a7cd35035a16d93bdcf076b9d"}, + {file = "psutil-6.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:33ea5e1c975250a720b3a6609c490db40dae5d83a4eb315170c4fe0d8b1f34b3"}, + {file = "psutil-6.0.0-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:ffe7fc9b6b36beadc8c322f84e1caff51e8703b88eee1da46d1e3a6ae11b4fd0"}, + {file = "psutil-6.0.0.tar.gz", hash = "sha256:8faae4f310b6d969fa26ca0545338b21f73c6b15db7c4a8d934a5482faa818f2"}, +] + +[package.extras] +test = ["enum34", "ipaddress", "mock", "pywin32", "wmi"] + [[package]] name = "pyright" version = "1.1.377" @@ -933,4 +962,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "78b6fb1bf2b5060cbb9ea5cbb840431d96e582c2cecb50b234ddb38d70c17494" +content-hash = "a93d83011121cab87e99209358e145ad73b8da37720436992597d707b0e2e607" diff --git a/pyproject.toml b/pyproject.toml index ec93ced..8e8aad0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ typing-extensions = "^4.12.2" aiofiles = "^24.1.0" aiocache = "^0.12.2" aioconsole = "^0.7.1" +psutil = "^6.0.0" [build-system] build-backend = "poetry.core.masonry.api" diff --git a/settings.yaml b/settings.yaml index 32138db..1674d01 100644 --- a/settings.yaml +++ b/settings.yaml @@ -2,7 +2,7 @@ info: title: Luminara author: wlinator license: GNU General Public License v3.0 - version: "v3.0.0-alpha" + version: "3.0.0-alpha" repository_url: https://git.wlinator.org/Luminara/Lumi invite_url: https://discord.com/oauth2/authorize?client_id=1038050427272429588&permissions=8&scope=bot