Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging subcommands #20

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion discord/ext/prometheus/prometheus_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -124,7 +125,18 @@ 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):
# Slash Command
command_name = ""
parent = interaction.command.parent
while parent is not None:
# Handle subcommands
command_name += parent.name + " "
parent = parent.parent
command_name += interaction.command.name
else:
# Context Menu Button
command_name = interaction.command.name

ON_INTERACTION_COUNTER.labels(
shard_id, interaction.type.name, command_name
Expand Down
Loading