1+
12package net .javadiscord .javabot .systems .user_preferences .commands ;
23
34import com .dynxsty .dih4jda .interactions .commands .AutoCompletable ;
910import net .dv8tion .jda .api .interactions .commands .Command ;
1011import net .dv8tion .jda .api .interactions .commands .OptionMapping ;
1112import net .dv8tion .jda .api .interactions .commands .OptionType ;
12- import net .dv8tion .jda .api .interactions .commands .build .Commands ;
13+ import net .dv8tion .jda .api .interactions .commands .build .SubcommandData ;
1314import net .javadiscord .javabot .Bot ;
1415import net .javadiscord .javabot .systems .user_preferences .UserPreferenceManager ;
1516import net .javadiscord .javabot .systems .user_preferences .model .Preference ;
2021import java .util .List ;
2122
2223/**
23- * <h3>This class represents the /preferences command.</h3>
24+ * <h3>This class represents the /preferences set command.</h3>
2425 */
25- public class UserPreferenceCommand extends SlashCommand implements AutoCompletable {
26+ public class PreferencesSetSubcommand extends SlashCommand . Subcommand implements AutoCompletable {
2627 /**
2728 * The constructor of this class, which sets the corresponding {@link net.dv8tion.jda.api.interactions.commands.build.SlashCommandData}.
2829 */
29- public UserPreferenceCommand () {
30- setSlashCommandData ( Commands . slash ( "preferences " , "Allows you to set some preferences!" )
30+ public PreferencesSetSubcommand () {
31+ setSubcommandData ( new SubcommandData ( "set " , "Allows you to set your preferences!" )
3132 .addOption (OptionType .INTEGER , "preference" , "The preference to set." , true , true )
3233 .addOption (OptionType .BOOLEAN , "state" , "The state of the specified preference." , true )
3334 );
@@ -45,9 +46,9 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
4546 boolean state = stateMapping .getAsBoolean ();
4647 UserPreferenceManager manager = new UserPreferenceManager (Bot .getDataSource ());
4748 if (manager .setOrCreate (event .getUser ().getIdLong (), preference , state )) {
48- Responses .info (event , "Preference Updated" , "Successfully set `%s` to `%s`!" , preference , state ).queue ();
49+ Responses .info (event , "Preference Updated" , "Successfully %s `%s`!" , state ? "enabled" : "disabled" , preference ).queue ();
4950 } else {
50- Responses .error (event , "Could not update `%s` to `%s`." , preference , state ).queue ();
51+ Responses .error (event , "Could not %s `%s`." , state ? "enable" : "disable" , preference ).queue ();
5152 }
5253 }
5354
0 commit comments