我正在尝试使用 Java JDA 和 gradle 创建一个Discord机器人。我试图使其联机,但它不起作用。我试图重新生成令牌并创建另一个项目。似乎没有任何作用。我使用的是Java 11,没有任何错误。什么原因可能导致此问题?
build.gradle:
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
jcenter()
}
dependencies {
compile("net.dv8tion:JDA:4.2.0_168")
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Main.java:
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
public class Main {
public static void main(String args[]) throws Exception{
JDA api = JDABuilder.createDefault("example").build();
System.out.println("Hello World");
}
}
输出:
9:53:30 PM: Executing task...
Starting Gradle Daemon...
Gradle Daemon started in 3 s 785 ms
> Task :help
Welcome to Gradle 6.1.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
For troubleshooting, visit https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 17s
1 actionable task: 1 executed
9:53:57 PM: Task execution finished.