1
+ package slash ;
2
+
3
+ import com .mewna .catnip .Catnip ;
4
+ import com .mewna .catnip .entity .builder .command .CommandOptionBuilder ;
5
+ import com .mewna .catnip .entity .interaction .InteractionResponseType ;
6
+ import com .mewna .catnip .entity .interaction .command .ApplicationCommandInteraction ;
7
+ import com .mewna .catnip .entity .interaction .command .ApplicationCommandOptionType ;
8
+ import com .mewna .catnip .entity .interaction .command .ApplicationCommandType ;
9
+ import com .mewna .catnip .entity .message .MessageOptions ;
10
+ import com .mewna .catnip .shard .DiscordEvent ;
11
+
12
+ import java .util .List ;
13
+
14
+ public class JavaExample {
15
+ public static void main (String [] args ) {
16
+ Catnip catnip = Catnip .catnip ("your token goes here" );
17
+
18
+ catnip .rest ().interaction ().createGlobalApplicationCommand (
19
+ ApplicationCommandType .CHAT_INPUT , "test" , "my cool command" ,
20
+ List .of (
21
+ new CommandOptionBuilder ()
22
+ .name ("option" )
23
+ .description ("my cool option" )
24
+ .type (ApplicationCommandOptionType .STRING )
25
+ .required (false )
26
+ .build ()
27
+ )
28
+ ).subscribe ();
29
+
30
+ catnip .observable (DiscordEvent .INTERACTION_CREATE ).subscribe (interaction -> {
31
+ if (interaction instanceof ApplicationCommandInteraction command ) {
32
+ if (command .data ().name ().equals ("test" )) {
33
+ catnip .rest ().interaction ().createInteractionInitialResponse (
34
+ InteractionResponseType .CHANNEL_MESSAGE_WITH_SOURCE ,
35
+ command .id (), command .token (),
36
+ new MessageOptions ().content ("test response!" )
37
+ );
38
+ }
39
+ }
40
+ });
41
+
42
+ catnip .connect ();
43
+ }
44
+ }
0 commit comments