From 6ae3821fca87a44c016ec17bff54df5ec64356e1 Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:50:33 +0200 Subject: [PATCH] Improve docs --- src/main/java/net/dv8tion/jda/api/JDA.java | 2 ++ .../interactions/commands/build/Commands.java | 20 ++++++++++++++++++- .../commands/build/EntryPointCommandData.java | 7 +++++-- .../GlobalCommandListUpdateAction.java | 12 ++++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/api/JDA.java b/src/main/java/net/dv8tion/jda/api/JDA.java index 30a2778d32..df91ddb567 100644 --- a/src/main/java/net/dv8tion/jda/api/JDA.java +++ b/src/main/java/net/dv8tion/jda/api/JDA.java @@ -30,6 +30,7 @@ import net.dv8tion.jda.api.interactions.commands.Command; import net.dv8tion.jda.api.interactions.commands.build.CommandData; import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.EntryPointCommandData; import net.dv8tion.jda.api.managers.AudioManager; import net.dv8tion.jda.api.managers.DirectAudioController; import net.dv8tion.jda.api.managers.Presence; @@ -773,6 +774,7 @@ default CommandCreateAction upsertCommand(@Nonnull String name, @Nonnull String /** * Configures the complete list of global commands. *
This will replace the existing command list for this bot. You should only use this once on startup! + *
If your bot has activities enabled, you must {@link GlobalCommandListUpdateAction#setEntryPointCommand(EntryPointCommandData) set your entry point command}. * *

This operation is idempotent. * Commands will persist between restarts of your bot, you only have to create a command once. diff --git a/src/main/java/net/dv8tion/jda/api/interactions/commands/build/Commands.java b/src/main/java/net/dv8tion/jda/api/interactions/commands/build/Commands.java index c7e070bfcc..6b74827e65 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/commands/build/Commands.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/commands/build/Commands.java @@ -130,7 +130,25 @@ public static CommandData context(@Nonnull Command.Type type, @Nonnull String na return new CommandDataImpl(type, name); } - //TODO docs + /** + * Create an activity entry point command builder. + * + *

Only one entry point can be created per app. + * + * @param name + * The entry point name, 1-32 lowercase alphanumeric characters + * @param description + * The entry point description, 1-100 characters + * + * @throws IllegalArgumentException + * If any of the following requirements are not met + *

+ * + * @return {@link EntryPointCommandData} builder for the app's activity entry point command + */ @Nonnull public static EntryPointCommandData entryPoint(@Nonnull String name, @Nonnull String description) { diff --git a/src/main/java/net/dv8tion/jda/api/interactions/commands/build/EntryPointCommandData.java b/src/main/java/net/dv8tion/jda/api/interactions/commands/build/EntryPointCommandData.java index 591f60a2b2..df9562798f 100644 --- a/src/main/java/net/dv8tion/jda/api/interactions/commands/build/EntryPointCommandData.java +++ b/src/main/java/net/dv8tion/jda/api/interactions/commands/build/EntryPointCommandData.java @@ -21,6 +21,7 @@ import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; import net.dv8tion.jda.api.interactions.commands.build.attributes.*; import net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction; +import net.dv8tion.jda.api.requests.restaction.GlobalCommandListUpdateAction; import net.dv8tion.jda.api.utils.data.DataObject; import net.dv8tion.jda.api.utils.data.SerializableData; @@ -29,9 +30,11 @@ /** * Builder for Entry Point Commands. - *
Use the factory methods provided by {@link Commands} to create instances of this interface. + *
Use {@link Commands#entryPoint(String, String)} to create instances of this interface. * - * @see Commands + *

This command can only be added via {@link GlobalCommandListUpdateAction#setEntryPointCommand(EntryPointCommandData)}. + * + * @see Commands#entryPoint(String, String) */ public interface EntryPointCommandData extends IDescribedCommandData, INamedCommandData, IScopedCommandData, IRestrictedCommandData, diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/GlobalCommandListUpdateAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/GlobalCommandListUpdateAction.java index 3442b98d4f..450a184862 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/GlobalCommandListUpdateAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/GlobalCommandListUpdateAction.java @@ -30,6 +30,7 @@ /** * Specialized {@link RestAction} used to replace existing commands globally. *
Any commands that currently exist and are not listed through {@link #addCommands(CommandData...)} will be DELETED! + *
If your bot has activities enabled, you must {@link #setEntryPointCommand(EntryPointCommandData) set your entry point command}. * *

This operation is idempotent. Commands will persist between restarts of your bot, you only have to create a command once. */ @@ -65,7 +66,16 @@ public interface GlobalCommandListUpdateAction extends CommandListUpdateAction @CheckReturnValue GlobalCommandListUpdateAction addCommands(@Nonnull CommandData... commands); - //TODO docs + /** + * Sets your app's activity primary entry point. + *
This must be set if your application has activities enabled. + *
Using this with activities disabled will not make the entry point appear. + * + * @param entryPoint + * The entry point data + * + * @return This instance, for chaining + */ @Nonnull @CheckReturnValue GlobalCommandListUpdateAction setEntryPointCommand(@Nonnull EntryPointCommandData entryPoint);