JDA-Applications / JDA-Utilities

A series of tools and utilities for JDA to assist in bot creation
Apache License 2.0
217 stars 110 forks source link

Doesn't work at all. #119

Closed vadympop closed 3 years ago

vadympop commented 3 years ago

I create a base bot, it doesn't work at all

My main class:

package jtools;

import com.jagrosh.jdautilities.command.CommandClient;
import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.AccountType;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import jtools.different.PingCommand;

public class BaseBot {

    public static void main(String[] args) throws Exception {
        EventWaiter waiter = new EventWaiter();
        CommandClientBuilder builder = new CommandClientBuilder();
        builder.setPrefix("j!")
                .setOwnerId("660110922865704980")
                .setHelpWord("help")
                .addCommand(new PingCommand());

        CommandClient client = builder.build();

        new JDABuilder(AccountType.BOT)
                .setToken("")
                .setActivity(Activity.playing("j!help"))
                .setStatus(OnlineStatus.IDLE)
                .addEventListeners(waiter, client)
                .build();
    }
}

PingCommand class:

package jtools.different;

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;

public class PingCommand extends Command {
    public PingCommand(){
        this.name = "ping";
    }

    @Override
    protected void execute(CommandEvent commandEvent) {
        commandEvent.reply("Hello, my ping is " + commandEvent.getJDA().getGatewayPing());
    }
}

Please help me

topi314 commented 3 years ago

update jda

vadympop commented 3 years ago

Latest version

Horstexplorer commented 3 years ago

You either are not on the latest version or are ignoring the big deprecated message. In either case update to the latest JDA with it's new factory methods.

vadympop commented 3 years ago

No, I have a latest version of JDA, but I have this Screenshot_62

RedDaedalus commented 3 years ago

That's not an error, it's just a warning telling you to configure your logger.

sebm253 commented 3 years ago

That's not an error, it's just a warning telling you to configure your logger.

.. about which you can read more here-FAQ#why-is-there-a-warning-from-slf4j-when-starting-up)

vadympop commented 3 years ago

Ok. But why doesn't my code work at all?

Horstexplorer commented 3 years ago

You either are not on the latest version or are ignoring the big deprecated message. In either case update to the latest JDA with it's new factory methods.

It doesnt work like this anymore. Have a look at the readme as it literally shows what to use instead.

DManstrator commented 3 years ago

Check the JDA ReadMe and Wiki since this is a general JDA issue, not a JDA-Utils issue. And please follow issue templates when seeing them.

jagrosh commented 3 years ago

Without more information it's impossible to help you debug. If you haven't already, I would recommend joining the JDA server and providing more info in the #jda-utilities channel.