### GET getInstallParameters Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/ApplicationInfo.IntegrationTypeConfiguration.html Retrieves the OAuth2 installation parameters used for the default in-app authorization link when a user invites the application. ```APIDOC ## GET /application/integration/install-parameters ### Description Retrieves the OAuth2 install parameters for the default in-app authorization link. These parameters are used when a user invites the application via the Discord app. ### Method GET ### Endpoint /application/integration/install-parameters ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example GET /application/integration/install-parameters ### Response #### Success Response (200) - **installParameters** (ApplicationInfo.InstallParameters) - The OAuth2 configuration object for the application invite URL. #### Response Example { "clientId": "123456789012345678", "scopes": ["bot", "applications.commands"], "permissions": "8" } ``` -------------------------------- ### POST /application/install-params Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/ApplicationManager.html Sets the default installation parameters for the application. ```APIDOC ## POST /application/install-params ### Description Sets the default installation parameters of this application. This is used if the application does not use a custom install URL. ### Method POST ### Endpoint /application/install-params ### Parameters #### Request Body - **installParams** (object) - Required - The default install parameters (IntegrationTypeConfig) ### Response #### Success Response (200) - **status** (string) - Returns ApplicationManager for chaining convenience ``` -------------------------------- ### IAudioSendSystem start() Method Details (Java) Source: https://docs.jda.wiki/net/dv8tion/jda/api/audio/factory/IAudioSendSystem.html Details the start method of the IAudioSendSystem interface. This method initiates the UDP audio packet sending loop. It's crucial that this method does not block the calling thread, similar to Thread.start(), implying the loop should run asynchronously. ```java /** * This represents the start of the loop, similar to Thread.start(), and after a call to this method JDA assumes that the instance will be sending UDP audio packets in a loop. * Note: The packet sending loop should NOT be started on the current thread. I.E: This method should not block forever, in the same way that Thread.start() does not. Just like in Thread, the running action of this system should be implemented asynchronously. */ void start(); ``` -------------------------------- ### POST /lifecycle/login Source: https://docs.jda.wiki/net/dv8tion/jda/api/sharding/DefaultShardManager.html Initializes and starts all managed shards. ```APIDOC ## POST /lifecycle/login ### Description Starts all shards. This method should only be called once during the application lifecycle. ### Method POST ### Endpoint /lifecycle/login ``` -------------------------------- ### Set Default Install Parameters for Application Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/ApplicationManager.html Sets the default installation parameters for an application when a custom install URL is not used. It configures scopes and permissions for invite URLs. The ApplicationManager is returned for chaining. ```java ApplicationManager setInstallParams(@Nullable ApplicationManager.IntegrationTypeConfig installParams) ``` -------------------------------- ### Naive Implementation Example Source: https://docs.jda.wiki/net/dv8tion/jda/api/interactions/commands/localization/LocalizationFunction.html An example of a naive implementation of the LocalizationFunction interface using a switch statement. ```JAVA public class MyFunction implements LocalizationFunction { @Override public Map apply(String localizationKey) { Map map = new HashMap<>(); switch (localizationKey) { case "ban.name": map.put(DiscordLocale.SPANISH, "prohibición"); map.put(DiscordLocale.FRENCH, "bannir"); break; case "ban.description": map.put(DiscordLocale.SPANISH, "Prohibir a un usuario del servidor"); map.put(DiscordLocale.FRENCH, "Bannir un utilisateur du serveur"); break; // etc etc } return map; } } ``` -------------------------------- ### Usage Example Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/ClosableIterator.html Example demonstrating the use of ClosableIterator within a try-with-resources block for safe resource management. ```APIDOC ### Example This example shows how to use `ClosableIterator` within a `try-with-resources` statement to ensure the underlying resource is properly closed, even if exceptions occur during iteration. ```java try (ClosableIterator it = cacheView.lockedIterator()) { while (it.hasNext()) { consume(it.next()); } } ``` ``` -------------------------------- ### Retrieve OAuth2 Install Parameters Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/ApplicationInfo.IntegrationTypeConfiguration.html Demonstrates how to access the OAuth2 install parameters required for the default in-app authorization link. This method returns an InstallParameters object or null if not configured. ```java ApplicationInfo.InstallParameters params = applicationInfo.getInstallParameters(); if (params != null) { // Use the OAuth2 parameters for the invite URL System.out.println("Parameters retrieved successfully"); } ``` -------------------------------- ### POST /application/install-url Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/ApplicationManager.html Sets the custom install URL for the application. ```APIDOC ## POST /application/install-url ### Description Sets the custom install URL for this application. The URL must not exceed 2048 characters. ### Method POST ### Endpoint /application/install-url ### Parameters #### Request Body - **customInstallUrl** (string) - Required - The custom install URL (max 2048 characters) ### Response #### Success Response (200) - **status** (string) - Returns ApplicationManager for chaining convenience #### Error Response (400) - **error** (string) - IllegalArgumentException if URL exceeds 2048 characters ``` -------------------------------- ### JDA Activity Timestamps Get Start Time Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Activity.Timestamps.html Retrieves the start timestamp of the match as an Instant object. This method provides a convenient way to get the start time, converting the epoch second timestamp to an Instant. ```java @Nullable public Instant getStartTime() Shortcut for Instant.ofEpochSecond(start) ``` -------------------------------- ### Initialize and Configure FileProxy Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/FileProxy.html Demonstrates how to instantiate a FileProxy object and set a global default OkHttpClient for all instances. ```java FileProxy proxy = new FileProxy("https://example.com/file.png"); FileProxy.setDefaultHttpClient(new okhttp3.OkHttpClient()); ``` -------------------------------- ### UserUpdateDiscriminatorEvent - Get New Discriminator Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.html Example of how to get the new discriminator from the UserUpdateDiscriminatorEvent. ```APIDOC ## GET /user/discriminator/new ### Description Retrieves the new discriminator of a user. ### Method GET ### Endpoint `/user/discriminator/new` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **discriminator** (String) - The new discriminator of the user. #### Response Example ```json { "discriminator": "5678" } ``` ``` -------------------------------- ### UserUpdateDiscriminatorEvent - Get Old Discriminator Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/user/update/UserUpdateDiscriminatorEvent.html Example of how to get the old discriminator from the UserUpdateDiscriminatorEvent. ```APIDOC ## GET /user/discriminator/old ### Description Retrieves the previous discriminator of a user. ### Method GET ### Endpoint `/user/discriminator/old` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **discriminator** (String) - The old discriminator of the user. #### Response Example ```json { "discriminator": "1234" } ``` ``` -------------------------------- ### Initialize ImageProxy Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/ImageProxy.html Demonstrates how to instantiate an ImageProxy object with a target URL. ```java ImageProxy proxy = new ImageProxy("https://example.com/image.png"); ``` -------------------------------- ### Get the Thread Channel Started from a Message Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Message.html Retrieves the `ThreadChannel` that was started from this message, if any. This can return null if no thread was started or if the thread has been deleted. ```java @Nullable ThreadChannel getStartedThread() // Returns the ThreadChannel that was started from this message. ``` -------------------------------- ### Constructing and Managing a MediaGallery Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/mediagallery/MediaGallery.html Demonstrates how to instantiate a MediaGallery using static factory methods and how to retrieve the contained items. Note that the gallery is limited to a maximum of 10 items. ```java import java.util.List; import java.util.ArrayList; // Creating a gallery from a collection List items = new ArrayList<>(); items.add(item1); MediaGallery gallery = MediaGallery.of(items); // Retrieving items List currentItems = gallery.getItems(); // Creating a gallery with a unique ID MediaGallery customGallery = gallery.withUniqueId(12345); ``` -------------------------------- ### Retrieve Parent Message Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html Attempts to get the Message that this thread was started from. The parent message was posted in the parent channel and a thread was started on it. ```APIDOC ## GET /websites/jda_wiki/threads/{threadId}/parentMessage ### Description Attempts to get the `Message` that this thread was started from. The parent message was posted in the `parent channel` and a thread was started on it. ### Method GET ### Endpoint /websites/jda_wiki/threads/{threadId}/parentMessage ### Parameters #### Path Parameters - **threadId** (string) - Required - The ID of the thread. ### Response #### Success Response (200) - **Message** (object) - The Message that started this thread. #### Response Example ```json { "id": "123456789012345678", "content": "This is the parent message.", "authorId": "987654321098765432", "channelId": "112233445566778899" } ``` ### Throws - `DetachedEntityException` - If this entity is `detached`. - `InsufficientPermissionException` - If this is a `GuildMessageChannel` and the logged in account does not have `Permission.VIEW_CHANNEL` or `Permission.MESSAGE_HISTORY`. - `UnsupportedOperationException` - If the parent channel is not a `GuildMessageChannel`. ``` -------------------------------- ### Configuring Welcome Screen Properties Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/GuildWelcomeScreenManager.html Shows how to update the welcome screen configuration, including enabling the screen, setting a description, and managing welcome channels. Note that descriptions are limited to 140 characters and welcome channels are limited to 5. ```java manager.setEnabled(true) .setDescription("Welcome to our server!") .setWelcomeChannels(channel1, channel2); ``` -------------------------------- ### Get User Install Count - Java Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/ApplicationInfo.html Retrieves the approximate count of users who have installed this application. Returns -1 if the count is unknown. ```java long getUserInstallCount() // Returns: The approximate count of users that have installed this application. ``` -------------------------------- ### Constructing and Configuring TextDisplay Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/textdisplay/TextDisplay.html Examples showing how to instantiate a TextDisplay component using static factory methods and how to update its content or unique identifier. ```java TextDisplay display = TextDisplay.of("Hello, World!"); TextDisplay formatted = TextDisplay.ofFormat("User: %s", username); TextDisplay updated = display.withContent("New Content").withUniqueId(1); ``` -------------------------------- ### Get Application Tags and Install Count (Java) Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/ApplicationInfo.html Accesses the tags associated with the Discord application and retrieves the approximate user install count. Tags help categorize the application, while the install count indicates its popularity. ```java @Unmodifiable List getTags() A `List` containing the tags of this bot's application. long getUserInstallCount() The approximate count of users that have installed this application, or `-1` if it is unknown. ``` -------------------------------- ### Initialize JDA Instance with JDABuilder Source: https://docs.jda.wiki/net/dv8tion/jda/api/JDABuilder.html Demonstrates how to create a basic JDA instance using the default builder configuration. This snippet shows the standard pattern for setting up a bot with a token and building the client. ```java JDABuilder builder = JDABuilder.createDefault("YOUR_BOT_TOKEN"); builder.addEventListeners(new MyListener()); JDA jda = builder.build(); ``` -------------------------------- ### Get Integration Owners - GenericInteractionCreateEvent Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/interaction/GenericInteractionCreateEvent.html Retrieves the integration owners of this interaction, which depends on how the application was installed. ```java public @Nonnull IntegrationOwners getIntegrationOwners() ``` -------------------------------- ### Create a WebhookClient Instance Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/WebhookClient.html Demonstrates how to instantiate an IncomingWebhookClient using a JDA instance and a webhook URL or ID/Token pair. ```java IncomingWebhookClient client = WebhookClient.createClient(jda, "https://discord.com/api/webhooks/id/token"); // Or using ID and Token IncomingWebhookClient client = WebhookClient.createClient(jda, "webhookId", "webhookToken"); ``` -------------------------------- ### User Activity Start Event Example (Java) Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/user/package-summary.html Demonstrates how to handle the UserActivityStartEvent, which is triggered when a user begins an activity in a guild. This event provides information about the user and the activity they started. It's useful for tracking user engagement or specific in-game events. ```java import net.dv8tion.jda.api.events.user.update.UserActivityStartEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; public class ActivityListener extends ListenerAdapter { @Override public void onUserActivityStart(UserActivityStartEvent event) { System.out.println(event.getUser().getName() + " started activity: " + event.getActivity().getName()); } } ``` -------------------------------- ### Initialize AttachmentProxy Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/AttachmentProxy.html Demonstrates how to instantiate an AttachmentProxy object using a target URL. This is the entry point for performing subsequent download operations. ```java AttachmentProxy proxy = new AttachmentProxy("https://example.com/image.png"); ``` -------------------------------- ### Retrieve Start Message Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html Attempts to get the Message that was posted when this thread was created. Unlike retrieveParentMessage(), the message was posted only inside the thread channel. ```APIDOC ## GET /websites/jda_wiki/threads/{threadId}/startMessage ### Description Attempts to get the `Message` that was posted when this thread was created. Unlike `retrieveParentMessage()`, the message was posted only inside the thread channel. This is common for `ForumChannel` posts. ### Method GET ### Endpoint /websites/jda_wiki/threads/{threadId}/startMessage ### Parameters #### Path Parameters - **threadId** (string) - Required - The ID of the thread. ### Response #### Success Response (200) - **Message** (object) - The Message that was posted when this thread was created. #### Response Example ```json { "id": "123456789012345678", "content": "This is the starting message.", "authorId": "987654321098765432", "channelId": "112233445566778899" } ``` ### Throws - `DetachedEntityException` - If this entity is `detached`. - `InsufficientPermissionException` - If this is a `GuildMessageChannel` and the logged in account does not have `Permission.VIEW_CHANNEL` or `Permission.MESSAGE_HISTORY`. ``` -------------------------------- ### Create and Reply with a StringSelectMenu Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/selections/StringSelectMenu.html Demonstrates how to instantiate a StringSelectMenu using the builder pattern, configure options, and attach it to a slash command response. ```java public void onSlashCommandInteraction(SlashCommandInteractionEvent event) { if (!event.getName().equals("class")) return; StringSelectMenu menu = StringSelectMenu.create("menu:class") .setPlaceholder("Choose your class") .setRequiredRange(1, 1) .addOption("Arcane Mage", "mage-arcane") .addOption("Fire Mage", "mage-fire") .addOption("Frost Mage", "mage-frost") .setDefaultValues("mage-fire") .build(); event.reply("Please pick your class below") .setEphemeral(true) .addComponents(ActionRow.of(menu)) .queue(); } ``` -------------------------------- ### Check and Initialize Opus Audio Support Source: https://docs.jda.wiki/net/dv8tion/jda/api/audio/AudioNatives.html Demonstrates how to check if audio is supported and ensure the Opus library is initialized. These methods are essential for verifying native dependency availability before starting audio streams. ```java import net.dv8tion.jda.api.audio.AudioNatives; public class AudioSetup { public void initializeAudio() { if (!AudioNatives.isAudioSupported()) { boolean success = AudioNatives.ensureOpus(); if (success) { System.out.println("Opus library loaded successfully."); } else { System.err.println("Failed to load Opus library."); } } } } ``` -------------------------------- ### JDA Activity Timestamps Get Elapsed Time Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Activity.Timestamps.html Calculates the time elapsed since the match started, in terms of the specified TemporalUnit. If the start time is not set, this method returns a negative value. It includes error handling for null units, arithmetic overflows, and date-time calculation issues. ```java public long getElapsedTime(@Nonnull TemporalUnit unit) Calculates the elapsed time from getStartTime() to now in terms of the specified unit. If getStartTime() is null this will be negative. Parameters: unit - The TemporalUnit to return Returns: Elapsed time in the provided TemporalUnit or -1 if unset ``` -------------------------------- ### Java: Getting Component Interaction Details Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.html Provides examples of how to retrieve specific information from a `GenericComponentInteractionCreateEvent`, such as the channel, the component itself, its ID, and the message it belongs to. These methods are essential for context-aware interaction handling. ```java public class MyComponentListener implements ListenerAdapter { @Override public void onGenericComponentInteraction(GenericComponentInteractionCreateEvent event) { String componentId = event.getComponentId(); ActionComponent component = event.getComponent(); Component.Type componentType = event.getComponentType(); MessageChannelUnion channel = event.getChannel(); Message message = event.getMessage(); String messageId = event.getMessageId(); System.out.println("Component ID: " + componentId); System.out.println("Message ID: " + messageId); // ... use other retrieved information } } ``` -------------------------------- ### Create and Configure Checkbox Instance Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/checkbox/Checkbox.html Demonstrates how to instantiate a Checkbox using static factory methods and configure its properties like custom ID and default selection state. ```java Checkbox cb = Checkbox.of("my_checkbox_id", true); Checkbox customCb = Checkbox.of("another_id").withDefault(false); ``` -------------------------------- ### Get DataArray from DataArray using Path Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/data/DataPath.html Retrieves a DataArray from a root DataArray using a specified path. Throws exceptions for invalid paths, out-of-bounds indices, or invalid arguments. The path must start with an index element. ```java @Nonnull public static DataArray getArray(@Nonnull DataArray root, @Nonnull String path) Parses the given `path` and finds the appropriate value within this `DataArray`. Parameters: `root` - The root data array, which is the top level accessor. The very first element in the path corresponds to a field of that name within this root object. `path` - The path of the value, in accordance with the described grammar by `DataPath`. This must start with an index element, such as "[0]". Returns: The `DataArray` at the given path Throws: `ParsingException` - If the path is invalid or resolving fails due to missing elements `IndexOutOfBoundsException` - If any of the elements in the path refer to an array index that is out of bounds `IllegalArgumentException` - If null is provided or the path is empty ``` -------------------------------- ### Initialize OptionData Source: https://docs.jda.wiki/net/dv8tion/jda/api/interactions/commands/build/OptionData.html Demonstrates how to instantiate an OptionData object to define a command option. It highlights the required parameters and the optional configuration for requirements and auto-completion. ```java OptionData option = new OptionData(OptionType.STRING, "name", "description", true, false); ``` -------------------------------- ### Get DataArray from DataObject using Path Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/data/DataPath.html Retrieves a DataArray from a root DataObject using a specified path. Throws exceptions for invalid paths, out-of-bounds indices, or invalid arguments. The path must start with a name element. ```java @Nonnull public static DataArray getArray(@Nonnull DataObject root, @Nonnull String path) Parses the given `path` and finds the appropriate value within this `DataObject`. Parameters: `root` - The root data object, which is the top level accessor. The very first element in the path corresponds to a field of that name within this root object. `path` - The path of the value, in accordance with the described grammar by `DataPath`. This must start with a name element, such as "foo". Returns: The `DataArray` at the given path Throws: `ParsingException` - If the path is invalid or resolving fails due to missing elements `IndexOutOfBoundsException` - If any of the elements in the path refer to an array index that is out of bounds `IllegalArgumentException` - If null is provided or the path is empty ``` -------------------------------- ### Set Scheduled Event Details with ScheduledEventManager Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/ScheduledEventManager.html This example demonstrates how to use the ScheduledEventManager to set various properties of a scheduled event, such as its name, description, start time, and end time. The `queue()` method is called to execute the changes. This manager is part of the JDA library for Discord bots. ```java manager.setLocation("at the beach") .setStartTime(OffsetDateTime.now().plusHours(1)) .setEndTime(OffsetDateTime.now().plusHours(3)) .setName("Discussing Turtle Shells") .queue(); ``` -------------------------------- ### Create ComponentTree Instances Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/tree/ComponentTree.html Demonstrates how to instantiate a ComponentTree using static factory methods for general components, message components, or modal components. ```java Collection components = new ArrayList<>(); // Create a general component tree ComponentTree tree = ComponentTree.of(components); // Create a message-specific tree MessageComponentTree messageTree = ComponentTree.forMessage(messageComponents); // Create a modal-specific tree ModalComponentTree modalTree = ComponentTree.forModal(modalComponents); ``` -------------------------------- ### User Typing Event Example (Java) Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/user/package-summary.html Shows how to implement the UserTypingEvent, which occurs when a user starts typing in a guild channel. This event can be used to provide real-time feedback or trigger specific bot responses based on user input. It provides access to the user and the channel they are typing in. ```java import net.dv8tion.jda.api.events.user.UserTypingEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; public class TypingListener extends ListenerAdapter { @Override public void onUserTyping(UserTypingEvent event) { System.out.println(event.getUser().getName() + " started typing in channel: " + event.getChannel().getName()); } } ``` -------------------------------- ### Configure Custom OkHttpClient Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/ImageProxy.html Shows how to attach a custom OkHttpClient to an ImageProxy instance for specific network configuration requirements. ```java OkHttpClient client = new OkHttpClient.Builder().build(); proxy.withClient(client); ``` -------------------------------- ### Get All Scheduled Events (Java) Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Guild.html Retrieves all ScheduledEvents within a Guild, sorted by start time and then by snowflake ID. This method creates a new list on each call (O(n) complexity), so storing the result in a local variable or using getScheduledEventCache() is recommended for efficiency. Requires CacheFlag.SCHEDULED_EVENTS. Throws DetachedEntityException if the entity is detached. ```Java @Nonnull default @Unmodifiable List getScheduledEvents() ``` -------------------------------- ### Configure ShardManager Event and Audio Settings Source: https://docs.jda.wiki/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.html Demonstrates how to configure event manager providers, audio modules, and bulk delete splitting behavior using the builder pattern. ```java DefaultShardManagerBuilder builder = DefaultShardManagerBuilder.createDefault(token); builder.setBulkDeleteSplittingEnabled(false); builder.setEnableShutdownHook(true); builder.setEventManagerProvider(id -> new AnnotatedEventManager()); builder.setAudioModuleConfig(new AudioModuleConfig()); ``` -------------------------------- ### Create and Respond with EntitySelectMenu Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/selections/EntitySelectMenu.html Demonstrates how to instantiate an EntitySelectMenu using the builder pattern and include it in a slash command response. It sets a placeholder, defines the required selection range, and adds the component to an ActionRow. ```java public void onSlashCommandInteraction(SlashCommandInteractionEvent event) { if (!event.getName().equals("class")) return; EntitySelectMenu menu = EntitySelectMenu.create("menu:class", SelectTarget.ROLE) .setPlaceholder("Choose your class") .setRequiredRange(1, 1) .build(); event.reply("Please pick your class below") .setEphemeral(true) .addComponents(ActionRow.of(menu)) .queue(); } ``` -------------------------------- ### Get Optional DataArray from DataArray using Path Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/data/DataPath.html Safely retrieves an optional DataArray from a root DataArray using a specified path. Returns null if the path resolves to a missing optional value. Throws exceptions for invalid paths, out-of-bounds indices, or invalid arguments. The path must start with an index element. ```java @Nullable public static DataArray optArray(@Nonnull DataArray root, @Nonnull String path) Parses the given `path` and finds the appropriate value within this `DataArray`. Parameters: `root` - The root data array, which is the top level accessor. The very first element in the path corresponds to a field of that name within this root object. `path` - The path of the value, in accordance with the described grammar by `DataPath`. This must start with an index element, such as "[0]". Returns: The `DataArray` at the given path, or null if the path resolves to an optional value that is missing. Throws: `ParsingException` - If the path is invalid or resolving fails due to missing elements `IndexOutOfBoundsException` - If any of the elements in the path refer to an array index that is out of bounds `IllegalArgumentException` - If null is provided or the path is empty ``` -------------------------------- ### Instantiate DataArray Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/data/DataArray.html Demonstrates how to create a new DataArray instance from scratch or from an existing collection. ```java DataArray emptyArray = DataArray.empty(); DataArray fromCol = DataArray.fromCollection(myList); ``` -------------------------------- ### Get Optional DataArray from DataObject using Path Source: https://docs.jda.wiki/net/dv8tion/jda/api/utils/data/DataPath.html Safely retrieves an optional DataArray from a root DataObject using a specified path. Returns null if the path resolves to a missing optional value. Throws exceptions for invalid paths, out-of-bounds indices, or invalid arguments. The path must start with a name element. ```java @Nullable public static DataArray optArray(@Nonnull DataObject root, @Nonnull String path) Parses the given `path` and finds the appropriate value within this `DataObject`. Parameters: `root` - The root data object, which is the top level accessor. The very first element in the path corresponds to a field of that name within this root object. `path` - The path of the value, in accordance with the described grammar by `DataPath`. This must start with a name element, such as "foo". Returns: The `DataArray` at the given path, or null if the path resolves to an optional value that is missing. Throws: `ParsingException` - If the path is invalid or resolving fails due to missing elements `IndexOutOfBoundsException` - If any of the elements in the path refer to an array index that is out of bounds `IllegalArgumentException` - If null is provided or the path is empty ``` -------------------------------- ### Set Custom Install URL for Application Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/ApplicationManager.html Sets a custom URL for application installation. This URL is used directly for installation and has a maximum length of 2048 characters. It returns the ApplicationManager for chaining. ```java ApplicationManager setCustomInstallUrl(@Nullable String customInstallUrl) ``` -------------------------------- ### Initialize and Build an Embed Source: https://docs.jda.wiki/net/dv8tion/jda/api/EmbedBuilder.html Demonstrates how to instantiate an EmbedBuilder, configure a title, and build it into a sendable MessageEmbed object. ```java EmbedBuilder builder = new EmbedBuilder(); builder.setTitle("Hello World", "https://example.com"); MessageEmbed embed = builder.build(); ``` -------------------------------- ### Constructing a GuildWelcomeScreen.Channel Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/GuildWelcomeScreen.Channel.html Demonstrates how to create a new instance of a recommended channel using the static factory methods. It requires a valid channel and a description under 42 characters, with an optional emoji. ```java GuildWelcomeScreen.Channel welcomeChannel = GuildWelcomeScreen.Channel.of(channel, "Check out our rules here!"); // With an emoji GuildWelcomeScreen.Channel welcomeChannelWithEmoji = GuildWelcomeScreen.Channel.of(channel, "General chat", emoji); ``` -------------------------------- ### POST /build Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/selections/StringSelectMenu.Builder.html Finalizes the configuration and creates a new StringSelectMenu instance. ```APIDOC ## POST /build ### Description Creates a new StringSelectMenu instance if all requirements are satisfied. Validates that options count is between 1 and 25 and that min/max value constraints are logical. ### Method POST ### Endpoint /build ### Response #### Success Response (200) - **menu** (StringSelectMenu) - The new StringSelectMenu instance. ### Errors - **IllegalArgumentException**: - If getMinValues() > getMaxValues() - If no options are provided - If more than 25 options are provided - If the minimum value range is 0 and a selection is explicitly required ``` -------------------------------- ### Lambda Implementation Example Source: https://docs.jda.wiki/net/dv8tion/jda/api/interactions/commands/localization/LocalizationFunction.html An example of implementing the LocalizationFunction interface using a lambda expression. ```JAVA LocalizationFunction myfunc = s -> { Map map = new HashMap<>(); switch (localizationKey) { case "ban.name": map.put(DiscordLocale.SPANISH, "prohibición"); map.put(DiscordLocale.FRENCH, "bannir"); break; case "ban.description": map.put(DiscordLocale.SPANISH, "Prohibir a un usuario del servidor"); map.put(DiscordLocale.FRENCH, "Bannir un utilisateur du serveur"); break; // etc etc } return map; } ``` -------------------------------- ### GET /guilds/{guildId}/members/by-id/{userId} Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Guild.html Gets a Member object via the id of the user. ```APIDOC ## GET /guilds/{guildId}/members/by-id/{userId} ### Description Gets a Member object via the id of the user. The id relates to ISnowflake.getId(), and this method is similar to JDA.getUserById(String). This is more efficient that using JDA.getUserById(String) and getMember(UserSnowflake). ### Method GET ### Endpoint /guilds/{guildId}/members/by-id/{userId} ### Parameters #### Path Parameters - **guildId** (string) - Required - The ID of the guild. - **userId** (string) - Required - The ID of the user. ### Response #### Success Response (200) - **member** (object | null) - The Member object for the given user ID. #### Response Example { "member": { "userId": "123456789012345678", "username": "ExampleUser" } } ``` -------------------------------- ### Instantiate RateLimitConfig Source: https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestRateLimiter.RateLimitConfig.html Demonstrates how to create a new instance of RateLimitConfig using a scheduler and global rate limit settings. This is typically used when configuring custom rate-limiting behavior for JDA. ```java ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); RestRateLimiter.GlobalRateLimit globalLimit = new RestRateLimiter.GlobalRateLimit(); RateLimitConfig config = new RateLimitConfig(scheduler, globalLimit, true); ``` -------------------------------- ### GET /guilds/{guildId}/members Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Guild.html Gets the Guild specific Member object for the provided UserSnowflake. ```APIDOC ## GET /guilds/{guildId}/members ### Description Gets the Guild specific Member object for the provided UserSnowflake. If the user is not in this guild or currently uncached, null is returned. This will only check cached members! ### Method GET ### Endpoint /guilds/{guildId}/members ### Parameters #### Path Parameters - **guildId** (string) - Required - The ID of the guild. #### Query Parameters - **userSnowflake** (string) - Required - The UserSnowflake for the member to get. This can be a member or user instance or User.fromId(long). ### Response #### Success Response (200) - **member** (object | null) - Possibly-null Member for the related User. #### Response Example { "member": { "userId": "123456789012345678", "username": "ExampleUser" } } ``` -------------------------------- ### Update Guild Welcome Screen - Java Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/GuildWelcomeScreenManager.html Demonstrates how to update the Guild's welcome screen settings using GuildWelcomeScreenManager. This includes enabling/disabling the screen, setting a description, and configuring welcome channels. The manager supports queuing these actions for execution. ```java manager.setEnabled(false) .setDescription(null) .setWelcomeChannels() .queue(); manager.setEnabled(true) .setDescription("Bot desc") .setWelcomeChannels(Arrays.asList( GuildWelcomeScreen.Channel.of(rulesChannel, "Read the rules first"), GuildWelcomeScreen.Channel.of(generalChannel, "Go have a chat", Emoji.fromUnicode("U+1F4AC")) )) .queue(); ``` -------------------------------- ### SelectOption Creation and Modification Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/selections/SelectOption.html Demonstrates how to create SelectOption instances and modify their properties. ```APIDOC ## Creating and Modifying SelectOptions ### Static Factory Methods - **`SelectOption.of(String label, String value)`** - Creates a new `SelectOption` instance with the provided label and value. - **`SelectOption.fromData(DataObject data)`** - Parses serialized option data to create a `SelectOption` instance. ### Instance Methods for Modification These methods return a *new* `SelectOption` instance with the specified change, leaving the original instance unchanged. - **`withLabel(String label)`** - Returns a copy of this select option with the changed label. - **`withValue(String value)`** - Returns a copy of this select option with the changed value. - **`withDescription(String description)`** - Returns a copy of this select option with the changed description. - **`withEmoji(Emoji emoji)`** - Returns a copy of this select option with the changed emoji. - **`withDefault(boolean isDefault)`** - Returns a copy of this select option with the changed default selection status. ``` -------------------------------- ### GET /guilds/{guildId}/members/me Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Guild.html Gets the Member object of the currently logged in account in this guild. ```APIDOC ## GET /guilds/{guildId}/members/me ### Description Gets the Member object of the currently logged in account in this guild. This is basically JDA.getSelfUser() being provided to getMember(UserSnowflake). ### Method GET ### Endpoint /guilds/{guildId}/members/me ### Parameters #### Path Parameters - **guildId** (string) - Required - The ID of the guild. ### Response #### Success Response (200) - **member** (object) - The Member object of the currently logged in account. #### Response Example { "member": { "userId": "123456789012345678", "username": "ExampleUser" } } ``` -------------------------------- ### Create Stage Instance Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/StageChannel.html Demonstrates how to initiate a new StageInstance for a given StageChannel using a topic string. It returns a StageInstanceAction and throws exceptions for invalid topics or insufficient permissions. ```java public StageInstanceAction createStageInstance(@Nonnull String topic) { // Implementation logic for creating a stage instance return new StageInstanceAction(this, topic); } ``` -------------------------------- ### CategoryManager - Set Name Example Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/channel/concrete/CategoryManager.html This example demonstrates how to set the name of a category using the CategoryManager. ```APIDOC ## POST /api/categories/{id} ### Description This endpoint allows for the modification of a category's properties, such as its name. ### Method POST ### Endpoint /api/categories/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the category to modify. #### Request Body - **name** (string) - Optional - The new name for the category. ### Request Example ```json { "name": "New Category Name" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates the category was updated successfully. #### Response Example ```json { "message": "Category updated successfully." } ``` ``` -------------------------------- ### Create a new SelectOption instance Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/selections/SelectOption.html Demonstrates how to instantiate a new SelectOption using the static factory method. This is the primary way to define a selectable item for a menu. ```java SelectOption option = SelectOption.of("Label Name", "unique_value"); ``` -------------------------------- ### ShardManager Initialization Source: https://docs.jda.wiki/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.html Initializes the ShardManager and optionally starts the login process. This operation is asynchronous and does not block until all shards are started. ```APIDOC ## ShardManager Initialization and Login ### Description Initializes the ShardManager and optionally starts the login process. This operation is asynchronous and does not block until all shards are started. It's recommended to perform other tasks in parallel while the ShardManager loads. ### Method This documentation describes a conceptual API call or method invocation rather than a specific HTTP endpoint. ### Endpoint N/A (Conceptual Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Example of calling the initialization method ShardManager shardManager = new ShardManager.Builder() .setToken("YOUR_BOT_TOKEN") .setLogin(true) // or false to manually call login later .build(); ``` ### Response #### Success Response (Conceptual) - **ShardManager** (object) - An instance of ShardManager. If `login` was true, the login process has been initiated. #### Response Example ```json { "message": "ShardManager initialized and login process started (if applicable).", "shardManagerInstance": "" } ``` ### Error Handling - **InvalidTokenException**: Thrown if the provided token is invalid and `login` is true. - **IllegalArgumentException**: Thrown if the provided token is empty or null, or if the intents/cache configuration is invalid. ``` -------------------------------- ### Constructing and Configuring a Label Component Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/label/Label.html Demonstrates how to instantiate a Label using the static factory methods and how to use fluent methods to update the label's properties. These methods return new instances of the Label, ensuring immutability. ```java Label myLabel = Label.of("Title", "Description", childComponent); Label updatedLabel = myLabel.withLabel("New Title").withDescription("New Description"); ``` -------------------------------- ### Constructing a Container Source: https://docs.jda.wiki/net/dv8tion/jda/api/components/container/Container.html Demonstrates how to create a new Container instance using the static factory methods provided by the interface. ```java Container container = Container.of(component1, component2); Container containerFromCollection = Container.of(listOfComponents); ``` -------------------------------- ### Get Widget Containing Member Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/Widget.Member.html Gets the widget to which this member belongs. This method returns a non-null Widget object. ```java @Nonnull Widget getWidget() ``` -------------------------------- ### Create Role with Properties Source: https://docs.jda.wiki/net/dv8tion/jda/api/requests/restaction/RoleAction.html Demonstrates creating a new role with various customizable properties using RoleAction. This includes setting the role's name, color, hoist status, mentionability, icon, and permissions. ```java // Example of setting various properties before creating a role RoleAction roleAction = guild.createRole(); roleAction.setName("New Role"); roleAction.setColor(Color.BLUE); roleAction.setHoisted(true); roleAction.setMentionable(true); roleAction.setIcon("👑"); roleAction.setPermissions(Permission.ADMINISTRATOR); roleAction.queue(createdRole -> { // Handle the created role }); ``` -------------------------------- ### Get Thread Member by Member Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html Gets a ThreadMember of this thread by their Member. Note that this operation relies on the ThreadMember cache for this ThreadChannel. ```APIDOC ## GET /websites/jda_wiki/threads/{threadId}/members/{memberId} ### Description Gets a `ThreadMember` of this thread by their `Member`. Note that this operation relies on the `ThreadMember cache` for this ThreadChannel. As the cache is likely to be unpopulated, this method is likely to return null. Use of `retrieveThreadMember(Member)` is preferred instead, once it is released. ### Method GET ### Endpoint /websites/jda_wiki/threads/{threadId}/members/{memberId} ### Parameters #### Path Parameters - **threadId** (string) - Required - The ID of the thread. - **memberId** (string) - Required - The ID of the member. ### Response #### Success Response (200) - **ThreadMember** (object | null) - The `ThreadMember` of this thread, null if the member is not found in the cache. #### Response Example ```json { "userId": "987654321098765432", "joinTimestamp": "2023-01-01T12:00:00Z", "flags": 0 } ``` ### Throws - `DetachedEntityException` - If this entity is `detached`. ``` -------------------------------- ### Get Self Thread Member Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html Gets the self member, as a member of this thread. If the current account is not a member of this thread, this will return null. ```APIDOC ## GET /websites/jda_wiki/threads/{threadId}/me/member ### Description Gets the self member, as a member of this thread. If the current account is not a member of this thread, this will return null. ### Method GET ### Endpoint /websites/jda_wiki/threads/{threadId}/me/member ### Response #### Success Response (200) - **ThreadMember** (object | null) - The self member of this thread, null if the current account is not a member of this thread. #### Response Example ```json { "userId": "987654321098765432", "joinTimestamp": "2023-01-01T12:00:00Z", "flags": 0 } ``` ### Throws - `DetachedEntityException` - If this entity is `detached`. ``` -------------------------------- ### Resetting Welcome Screen Fields Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/GuildWelcomeScreenManager.html Demonstrates how to reset specific fields of the welcome screen using either bit-flags or varargs. This is useful for reverting changes to the enabled state, description, or channels. ```java manager.reset(GuildWelcomeScreenManager.DESCRIPTION | GuildWelcomeScreenManager.CHANNELS); manager.reset(GuildWelcomeScreenManager.DESCRIPTION, GuildWelcomeScreenManager.CHANNELS); ``` -------------------------------- ### GuildWelcomeScreenManager Configuration Source: https://docs.jda.wiki/net/dv8tion/jda/api/managers/GuildWelcomeScreenManager.html Methods to configure the welcome screen settings including enabling, setting descriptions, and managing welcome channels. ```APIDOC ## GuildWelcomeScreenManager Configuration ### Description Methods to modify the state of a Guild's welcome screen. These methods support chaining for fluent API usage. ### Methods - **setEnabled(boolean enabled)**: Sets the enabled state of the welcome screen. - **setDescription(String description)**: Sets the description (max 140 characters). - **setWelcomeChannels(Collection channels)**: Sets the list of welcome channels (max 5). - **reset(long fields)**: Resets specific fields using bit-flag constants (ENABLED, DESCRIPTION, CHANNELS). ### Parameters #### Request Body - **enabled** (boolean) - Required - Whether the screen is active. - **description** (String) - Optional - Text description of the welcome screen. - **channels** (Collection) - Optional - List of welcome channels to display. ### Response #### Success Response (200) - **GuildWelcomeScreenManager** (Object) - The manager instance for further chaining. ### Request Example { "enabled": true, "description": "Welcome to our server!", "channels": ["channel_id_1", "channel_id_2"] } ``` -------------------------------- ### User Activity Start Event Source: https://docs.jda.wiki/net/dv8tion/jda/api/events/user/package-tree.html This event is fired when a user starts a new activity, such as playing a game or streaming. It includes details about the activity. ```APIDOC ## POST /users/{userId}/activity/start ### Description This endpoint is called when a user starts a new activity. ### Method POST ### Endpoint /users/{userId}/activity/start ### Parameters #### Path Parameters - **userId** (string) - Required - The ID of the user. #### Request Body - **activityType** (string) - Required - The type of activity (e.g., PLAYING, STREAMING, LISTENING, WATCHING). - **activityName** (string) - Required - The name of the activity. ### Request Example { "activityType": "PLAYING", "activityName": "JDA Wiki" } ### Response #### Success Response (200) - **status** (string) - Indicates success or failure. #### Response Example { "status": "success" } ``` -------------------------------- ### Get Thread Members Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/channel/concrete/ThreadChannel.html Gets a List of all cached members of this thread. The thread owner is not included in this list, unless the current account is the owner. ```APIDOC ## GET /websites/jda_wiki/threads/{threadId}/members ### Description Gets a List of all cached `members` of this thread. The thread owner is not included in this list, unless the current account is the owner. Any updates to this cache are lost when JDA is shutdown, and this list is not sent to JDA on startup. For this reason, `retrieveThreadMembers()` should be used instead in most cases. ### Method GET ### Endpoint /websites/jda_wiki/threads/{threadId}/members ### Response #### Success Response (200) - **List** (array) - List of all `members` of this thread. This list may be empty, but not null. #### Response Example ```json [ { "userId": "987654321098765432", "joinTimestamp": "2023-01-01T12:00:00Z", "flags": 0 }, { "userId": "112233445566778899", "joinTimestamp": "2023-01-02T13:00:00Z", "flags": 0 } ] ``` ### Throws - `DetachedEntityException` - If this entity is `detached`. ``` -------------------------------- ### Configuring a GuildChannel using ChannelAction Source: https://docs.jda.wiki/net/dv8tion/jda/api/requests/restaction/ChannelAction.html This example demonstrates how to use the ChannelAction interface to set properties like name, NSFW status, and permission overrides before executing the creation action. ```java guild.createTextChannel("general") .setNSFW(true) .addRolePermissionOverride(roleId, EnumSet.of(Permission.VIEW_CHANNEL), null) .queue(); ``` -------------------------------- ### Start New Shard using ShardManager Source: https://docs.jda.wiki/net/dv8tion/jda/api/sharding/DefaultShardManager.html Adds and starts a new shard with the specified ID within the ShardManager. This method is defined in the ShardManager interface. ```java /** * Adds a new shard with the given id to this ShardManager and starts it. * * @param shardId The id of the shard that should be started */ public void start(int shardId) ``` -------------------------------- ### Initialize RoleColors Instance Source: https://docs.jda.wiki/net/dv8tion/jda/api/entities/RoleColors.html Demonstrates how to instantiate the RoleColors class by providing primary, secondary, and tertiary color values. ```java RoleColors colors = new RoleColors(0xFF0000, 0x00FF00, 0x0000FF); ``` -------------------------------- ### Handle User Activity Start Events in ListenerAdapter Source: https://docs.jda.wiki/net/dv8tion/jda/api/hooks/ListenerAdapter.html Processes events when a user starts a new activity (e.g., playing a game). It receives a UserActivityStartEvent. ```java public void onUserActivityStart(@Nonnull UserActivityStartEvent event) ```