JDA
JDA copied to clipboard
Add support for components V2
Pull Request Etiquette
- [X] I have checked the PRs for upcoming features/bug fixes.
- [X] I have read the contributing guidelines.
Changes
- [X] Internal code
- [X] Library interface (affecting end-user code)
- [X] Documentation
- [ ] Other: _____
Closes Issue: NaN
Description
This adds the new component system (aka Components V2).
API docs:
- https://discord.com/developers/docs/change-log#introducing-new-components-for-messages
- https://discord.com/developers/docs/change-log#raised-component-limits
- https://discord.com/developers/docs/components/overview
Examples: ComponentsV2Example.java
Make sure to give your opinion on the JDA dev thread.
Supersedes #2806.
Installation (Preview)
You can use the "Using new features" guide from the JDA wiki.
Alternatively, you can get the newest version for your favorite tool, by using the /jitpack pr command in the JDA Discord server. You can use the Update PR button to merge the latest changes if necessary (note that it may not update it if there are conflicts).
Migration (Preview)
I've written an OpenRewrite recipe to update most (if not all) breaking changes.
Requirements
- Use a release JDA version (i.e., the group ID must be
net.dv8tion) - Your current code must compile
Usage
As with any migration tool, it is highly recommended to commit/push your changes before doing anything.
Note: Kotlin 2.X is not supported by OpenRewrite yet, however 1.X should work.
(Kotlin) Gradle
plugins {
// ...
id("org.openrewrite.rewrite") version "7.4.1"
}
repositories {
// ...
maven("https://jitpack.io")
}
dependencies {
// Existing JDA dependency
// ...
rewrite("io.github.freya022:JDA:{{latest commit hash}}")
rewrite("org.openrewrite.recipe:rewrite-java-dependencies:1.32.1")
}
rewrite {
activeRecipe("net.dv8tion.MigrateComponentsV2")
}
Checking changes (dry run)
Run the rewriteDryRun task, this can be done by pressing CTRL twice on IntelliJ then running gradle rewriteDryRun.
This will generate a diff file at build/reports/rewrite/rewrite.patch, you can check the possible changes there.
Applying changes
Run the rewriteRun task.
Maven
- Add the following repository:
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
- Add the following plugin:
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.6.1</version>
<configuration>
<activeRecipes>
<recipe>net.dv8tion.MigrateComponentsV2</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-java-dependencies</artifactId>
<version>1.32.1</version>
</dependency>
<dependency>
<groupId>io.github.freya022</groupId>
<artifactId>JDA</artifactId>
<version>{{latest commit hash}}</version>
</dependency>
</dependencies>
</plugin>
Checking changes (dry run)
Run the rewrite:dryRun goal, this can be done by pressing CTRL twice on IntelliJ then running mvn rewrite:dryRun.
This will generate a diff file at target/site/rewrite/rewrite.patch, you can check the possible changes there.
Applying changes
Run the rewrite:run goal.
You can then set the JDA dependency, as JDA 6.0.0 is not released.
It is recommended to optimize imports (Code | Optimize imports in IntelliJ) after migrating.
You're saying you have an issue but didn't describe what the issue is
@freya022 Seemed to be an issue on my side. Was just talking and just an hour after it founding it 😭
Bump
Is it intended that a TextDisplay can't be the first argument of a Section?
Yes, a TextDisplay cannot be an accessory.
alright, thank you
Minn sorting out