11package technobot .commands .starboard ;
22
33import net .dv8tion .jda .api .Permission ;
4+ import net .dv8tion .jda .api .entities .ChannelType ;
45import net .dv8tion .jda .api .events .interaction .command .SlashCommandInteractionEvent ;
56import net .dv8tion .jda .api .interactions .commands .OptionMapping ;
67import net .dv8tion .jda .api .interactions .commands .OptionType ;
@@ -27,13 +28,16 @@ public StarboardCommand(TechnoBot bot) {
2728 this .category = Category .STARBOARD ;
2829 this .permission = Permission .MANAGE_SERVER ;
2930 this .subCommands .add (new SubcommandData ("create" , "Sets a channel to become the starboard." )
30- .addOption (OptionType .CHANNEL , "channel" , "The channel to set as the starboard" , true ));
31+ .addOptions (new OptionData (OptionType .CHANNEL , "channel" , "The channel to set as the starboard" , true )
32+ .setChannelTypes (ChannelType .TEXT , ChannelType .NEWS )));
3133 this .subCommands .add (new SubcommandData ("limit" , "Sets the star requirement for messages to post to the starboard." )
3234 .addOptions (new OptionData (OptionType .INTEGER , "stars" , "The star limit" ).setMinValue (1 ).setMaxValue (25 )));
3335 this .subCommands .add (new SubcommandData ("blacklist" , "Blocks a channel from having their messages starred." )
34- .addOption (OptionType .CHANNEL , "channel" , "The channel to blacklist" ));
36+ .addOptions (new OptionData (OptionType .CHANNEL , "channel" , "The channel to blacklist" )
37+ .setChannelTypes (ChannelType .TEXT , ChannelType .NEWS )));
3538 this .subCommands .add (new SubcommandData ("unblacklist" , "Removes a channel from the starboard blacklist." )
36- .addOption (OptionType .CHANNEL , "channel" , "The channel to unblacklist" ));
39+ .addOptions (new OptionData (OptionType .CHANNEL , "channel" , "The channel to unblacklist" )
40+ .setChannelTypes (ChannelType .TEXT , ChannelType .NEWS )));
3741 this .subCommands .add (new SubcommandData ("lock" , "Toggles a temporary lock on the entire starboard." ));
3842 this .subCommands .add (new SubcommandData ("jump" , "Toggles a link to the source message for each starboard entry." ));
3943 this .subCommands .add (new SubcommandData ("nsfw" , "Toggles the ability to star messages in NSFW channels." ));
@@ -51,15 +55,9 @@ public void execute(SlashCommandInteractionEvent event) {
5155 switch (event .getSubcommandName ()) {
5256 case "create" -> {
5357 // Set starboard channel
54- try {
55- long channel = channelOption .getAsTextChannel ().getIdLong ();
56- starboardHandler .setChannel (channel );
57- text = EmbedUtils .BLUE_TICK + " Set the starboard channel to <#" + channel + ">" ;
58- } catch (NullPointerException e ) {
59- text = "You can only set a text channel as the starboard!" ;
60- event .getHook ().sendMessageEmbeds (EmbedUtils .createError (text )).queue ();
61- return ;
62- }
58+ long channel = channelOption .getAsGuildChannel ().getIdLong ();
59+ starboardHandler .setChannel (channel );
60+ text = EmbedUtils .BLUE_TICK + " Set the starboard channel to <#" + channel + ">" ;
6361 }
6462 case "limit" -> {
6563 OptionMapping limitOption = event .getOption ("stars" );
@@ -74,31 +72,19 @@ public void execute(SlashCommandInteractionEvent event) {
7472 }
7573 case "blacklist" -> {
7674 if (channelOption != null ) {
77- try {
78- long channel = channelOption .getAsTextChannel ().getIdLong ();
79- starboardHandler .blacklistChannel (channel );
80- text = EmbedUtils .BLUE_TICK + " Starboard will now ignore reactions from <#" + channel + ">" ;
81- } catch (NullPointerException e ) {
82- text = "You can only blacklist a text channel!" ;
83- event .getHook ().sendMessageEmbeds (EmbedUtils .createError (text )).queue ();
84- return ;
85- }
75+ long channel = channelOption .getAsGuildChannel ().getIdLong ();
76+ starboardHandler .blacklistChannel (channel );
77+ text = EmbedUtils .BLUE_TICK + " Starboard will now ignore reactions from <#" + channel + ">" ;
8678 } else {
8779 starboardHandler .clearBlacklist ();
8880 text = EmbedUtils .BLUE_TICK + " Reset the starboard blacklist!" ;
8981 }
9082 }
9183 case "unblacklist" -> {
9284 if (channelOption != null ) {
93- try {
94- long channel = channelOption .getAsTextChannel ().getIdLong ();
95- starboardHandler .unBlacklistChannel (channel );
96- text = EmbedUtils .BLUE_X + " Removed <#" + channel + "> from the Starboard blacklist!" ;
97- } catch (NullPointerException e ) {
98- text = "You can only unblacklist a text channel!" ;
99- event .getHook ().sendMessageEmbeds (EmbedUtils .createError (text )).queue ();
100- return ;
101- }
85+ long channel = channelOption .getAsGuildChannel ().getIdLong ();
86+ starboardHandler .unBlacklistChannel (channel );
87+ text = EmbedUtils .BLUE_X + " Removed <#" + channel + "> from the Starboard blacklist!" ;
10288 } else {
10389 starboardHandler .clearBlacklist ();
10490 text = EmbedUtils .BLUE_TICK + " Reset the starboard blacklist!" ;
0 commit comments