1515import xyz .dynxsty .dih4jda .interactions .AutoCompletable ;
1616
1717/**
18- * The `/form delete` command. Deletes an existing form, also detaching it from
19- * a message if it's attached at the time of running this command. This command
20- * does NOT delete submission records from the database, see
21- * {@link SubmissionsDeleteFormSubcommand}.
18+ * The `/form delete` command. Deletes an existing form. This command does NOT
19+ * delete submission records from the database, see
20+ * {@link SubmissionsDeleteFormSubcommand}. This command won't work if the form
21+ * is attached to a message, see {@link DetachFormSubcommand}
2222 *
2323 * @see FormData
2424 */
@@ -36,8 +36,8 @@ public class DeleteFormSubcommand extends FormSubcommand implements AutoCompleta
3636 public DeleteFormSubcommand (FormsRepository formsRepo , BotConfig botConfig ) {
3737 super (botConfig , formsRepo );
3838 this .formsRepo = formsRepo ;
39- setCommandData (new SubcommandData ("delete" , "Delete an existing form" )
40- . addOptions ( new OptionData (OptionType .INTEGER , FORM_ID_FIELD , "The ID of a form to delete" , true , true )));
39+ setCommandData (new SubcommandData ("delete" , "Delete an existing form" ). addOptions (
40+ new OptionData (OptionType .INTEGER , FORM_ID_FIELD , "The ID of a form to delete" , true , true )));
4141 }
4242
4343 @ Override
@@ -51,15 +51,17 @@ public void execute(SlashCommandInteractionEvent event) {
5151 }
5252
5353 event .deferReply (true ).queue ();
54-
5554 FormData form = formOpt .get ();
56- formsRepo .deleteForm (form );
5755
5856 if (form .isAttached ()) {
59- DetachFormSubcommand .detachFromMessage (form , event .getGuild ());
60- // TODO send a warning
57+ event .getHook ().sendMessage (
58+ "This form is attached to a message. Use `details` subcommand to check the message this form is attached to, or `detach` subcommand to detach the message before deleting." )
59+ .queue ();
60+ return ;
6161 }
6262
63+ formsRepo .deleteForm (form );
64+
6365 event .getHook ().sendMessage ("Form deleted!" ).queue ();
6466 }
6567
0 commit comments