我有这个托管在Heroku上的java不和谐机器人,在升级到最新版本的JDA之后,我不得不将onGuildMessageReceived更改为onMessageReceived。在intellij上运行我的机器人时,它没有任何问题,但是在Heroku执行它时,每次我发出关于不和谐的消息时,它都会给我“net.dv8tion.jda.api.entities.GuildVoiceState.getChannel()”:net.dv8tion.jda.api.entities.AudioChannel“。导致这个错误的代码是:onMessageReceived内部的AudioChannel audioChannel = e.getMember().getVoiceState().getChannel();。
我个人认为maven可能将错误的版本导入Heroku,但我没有任何方法检查它,所以这里是我的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.furetto126.furettobot.FurettoBot</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>com.furetto126.furettobot</groupId>
<artifactId>FurettoBot</artifactId>
<version>1.1</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<repositories>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.77</version>
</dependency>
</dependencies>
</project>发布于 2022-06-20 15:04:41
根据我的经验,java.lang.NoSuchMethodError通常意味着有jar冲突,其中sugget有多个包含特定类的jar文件。您可以在idea中简单地双击shift,并搜索特定的类名,以检查jar是否包含某些类。
https://stackoverflow.com/questions/72688812
复制相似问题