【问题标题】:JDA returing null when getting guild by idJDA 在通过 id 获取公会时返回 null
【发布时间】:2021-03-06 03:26:12
【问题描述】:

我正在制作 Minecraft 插件,它会与 discord 通信,但是当我尝试通过 id 获取公会时,它会返回 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 是命令执行者,我正在尝试从中获取公会。

【问题讨论】:

    标签: java minecraft bukkit discord-jda


    【解决方案1】:

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

    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);
    

    您可以在 wiki 上查看简单问题 https://github.com/DV8FromTheWorld/JDA/wiki

    【讨论】:

      猜你喜欢
      • 2021-09-09
      • 2020-05-04
      • 2021-12-28
      • 2021-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多