mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 22:23:13 +00:00
Add stats command
This commit is contained in:
parent
c58b0dfcf3
commit
1187d93735
5 changed files with 60 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"emotes_guild_id": 1038051105642401812,
|
||||
"gitlab_url": "https://gitlab.com/wlinator/Racu",
|
||||
"author_url": "<https://discord.com/users/784783517845946429>",
|
||||
"guild_specific": {
|
||||
"guild_id": 719227135151046699,
|
||||
"intro_channel_id": 973619250507972618,
|
||||
|
@ -20,7 +22,8 @@
|
|||
"icons": {
|
||||
"racu_exclam": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_exclam.png",
|
||||
"racu_question": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_question.png",
|
||||
"racu_streak": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_streak.png"
|
||||
"racu_streak": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_streak.png",
|
||||
"racu_logo": "https://gitlab.com/wlinator/Racu/-/raw/main/art/racu_logo.png"
|
||||
},
|
||||
"blackjack": {
|
||||
"emotes": {
|
||||
|
|
|
@ -4,8 +4,7 @@ import discord
|
|||
from discord.ext import commands, bridge, tasks
|
||||
from lib import checks
|
||||
from lib.embeds.info import MiscInfo
|
||||
from lib.embeds.error import IntroErrors
|
||||
from modules.misc import introduction, invite, backup
|
||||
from modules.misc import introduction, invite, backup, info
|
||||
from modules.config import prefix
|
||||
|
||||
|
||||
|
@ -60,6 +59,17 @@ class Misc(commands.Cog):
|
|||
async def prefix_command(self, ctx):
|
||||
return await prefix.get_cmd(ctx)
|
||||
|
||||
@bridge.bridge_command(
|
||||
name="info",
|
||||
aliases=["stats"]
|
||||
)
|
||||
async def info_command(self, ctx):
|
||||
"""
|
||||
Shows basic stats for Racu.
|
||||
"""
|
||||
unix_timestamp = int(round(self.start_time.timestamp()))
|
||||
return await info.cmd(self, ctx, unix_timestamp)
|
||||
|
||||
@bridge.bridge_command(
|
||||
name="introduction",
|
||||
aliases=["intro", "introduce"],
|
||||
|
|
33
modules/misc/info.py
Normal file
33
modules/misc/info.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import logging
|
||||
import discord
|
||||
from config.parser import JsonCache
|
||||
from lib import metadata
|
||||
from services.BlackJackStats import BlackJackStats
|
||||
from services.Currency import Currency
|
||||
import psutil
|
||||
|
||||
_logs = logging.getLogger('Racu.Core')
|
||||
_data = JsonCache.read_json("resources")
|
||||
|
||||
|
||||
async def cmd(command, ctx, unix_timestamp):
|
||||
memory_usage = psutil.Process().memory_info().rss
|
||||
memory_usage_in_mb = memory_usage / (1024 * 1024)
|
||||
|
||||
total_rows = BlackJackStats.get_total_rows_count()
|
||||
total_rows = Currency.format(total_rows)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=discord.Color.orange()
|
||||
)
|
||||
embed.set_author(name=f"{metadata.__title__} v{metadata.__version__}",
|
||||
url=_data["gitlab_url"],
|
||||
icon_url=_data["icons"]["racu_logo"])
|
||||
|
||||
embed.add_field(name="Author", value=f"[{metadata.__author__}]({_data['author_url']})", inline=False)
|
||||
embed.add_field(name="Uptime", value=f"<t:{unix_timestamp}:R>", inline=False)
|
||||
embed.add_field(name="Latency", value=f"{round(1000 * command.client.latency)}ms", inline=False)
|
||||
embed.add_field(name="Memory", value=f"{memory_usage_in_mb:.2f} MB", inline=False)
|
||||
embed.add_field(name="Database", value=f"{total_rows} records", inline=False)
|
||||
|
||||
return await ctx.respond(embed=embed)
|
|
@ -3,4 +3,5 @@ python-dotenv==1.0.0
|
|||
setuptools==67.8.0
|
||||
pytz==2023.3
|
||||
dropbox==11.36.2
|
||||
mysql-connector-python==8.1.0
|
||||
mysql-connector-python==8.1.0
|
||||
psutil==5.9.8
|
|
@ -44,3 +44,12 @@ class BlackJackStats:
|
|||
"winning_amount": winning_amount,
|
||||
"losing_amount": losing_amount
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def get_total_rows_count():
|
||||
query = """
|
||||
SELECT SUM(TABLE_ROWS)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
"""
|
||||
|
||||
return database.select_query_one(query)
|
||||
|
|
Loading…
Reference in a new issue