@@ -5,6 +5,7 @@ use crate::serenity_prelude as serenity;
55/// Check if the interaction with the given name and arguments matches any framework command
66fn find_matching_command < ' a , ' b , U , E > (
77 interaction_name : & str ,
8+ interaction_kind : serenity:: CommandType ,
89 interaction_options : & ' b [ serenity:: ResolvedOption < ' b > ] ,
910 commands : & ' a [ crate :: Command < U , E > ] ,
1011 parent_commands : & mut Vec < & ' a crate :: Command < U , E > > ,
@@ -16,6 +17,19 @@ fn find_matching_command<'a, 'b, U, E>(
1617 return None ;
1718 }
1819
20+ // Discord allows commands with the same name as long as they have different types.
21+ match interaction_kind {
22+ serenity:: CommandType :: ChatInput => {
23+ cmd. slash_action ?;
24+ }
25+ serenity:: CommandType :: User | serenity:: CommandType :: Message => {
26+ cmd. context_menu_action
27+ . map ( serenity:: CommandType :: from)
28+ . filter ( |kind| kind == & interaction_kind) ?;
29+ }
30+ _ => unimplemented ! ( ) ,
31+ }
32+
1933 if let Some ( ( sub_name, sub_interaction) ) =
2034 interaction_options
2135 . iter ( )
@@ -26,7 +40,13 @@ fn find_matching_command<'a, 'b, U, E>(
2640 } )
2741 {
2842 parent_commands. push ( cmd) ;
29- find_matching_command ( sub_name, sub_interaction, & cmd. subcommands , parent_commands)
43+ find_matching_command (
44+ sub_name,
45+ interaction_kind,
46+ sub_interaction,
47+ & cmd. subcommands ,
48+ parent_commands,
49+ )
3050 } else {
3151 Some ( ( cmd, interaction_options) )
3252 }
@@ -50,6 +70,7 @@ fn extract_command<'a, U, E>(
5070) -> Result < crate :: ApplicationContext < ' a , U , E > , crate :: FrameworkError < ' a , U , E > > {
5171 let search_result = find_matching_command (
5272 & interaction. data . name ,
73+ interaction. data . kind ,
5374 options,
5475 & framework. options . commands ,
5576 parent_commands,
0 commit comments