1010import net .dv8tion .jda .api .interactions .commands .OptionMapping ;
1111import net .dv8tion .jda .api .interactions .commands .OptionType ;
1212import net .dv8tion .jda .api .interactions .commands .build .OptionData ;
13- import net .dv8tion .jda .api .interactions .commands .build .SubcommandData ;
1413import net .dv8tion .jda .api .interactions .components .ActionRow ;
1514import net .dv8tion .jda .api .interactions .components .ComponentInteraction ;
1615import net .dv8tion .jda .api .interactions .components .selections .SelectOption ;
@@ -44,9 +43,6 @@ public final class RoleSelectCommand extends SlashCommandAdapter {
4443
4544 private static final Logger logger = LoggerFactory .getLogger (RoleSelectCommand .class );
4645
47- private static final String ALL_OPTION = "all" ;
48- private static final String CHOOSE_OPTION = "choose" ;
49-
5046 private static final String TITLE_OPTION = "title" ;
5147 private static final String DESCRIPTION_OPTION = "description" ;
5248
@@ -65,15 +61,7 @@ public RoleSelectCommand() {
6561 super ("role-select" , "Sends a message where users can select their roles" ,
6662 SlashCommandVisibility .GUILD );
6763
68- SubcommandData allRoles =
69- new SubcommandData (ALL_OPTION , "Lists all the rolls in the server for users" )
70- .addOptions (messageOptions );
71-
72- SubcommandData selectRoles =
73- new SubcommandData (CHOOSE_OPTION , "Choose the roles for users to select" )
74- .addOptions (messageOptions );
75-
76- getData ().addSubcommands (allRoles , selectRoles );
64+ getData ().addOptions (messageOptions );
7765 }
7866
7967 @ NotNull
@@ -107,14 +95,8 @@ public void onSlashCommand(@NotNull final SlashCommandEvent event) {
10795
10896 SelectionMenu .Builder menu =
10997 SelectionMenu .create (generateComponentId (Lifespan .PERMANENT , member .getId ()));
110- boolean isEphemeral = false ;
11198
112- if (CHOOSE_OPTION .equals (event .getSubcommandName ())) {
113- addMenuOptions (event , menu , "Select the roles to display" , 1 );
114- isEphemeral = true ;
115- } else {
116- addMenuOptions (event , menu , "Select your roles" , 0 );
117- }
99+ addMenuOptions (event , menu , "Select the roles to display" , 1 );
118100
119101 // Handle Optional arguments
120102 OptionMapping titleOption = event .getOption (TITLE_OPTION );
@@ -126,13 +108,7 @@ public void onSlashCommand(@NotNull final SlashCommandEvent event) {
126108 MessageBuilder messageBuilder = new MessageBuilder (makeEmbed (title , description ))
127109 .setActionRows (ActionRow .of (menu .build ()));
128110
129- if (isEphemeral ) {
130- event .reply (messageBuilder .build ()).setEphemeral (true ).queue ();
131- } else {
132- event .getChannel ().sendMessage (messageBuilder .build ()).queue ();
133-
134- event .reply ("Message sent successfully!" ).setEphemeral (true ).queue ();
135- }
111+ event .reply (messageBuilder .build ()).setEphemeral (true ).queue ();
136112 }
137113
138114 /**
@@ -325,4 +301,4 @@ private static void handleRoleModifications(@NotNull final Interaction event,
325301 return null ;
326302 }
327303 }
328- }
304+ }
0 commit comments