Java Discord API(JDA)旧Bot无法正常工作

时间:2020-11-01 00:36:00

标签: java discord

我正在使用该代码:

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.OnlineStatus;
import net.dv8tion.jda.core.entities.Game;

public class Main {
    static JDA jda;
    public static void main(String[] args) {
        JDABuilder jb = new JDABuilder();
        jb.setToken("My Bot Token");
        jb.setStatus(OnlineStatus.ONLINE);
        jb.setGame(Game.playing("Hello"));
        //jb.setAutoReconnect(true);
        jb.addEventListener(new tl());

        try {
            jda = jb.build();
            System.out.println(jda.getStatus());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

和tl.java是:

import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;

public class tl extends ListenerAdapter {
    @Override
    public void onReady(ReadyEvent event) {
        System.out.println("Finish Loading!");
    }
}

如果我使用旧机器人的令牌,那么我什么也没得到。但是,如果我使用新的机器人令牌,则会收到“完成加载!”。是否有一些jda问题?

0 个答案:

没有答案