From c0dff561ba6f9e355a7fda224b296f929e9923c9 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Wed, 7 Aug 2024 21:19:07 +0200 Subject: [PATCH] add character limits to add-note command --- .../java/me/youhavetrouble/noted/Main.java | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/youhavetrouble/noted/Main.java b/src/main/java/me/youhavetrouble/noted/Main.java index 8d2cbdf..111c2ae 100644 --- a/src/main/java/me/youhavetrouble/noted/Main.java +++ b/src/main/java/me/youhavetrouble/noted/Main.java @@ -1,5 +1,6 @@ package me.youhavetrouble.noted; +import me.youhavetrouble.noted.listener.SlashCommandListener; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.Activity; @@ -67,16 +68,46 @@ public class Main { jda.upsertCommand(Commands.slash("add-note", "Add a note") .setIntegrationTypes(IntegrationType.GUILD_INSTALL, IntegrationType.USER_INSTALL) .addOptions( - new OptionData(OptionType.STRING, "alias", "An alias for the note").setRequired(true), - new OptionData(OptionType.STRING, "title", "The title of the note").setRequired(true), - new OptionData(OptionType.STRING, "content", "The content of the note").setRequired(true), - new OptionData(OptionType.STRING, "image-url", "The image URL of the note").setRequired(false), - new OptionData(OptionType.STRING, "thumbnail-url", "The thumbnail URL of the note").setRequired(false), - new OptionData(OptionType.STRING, "color", "The color of the note").setRequired(false), - new OptionData(OptionType.STRING, "author", "The author of the note").setRequired(false), - new OptionData(OptionType.STRING, "author-url", "The author URL of the note").setRequired(false), - new OptionData(OptionType.STRING, "footer", "The footer of the note").setRequired(false), - new OptionData(OptionType.STRING, "footer-url", "The footer URL of the note").setRequired(false) + new OptionData(OptionType.STRING, "alias", "An alias for the note") + .setMinLength(1) + .setMaxLength(256) + .setRequired(true), + new OptionData(OptionType.STRING, "title", "The title of the note") + .setMinLength(1) + .setMaxLength(256) + .setRequired(true), + new OptionData(OptionType.STRING, "content", "The content of the note") + .setMinLength(1) + .setMaxLength(4096) + .setRequired(true), + new OptionData(OptionType.STRING, "image-url", "The image URL of the note") + .setMinLength(1) + .setMaxLength(2000) + .setRequired(false), + new OptionData(OptionType.STRING, "thumbnail-url", "The thumbnail URL of the note") + .setMinLength(1) + .setMaxLength(2000) + .setRequired(false), + new OptionData(OptionType.STRING, "color", "The color of the note") + .setMinLength(1) + .setMaxLength(7) + .setRequired(false), + new OptionData(OptionType.STRING, "author", "The author of the note") + .setMinLength(1) + .setMaxLength(256) + .setRequired(false), + new OptionData(OptionType.STRING, "author-url", "The author URL of the note") + .setMinLength(1) + .setMaxLength(2000) + .setRequired(false), + new OptionData(OptionType.STRING, "footer", "The footer of the note") + .setMinLength(1) + .setMaxLength(256) + .setRequired(false), + new OptionData(OptionType.STRING, "footer-url", "The footer URL of the note") + .setMinLength(1) + .setMaxLength(2000) + .setRequired(false) ) .setContexts(InteractionContextType.BOT_DM) ).queue();