From f3586183252e02abf14fc0b628fa35b9320fa240 Mon Sep 17 00:00:00 2001 From: John Wuller <847785bd-d466-47cd-a536-eae4096d241d@anonaddy.me> Date: Sat, 15 Jun 2024 16:42:40 -0400 Subject: [PATCH] Fix the logging of subcommands --- discord/ext/prometheus/prometheus_cog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discord/ext/prometheus/prometheus_cog.py b/discord/ext/prometheus/prometheus_cog.py index 0633ace..d1eaeff 100644 --- a/discord/ext/prometheus/prometheus_cog.py +++ b/discord/ext/prometheus/prometheus_cog.py @@ -2,6 +2,7 @@ from prometheus_client import start_http_server, Counter, Gauge from discord.ext import commands, tasks from discord import Interaction, InteractionType, AutoShardedClient +from discord.app_commands.commands import Command log = logging.getLogger("prometheus") @@ -124,7 +125,15 @@ async def on_interaction(self, interaction: Interaction): interaction.type == InteractionType.application_command and interaction.command ): - command_name = interaction.command.name + if isinstance(interaction.command, Command): + command_name = "" + parent = interaction.command.parent + while parent is not None: + command_name += parent.name + " " + parent = parent.parent + command_name += interaction.command.name + else: + command_name = interaction.command.name ON_INTERACTION_COUNTER.labels( shard_id, interaction.type.name, command_name