File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2
2
from prometheus_client import start_http_server , Counter , Gauge
3
3
from discord .ext import commands , tasks
4
4
from discord import Interaction , InteractionType , AutoShardedClient
5
+ from discord .app_commands .commands import Command
5
6
6
7
log = logging .getLogger ("prometheus" )
7
8
@@ -124,7 +125,18 @@ async def on_interaction(self, interaction: Interaction):
124
125
interaction .type == InteractionType .application_command
125
126
and interaction .command
126
127
):
127
- command_name = interaction .command .name
128
+ if isinstance (interaction .command , Command ):
129
+ # Slash Command
130
+ command_name = ""
131
+ parent = interaction .command .parent
132
+ while parent is not None :
133
+ # Handle subcommands
134
+ command_name += parent .name + " "
135
+ parent = parent .parent
136
+ command_name += interaction .command .name
137
+ else :
138
+ # Context Menu Button
139
+ command_name = interaction .command .name
128
140
129
141
ON_INTERACTION_COUNTER .labels (
130
142
shard_id , interaction .type .name , command_name
You can’t perform that action at this time.
0 commit comments