discord.jar is
a work in progress Java wrapper for the Discord API.
Everything that needs doing can be found in the Issues tab, so if you're
interested in helping out it would be greatly appreciated! Developed & maintained by @seailz
You'll need to add discord.jar to your project's dependencies. We are currently using jitpack to host our builds. See tutorials for your dependency management system here.
A Discord bot token is required to use the API. You can get one by creating a bot account here.
To initialize a bot that uses the gateway (is able to receive events), you can use the following code:
new DiscordJv("token");You can specify intents to use with the gateway by using the following code:
new DiscordJv("token", EnumSet.of(Intent.GUILDS, Intent.GUILD_MESSAGES));Note: You can use the Intent.ALL constant to specify all intents. This does not include privileged intents.
To make your bot an HTTP only bot, you'll need to specify a couple more parameters.
new DiscordJv("token",EnumSet.of(Intents.GUILDS,Intents.GUILD_MESSAGES), APIVersion.getLatest(), true,
new HTTPOnlyInfo(
"interactions",
"EXAMPLE_APPLICATION_PUBLIC_KEY" // this cxan be found in your application's page in the dev panel
));You should set "interactions" to whatever endpoint you want to use to receive post requests from Discord. This will be
the endpoint you set in the Discord Developer Portal.
This WILL break some methods and is only recommended to be used if you know what you are doing. Otherwise, making a normal bot is recommended. HTTP-only bots (or Interaction-only bots) are bots that do not connect to the gateway, and therefore cannot receive events. They receive interactions through POST requests to a specified endpoint of your bot. This is useful if you want to make a bot that only uses slash commands.
Voice will not work, neither will setting your status & most gateway events.
Interaction-based events will still be delivered as usual.
To change the port of your web server, create a new file in the running directory called `application.properties` and add the following line:
server.port=8081
- Go to the Discord Developer Portal
- You'll want to start your bot if you haven't already.
- Select your bot.
- Go to the "General Information" tab.
- Scroll down to "INTERACTIONS ENDPOINT URL" and set it to the URL of your bot's endpoint. For example, if my bot's IP
was 123, the port was 321, and the endpoint was "interactions", I would set it to
http://123:321/interactions.
If it fails to save after that, please contact Seailz#0001 on Discord.
There is currently no documentation (excluding the tiny bit above), but it will be available here when it's ready. Although there is no documentation, there are still examples which are avaliable here
Javadocs can be found here.
If you want to contribute to this project, feel free to do so! Everything that needs doing can be found in the Issues tab, and if an issue there has the available tag you are free to make a PR fixing/adding it! :)
Make sure you first check the active PRs and branches for the feature/bug you're fixing/adding. If you make a PR for an issue with the claimed tag, and you are not the one who claimed it, (or in other words if there is a PR open for the issue you're looking to fix/add), then your PR will be closed.
If you've opened a PR, but it's not yet finished, please mark it as a draft PR.
Branches should be named either:
feature/[feature]
or
bug/[bugfix]
or
other[description].
To contribute to the /examples module, please see here.
/.github is off limits for contirubtions, please make an issue if there is an error in that folder.
Springframework - web sockets - may be removed soon,
org.json - json managing - may be removed soon,
jetbrains annotations (should stay?)
License info can be found here. This project is licensed under GNU General Public License V3
