Skip to content

Commit e52cd7d

Browse files
authored
Add support for components V2 (#2809)
1 parent ffadc41 commit e52cd7d

172 files changed

Lines changed: 11513 additions & 1766 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ src-old/examples/java/TestReceive.java
5050
src-old/main/java/net/dv8tion/jda/events/audio/AudioMovedEvent.java
5151
src-old/main/java/net/dv8tion/jda/ratelimit/Bucket.java
5252
src-old/main/java/net/dv8tion/jda/ratelimit/RateLimitControl.java
53+
54+
# Recipe jars
55+
src/test/resources/**/*.jar

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ And configurators like:
253253
```java
254254
public RestAction<Void> selfDestruct(MessageChannel channel, String content) {
255255
return channel.sendMessage("The following message will destroy itself in 1 minute!")
256-
.addActionRow(Button.danger("delete", "Delete now")) // further amend message before sending
256+
.addComponents(ActionRow.of(Button.danger("delete", "Delete now"))) // further amend message before sending
257257
.delay(10, SECONDS, scheduler) // after sending, wait 10 seconds
258258
.flatMap((it) -> it.editMessage(content)) // then edit the message
259259
.delay(1, MINUTES, scheduler) // wait another minute

build.gradle.kts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ configure<SourceSetContainer> {
114114
// //
115115
////////////////////////////////////
116116

117+
val recipeParserClasspath by configurations.creating
117118

118119
repositories {
119120
mavenLocal()
@@ -168,6 +169,25 @@ dependencies {
168169
testImplementation(libs.commons.lang3)
169170
testImplementation(libs.logback.classic)
170171
testImplementation(libs.archunit)
172+
173+
// OpenRewrite
174+
// Import Rewrite's bill of materials.
175+
testImplementation(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.6.1"))
176+
177+
// rewrite-java dependencies only necessary for Java Recipe development
178+
testImplementation("org.openrewrite:rewrite-java")
179+
testImplementation("org.openrewrite.recipe:rewrite-java-dependencies")
180+
181+
// This is supposed to only be the version that corresponds to the current Java version,
182+
// but as there are no toolchain, we include all, they can coexist safely tho.
183+
testRuntimeOnly("org.openrewrite:rewrite-java-8")
184+
testRuntimeOnly("org.openrewrite:rewrite-java-11")
185+
testRuntimeOnly("org.openrewrite:rewrite-java-17")
186+
187+
// For authoring tests for any kind of Recipe
188+
testImplementation("org.openrewrite:rewrite-test")
189+
190+
recipeParserClasspath("net.dv8tion:JDA:5.6.1")
171191
}
172192

173193
fun isNonStable(version: String): Boolean {
@@ -459,6 +479,16 @@ nexusPublishing {
459479
}
460480
}
461481

482+
val downloadRecipeClasspath by tasks.registering(Copy::class) {
483+
from(recipeParserClasspath)
484+
into("src/test/resources/META-INF/rewrite/classpath")
485+
486+
include("JDA-*.jar")
487+
}
488+
489+
tasks.named("processTestResources").configure {
490+
dependsOn(downloadRecipeClasspath)
491+
}
462492

463493
////////////////////////////////////
464494
// //

overview.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<li><a target="_blank" href="https://github.com/discord-jda/JDA/blob/master/src/examples/java/MessageLoggerExample.java">Message Logging</a></li>
3333
<li><a target="_blank" href="https://github.com/discord-jda/JDA/blob/master/src/examples/java/SlashBotExample.java">Slash Commands</a></li>
3434
<li><a target="_blank" href="https://github.com/discord-jda/JDA/blob/master/src/examples/java/AudioEchoExample.java">Receiving and Sending Audio</a></li>
35+
<li><a target="_blank" href="https://github.com/discord-jda/JDA/blob/master/src/examples/java/LocalizationExample.java">Localizing application commands</a></li>
36+
<li><a target="_blank" href="https://github.com/discord-jda/JDA/blob/master/src/examples/java/ComponentsV2Example.java">Using components V2</a></li>
3537
</ul>
3638

3739
<p>Other useful resources:

0 commit comments

Comments
 (0)