mirror of
https://gitlab.com/pancakes1234/wdiscordbotserver.git
synced 2025-06-16 07:14:21 -06:00
Merge branch 'metrics-rename-pr' into 'main'
Groups metrics commands under a common namespace See merge request pancakes1234/wdiscordbotserver!1
This commit is contained in:
commit
cb855c468a
@ -7,11 +7,13 @@ class MetricsCog(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(
|
||||
name="metrics",
|
||||
description="Display live bot metrics."
|
||||
metrics_group = app_commands.Group(name="metrics", description="Access various bot metrics")
|
||||
|
||||
@metrics_group.command(
|
||||
name="local",
|
||||
description="Display live bot metrics (calculated locally)."
|
||||
)
|
||||
async def metrics(self, interaction: discord.Interaction) -> None:
|
||||
async def local_metrics(self, interaction: discord.Interaction) -> None:
|
||||
# Calculate live metrics.
|
||||
now = datetime.utcnow()
|
||||
uptime_delta = now - self.bot.launch_time
|
||||
|
@ -2,16 +2,17 @@ import discord
|
||||
from discord.ext import commands
|
||||
from discord import app_commands
|
||||
import aiohttp
|
||||
from cogs.apisync import MetricsCog # Import MetricsCog to access its group
|
||||
|
||||
class MetricsDisplayCog(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
@app_commands.command(
|
||||
name="metrics",
|
||||
@MetricsCog.metrics_group.command( # Use the group from MetricsCog
|
||||
name="api", # Change name to "api"
|
||||
description="Displays live bot metrics fetched from the API."
|
||||
)
|
||||
async def metrics(self, interaction: discord.Interaction) -> None:
|
||||
async def api_metrics(self, interaction: discord.Interaction) -> None: # Rename method
|
||||
# URL of your metrics API endpoint.
|
||||
url = "https://api.learnhelp.cc/discord/botmetrics.json/"
|
||||
|
||||
@ -55,4 +56,4 @@ class MetricsDisplayCog(commands.Cog):
|
||||
)
|
||||
|
||||
async def setup(bot: commands.Bot) -> None:
|
||||
await bot.add_cog(MetricsDisplayCog(bot))
|
||||
await bot.add_cog(MetricsDisplayCog(bot))
|
||||
|
Loading…
x
Reference in New Issue
Block a user