{"id":13410395,"url":"https://github.com/discord-jda/JDA","last_synced_at":"2025-03-14T15:32:36.096Z","repository":{"id":37579843,"uuid":"47880207","full_name":"discord-jda/JDA","owner":"discord-jda","description":"Java wrapper for the popular chat \u0026 VOIP service: Discord https://discord.com","archived":false,"fork":false,"pushed_at":"2024-10-08T17:46:42.000Z","size":33553,"stargazers_count":4332,"open_issues_count":53,"forks_count":736,"subscribers_count":81,"default_branch":"master","last_synced_at":"2024-10-29T18:11:29.202Z","etag":null,"topics":["api","api-wrapper","bot","bot-api","discord","hacktoberfest","java","javadoc","jda","promoted-downloads","rest","rest-api","websocket"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discord-jda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"java-jda","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2015-12-12T13:57:32.000Z","updated_at":"2024-10-27T14:37:21.000Z","dependencies_parsed_at":"2023-09-04T13:50:06.931Z","dependency_job_id":"6791b10f-2c13-4aec-a158-87b5bfc55b9b","html_url":"https://github.com/discord-jda/JDA","commit_stats":{"total_commits":2417,"total_committers":184,"mean_commits":13.13586956521739,"dds":0.6921803889118743,"last_synced_commit":"e46bacb3ab6239522a9e242b885b9110f3941035"},"previous_names":["discord-jda/jda","dv8fromtheworld/jda"],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-jda%2FJDA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-jda%2FJDA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-jda%2FJDA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord-jda%2FJDA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discord-jda","download_url":"https://codeload.github.com/discord-jda/JDA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242973976,"owners_count":20215251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-wrapper","bot","bot-api","discord","hacktoberfest","java","javadoc","jda","promoted-downloads","rest","rest-api","websocket"],"created_at":"2024-07-30T20:01:06.621Z","updated_at":"2025-03-14T15:32:35.418Z","avatar_url":"https://github.com/discord-jda.png","language":"Java","readme":"[maven-central]: https://img.shields.io/maven-central/v/net.dv8tion/JDA?color=blue\n[jitpack]: https://img.shields.io/badge/Snapshots-JitPack-blue\n[installation]: #-installation\n[discord-invite]: https://discord.gg/0hMr4ce0tIl3SLv5\n[migration]: https://jda.wiki/introduction/migration-v4-v5/\n[jenkins]: https://ci.dv8tion.net/job/JDA5\n[license]: https://github.com/discord-jda/JDA/tree/master/LICENSE\n[faq]: https://jda.wiki/introduction/faq/\n[docs]: https://docs.jda.wiki/index.html\n[wiki]: https://jda.wiki/introduction/jda/\n[troubleshooting]: https://jda.wiki/using-jda/troubleshooting/\n[discord-shield]: https://discord.com/api/guilds/125227483518861312/widget.png\n[faq-shield]: https://img.shields.io/badge/Wiki-FAQ-blue.svg\n[docs-shield]: https://img.shields.io/badge/Wiki-Docs-blue.svg\n[troubleshooting-shield]: https://img.shields.io/badge/Wiki-Troubleshooting-darkgreen.svg\n[jenkins-shield]: https://img.shields.io/badge/Download-Jenkins-purple.svg\n[license-shield]: https://img.shields.io/badge/License-Apache%202.0-white.svg\n[migration-shield]: https://img.shields.io/badge/Wiki-Migrating%20from%20V4-darkgreen.svg\n[GatewayIntent]: https://docs.jda.wiki/net/dv8tion/jda/api/requests/GatewayIntent.html\n[JDABuilder]: https://docs.jda.wiki/net/dv8tion/jda/api/JDABuilder.html\n[DefaultShardManagerBuilder]: https://docs.jda.wiki/net/dv8tion/jda/api/sharding/DefaultShardManagerBuilder.html\n\n\u003cimg align=\"right\" src=\"https://github.com/discord-jda/JDA/blob/assets/assets/readme/logo.png?raw=true\" height=\"150\" width=\"150\"\u003e\n\n[![maven-central][]][installation]\n[![jitpack][]](https://jitpack.io/#discord-jda/JDA)\n[![jenkins-shield][]][jenkins]\n[![license-shield][]][license]\n\n[![discord-shield][]][discord-invite]\n[![faq-shield]][faq]\n[![docs-shield]][docs]\n[![troubleshooting-shield]][troubleshooting]\n[![migration-shield][]][migration]\n\n# JDA (Java Discord API)\n\nThis open source library is intended for implementing bots on Discord using the real-time gateway and REST API. It provides event based functionality to implement bots of any kind, allowing for effective and scalable applications.\n\n## 📖 Overview\n\nThe core concepts of JDA have been developed to make building scalable apps easy:\n\n1. Event System  \n    Providing simplified events from the gateway API, to respond to any platform events in real-time without much hassle.\n1. Rest Actions  \n    Easy to use and scalable implementation of REST API functionality, letting you choose between callbacks with combinators, futures, and blocking.\n    The library also handles rate-limits imposed by Discord automatically, while still offering ways to replace the default implementation.\n1. Customizable Cache  \n    Trading memory usage for better performance where necessary, with sane default presets to choose from and customize.\n\nYou can learn more by visiting our [wiki][wiki] or referencing our [Javadocs][docs].\n\n## 🔬 Installation\n\n[![maven-central][]](https://mvnrepository.com/artifact/net.dv8tion/JDA/latest)\n[![jitpack][]](https://jitpack.io/#discord-jda/JDA)\n\nThis library is available on maven central. The latest version is always shown in the [GitHub Release](https://github.com/discord-jda/JDA/releases/latest).\n\nThe minimum java version supported by JDA is **Java SE 8**. JDA also uses JSR 305 to support solid interoperability with Kotlin out of the box.\n\n### Gradle\n\n```gradle\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"net.dv8tion:JDA:$version\") { // replace $version with the latest version\n      // Optionally disable audio natives to reduce jar size by excluding `opus-java`\n      // Gradle DSL:\n      // exclude module: 'opus-java'\n      // Kotlin DSL:\n      // exclude(module=\"opus-java\")\n    }\n}\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enet.dv8tion\u003c/groupId\u003e\n    \u003cartifactId\u003eJDA\u003c/artifactId\u003e\n    \u003cversion\u003e$version\u003c/version\u003e \u003c!-- replace $version with the latest version --\u003e\n    \u003c!-- Optionally disable audio natives to reduce jar size by excluding `opus-java`\n    \u003cexclusions\u003e\n        \u003cexclusion\u003e\n            \u003cgroupId\u003eclub.minnced\u003c/groupId\u003e\n            \u003cartifactId\u003eopus-java\u003c/artifactId\u003e\n        \u003c/exclusion\u003e\n    \u003c/exclusions\u003e\n    --\u003e\n\u003c/dependency\u003e\n```\n\n## 🤖 Creating a Bot\n\nTo use this library, you have to create an Application in the [Discord Application Dashboard](https://discord.com/developers/applications) and grab your bot token. You can find a step-by-step guide for this in our wiki page [Creating a Discord Bot](https://jda.wiki/using-jda/getting-started/#creating-a-discord-bot).\n\n## 🏃‍♂️ Getting Started\n\nWe provide a number of [examples](https://github.com/discord-jda/JDA/tree/master/src/examples/java) to introduce you to JDA. You can also take a look at our official [Wiki][wiki], [Documentation][docs], and [FAQ][faq].\n\nEvery bot implemented by JDA starts out using the [JDABuilder][JDABuilder] or [DefaultShardManagerBuilder][DefaultShardManagerBuilder]. Both builders provide a set of default presets for cache usage and events it wants to receive:\n\n- `createDefault` - Enables cache for users who are active in voice channels and all cache flags\n- `createLight` - Disables all user cache and cache flags\n- `create` - Enables member chunking, caches all users, and enables all cache flags\n\nWe recommend reading the guide on [caching and intents](https://jda.wiki/using-jda/gateway-intents-and-member-cache-policy/) to get a feel for configuring your bot properly. Here are some possible use-cases:\n\n### Example: Message Logging\n\n\u003e [!NOTE]\n\u003e The following example makes use of the **privileged intent** `GatewayIntent.MESSAGE_CONTENT`, which must be explicitly enabled in your application dashboard. You can find out more about intents in our [wiki guide](https://jda.wiki/using-jda/gateway-intents-and-member-cache-policy/).\n\nSimply logging messages to the console. Making use of [JDABuilder][JDABuilder], the intended entry point for smaller bots that don't intend to grow to thousands of guilds.\n\nStarting your bot and attaching an event listener, using the right [intents][GatewayIntent]:\n\n```java\npublic static void main(String[] args) {\n  JDABuilder.createLight(token, EnumSet.of(GatewayIntent.GUILD_MESSAGES, GatewayIntent.MESSAGE_CONTENT))\n      .addEventListeners(new MessageReceiveListener())\n      .build();\n}\n```\n\nYour event listener could look like this:\n\n```java\npublic class MessageReceiveListener extends ListenerAdapter {\n  @Override\n  public void onMessageReceived(MessageReceivedEvent event) {\n    System.out.printf(\"[%s] %#s: %s\\n\",\n      event.getChannel(),\n      event.getAuthor(),\n      event.getMessage().getContentDisplay());\n  }\n}\n```\n\nYou can find a more thorough example with the [MessageLoggerExample](https://github.com/discord-jda/JDA/blob/master/src/examples/java/MessageLoggerExample.java) class.\n\n### Example: Slash Command Bot\n\nThis is a bot that makes use of [interactions](https://jda.wiki/using-jda/interactions/) to respond to user commands. Unlike the message logging bot, this bot can work without any enabled intents, since interactions are always available.\n\n```java\npublic static void main(String[] args) {\n  JDA jda = JDABuilder.createLight(token, Collections.emptyList())\n      .addEventListeners(new SlashCommandListener())\n      .build();\n\n  // Register your commands to make them visible globally on Discord:\n\n  CommandListUpdateAction commands = jda.updateCommands();\n\n  // Add all your commands on this action instance\n  commands.addCommands(\n    Commands.slash(\"say\", \"Makes the bot say what you tell it to\")\n      .addOption(STRING, \"content\", \"What the bot should say\", true), // Accepting a user input\n    Commands.slash(\"leave\", \"Makes the bot leave the server\")\n      .setGuildOnly(true) // this doesn't make sense in DMs\n      .setDefaultPermissions(DefaultMemberPermissions.DISABLED) // only admins should be able to use this command.\n  );\n\n  // Then finally send your commands to discord using the API\n  commands.queue();\n}\n```\n\nAn event listener that responds to commands could look like this:\n\n```java\npublic class SlashCommandListener extends ListenerAdapter {\n  @Override\n  public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {\n    switch (event.getName()) {\n      case \"say\" -\u003e {\n        String content = event.getOption(\"content\", OptionMapping::getAsString);\n        event.reply(content).queue();\n      };\n      case \"leave\" -\u003e {\n        event.reply(\"I'm leaving the server now!\")\n          .setEphemeral(true) // this message is only visible to the command user\n          .flatMap(m -\u003e event.getGuild().leave()) // append a follow-up action using flatMap\n          .queue(); // enqueue both actions to run in sequence (send message -\u003e leave guild)\n      };\n      default -\u003e return;\n    }\n  }\n}\n```\n\nYou can find a more thorough example with the [SlashBotExample](https://github.com/discord-jda/JDA/blob/master/src/examples/java/SlashBotExample.java) class.\n\n## 🚀 RestAction\n\nIn this library, the [RestAction](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html) interface is used as a request builder for all API endpoints.\nThis interface represents a lazy request builder, as shown in this simple example:\n\n```java\nchannel.sendMessage(\"Hello Friend!\")\n  .addFiles(FileUpload.fromData(greetImage)) // Chain builder methods to configure the request\n  .queue() // Send the request asynchronously\n```\n\n\u003e [!IMPORTANT]\n\u003e The final call to [`queue()`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#queue%28%29) sends the request.\n\u003e You can also send the request synchronously or using futures, check out our extended guide in the [RestAction Wiki](https://jda.wiki/using-jda/using-restaction/).\n\nThe RestAction interface also supports a number of operators to avoid callback hell:\n\n- [`map`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#map%28java.util.function.Function%29)  \n    Convert the result of the `RestAction` to a different value\n- [`flatMap`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#flatMap%28java.util.function.Function%29)  \n    Chain another `RestAction` on the result\n- [`delay`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#delay%28java.time.Duration%29)  \n    Delay the element of the previous step\n\nAs well as combinators like:\n\n- [`and`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#and(net.dv8tion.jda.api.requests.RestAction,java.util.function.BiFunction))  \n   Require another RestAction to complete successfully, running in parallel\n- [`allOf`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#allOf(java.util.Collection))  \n   Accumulate a list of many actions into one (see also [`mapToResult`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#mapToResult()))\n- [`zip`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#zip(net.dv8tion.jda.api.requests.RestAction,net.dv8tion.jda.api.requests.RestAction...))  \n   Similar to `and`, but combines the results into a list\n  \n\nAnd configurators like:\n\n- [`timeout`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#timeout(long,java.util.concurrent.TimeUnit)) and [`deadline`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#deadline(long))  \n   Configure how long the action is allowed to be in queue, cancelling if it takes too long\n- [`setCheck`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/RestAction.html#setCheck(java.util.function.BooleanSupplier))  \n   Running some checks right before the request is sent, this can be helpful when it is in queue for a while\n- [`reason`](https://docs.jda.wiki/net/dv8tion/jda/api/requests/restaction/AuditableRestAction.html#reason(java.lang.String))  \n   The [audit log reason](https://discord.com/developers/docs/resources/audit-log) for an action\n\n**Example**:\n\n```java\npublic RestAction\u003cVoid\u003e selfDestruct(MessageChannel channel, String content) {\n    return channel.sendMessage(\"The following message will destroy itself in 1 minute!\")\n        .addActionRow(Button.danger(\"delete\", \"Delete now\")) // further amend message before sending\n        .delay(10, SECONDS, scheduler) // after sending, wait 10 seconds\n        .flatMap((it) -\u003e it.editMessage(content)) // then edit the message\n        .delay(1, MINUTES, scheduler) // wait another minute\n        .flatMap(Message::delete); // then delete\n}\n```\n\nThis could then be used in code:\n\n```java\nselfDestruct(channel, \"Hello friend, this is my secret message\").queue();\n```\n\n## 🧩 Extensions\n\n### [jda-ktx](https://github.com/MinnDevelopment/jda-ktx)\n\nCreated and maintained by [MinnDevelopment](https://github.com/MinnDevelopment).  \nProvides [Kotlin](https://kotlinlang.org/) extensions for **RestAction** and events that provide a more idiomatic Kotlin experience.\n\n```kotlin\nfun main() {\n    val jda = light(BOT_TOKEN)\n    \n    jda.onCommand(\"ping\") { event -\u003e\n        val time = measureTime {\n            event.reply(\"Pong!\").await() // suspending\n        }.inWholeMilliseconds\n\n        event.hook.editOriginal(\"Pong: $time ms\").queue()\n    }\n}\n```\n\nThere are a number of examples available in the [README](https://github.com/MinnDevelopment/jda-ktx/#jda-ktx).\n\n### [Lavaplayer](https://github.com/lavalink-devs/lavaplayer)\n\nCreated by [sedmelluq](https://github.com/sedmelluq) and now maintained by the [lavalink community](https://github.com/lavalink-devs)  \nLavaplayer is the most popular library used by Music Bots created in Java.\nIt is highly compatible with JDA and Discord4J and allows playing audio from\nYouTube, Soundcloud, Twitch, Bandcamp and [more providers](https://github.com/lavalink-devs/lavaplayer#supported-formats).  \nThe library can easily be expanded to more services by implementing your own AudioSourceManager and registering it.\nWe recommend to also use [udpqueue](#udpqueue-an-extension-of-jda-nas) in addition to lavaplayer, to avoid stuttering issues caused by GC pauses.\n\nIt is recommended to read the [Usage](https://github.com/lavalink-devs/lavaplayer#usage) section of Lavaplayer\nto understand a proper implementation.  \nSedmelluq provided a demo in his repository which presents an example implementation for JDA:\nhttps://github.com/lavalink-devs/lavaplayer/tree/master/demo-jda\n\n### [udpqueue](https://github.com/MinnDevelopment/udpqueue.rs) (an extension of [jda-nas](https://github.com/sedmelluq/jda-nas))\n\nCreated and maintained by [sedmelluq](https://github.com/sedmelluq) and extended by [MinnDevelopment](https://github.com/MinnDevelopment)  \nProvides a native implementation for the JDA Audio Send-System **to avoid GC pauses potentially causing problems** with continuous audio playback.\n\nNote that this send-system creates an extra UDP-Client which causes audio receive to no longer function properly,\nsince Discord identifies the sending UDP-Client as the receiver.\n\n```java\nJDABuilder builder = JDABuilder.createDefault(BOT_TOKEN)\n    .setAudioSendFactory(new NativeAudioSendFactory());\n```\n\n### [Lavalink](https://github.com/lavalink-devs/Lavalink)\n\nCreated by [Freya Arbjerg](https://github.com/freyacodes) and now maintained by the [lavalink community](https://github.com/lavalink-devs).\n\nLavalink is a popular standalone audio sending node based on Lavaplayer. Lavalink was built with scalability in mind,\nand allows streaming music via many servers. It supports most of Lavaplayer's features.\n\nLavalink is used by many large bots, as well as bot developers who can not use a Java library like Lavaplayer.\nIf you plan on serving music on a smaller scale with JDA, it is often preferable to just use Lavaplayer directly\nas it is easier.\n\n[Lavalink-Client](https://github.com/FredBoat/Lavalink-Client) is the official Lavalink client for JDA.\n\n## 🛠️ Contributing to JDA\n\nIf you want to contribute to JDA, make sure to base your branch off of our **master** branch (or a feature-branch)\nand create your PR into that **same** branch.\n\nPlease follow our [Contributing Guidelines](https://github.com/discord-jda/JDA/blob/master/.github/CONTRIBUTING.md).\n\nDo not expect your pull request to get immediate attention, sometimes it will take a long time to get a response.\nYou can join our [discord server][discord-invite] and ask in [#lib-dev](https://discord.com/channels/125227483518861312/869965829024915466) before starting to work on a new PR, to get more immediate feedback from our community members.\n\n## 🚨 Breaking Changes\n\nDue to the nature of the Discord API, the library will regularly introduce breaking changes to allow for a quick adoption of newer features. We try to keep these breaking changes minimal, but cannot avoid them entirely.\n\nMost breaking changes will result in a **minor** version bump (`5.1.2` → `5.2.0`).\n","funding_links":["https://opencollective.com/java-jda"],"categories":["Libraries","Java"],"sub_categories":["Java"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord-jda%2FJDA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscord-jda%2FJDA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord-jda%2FJDA/lists"}