jda按id获取guild时返回null

pbgvytdp  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(320)

我正在制作minecraft插件,它将与discord通信,但是当我试图通过id获取guild时,它将返回null。

jda = new JDABuilder(AccountType.BOT).setToken(token).build();
jda.addEventListener(new ReactionRecieveEvent(this));
jda.addEventListener(new CreateNewVoiceChannel(this));
jda.addEventListener(new DeleteEmptyChannel(this));
new VerifyCommand(this);

这是我构建jda的地方。类verifycommand是命令执行者,我正试图从中获得公会。

dgtucam1

dgtucam11#

这种方式已被弃用,所以请使用这种方式。

jda = JDABuilder.createDefault(token).build();
jda.addEventListener(new ReactionRecieveEvent(this));
jda.addEventListener(new CreateNewVoiceChannel(this));
jda.addEventListener(new DeleteEmptyChannel(this));
new VerifyCommand(this);

或者你可以用这种方法来提高可读性

jda = JDABuilder.createDefault(token)
    .addEventListener(new ReactionRecieveEvent(this))
    .addEventListener(new CreateNewVoiceChannel(this))
    .addEventListener(new DeleteEmptyChannel(this))
    .build();
new VerifyCommand(this);

你可以在维基上看到一些简单的问题https://github.com/dv8fromtheworld/jda/wiki

相关问题