discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.26k stars 730 forks source link

ClassNotFoundException: net.dv8tion.jda.api.entities.GuildChannel #2670

Closed ERmak148 closed 3 months ago

ERmak148 commented 3 months ago

General Troubleshooting

Version of JDA

v5.0.0-beta.23

Expected Behaviour

JDA should work

Code Example for Reproduction Steps

package org.example;

import com.jagrosh.jdautilities.command.CommandClient;
import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import org.example.commands.HelloWorld;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
    public static void main(String[] args) {
        EventWaiter waiter = new EventWaiter();

        CommandClient commandClient = new CommandClientBuilder()
                .setPrefix("..")
                .addCommand(new HelloWorld())
                .build();
        JDA bot = JDABuilder.createDefault("dinahu")
                .addEventListeners(commandClient, waiter)
                .build();

    }
}

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>MyDiscordBot1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <repositories>
        <repository>
            <id>central</id>
            <name>bintray</name>
            <url>https://jcenter.bintray.com</url>
        </repository>
    </repositories>
    <properties>
        <maven.compiler.source>20</maven.compiler.source>
        <maven.compiler.target>20</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>net.dv8tion</groupId>
            <artifactId>JDA</artifactId>
            <version>5.0.0-beta.23</version>
        </dependency>
        <dependency>
            <groupId>com.jagrosh</groupId>
            <artifactId>jda-utilities</artifactId>
            <version>3.0.2</version>
            <scope>compile</scope>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.13</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.13</version>
        </dependency>

    </dependencies>

</project>

Code for JDABuilder or DefaultShardManagerBuilder used

JDA bot = JDABuilder.createDefault("token")
                .addEventListeners(commandClient, waiter)
                .build();

Exception or Error

Exception in thread "main" java.lang.NoClassDefFoundError: net/dv8tion/jda/api/entities/GuildChannel
    at org.example.Main.main(Main.java:17)
Caused by: java.lang.ClassNotFoundException: net.dv8tion.jda.api.entities.GuildChannel
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more
nateweisz commented 3 months ago

jda-utilities is still on jda 4, I don't think it's recommended at all

Andre601 commented 3 months ago

This is not a JDA, but a JDA-Utilities issue. If you want to use utils for v5 of JDA, use 2.0-SNAPSHOT of JDA-Chewtils by Chew.

More info: https://github.com/Chew/JDA-Chewtils/wiki/Compatibility-with-JDA-4-%26-5