JDA ChannelManager 设置频道名称 查看在线统计数据

huangapple go评论94阅读模式
英文:

JDA ChannelManager setname Channel view online stats

问题

在加入 Discord 后,频道应该刷新并显示新的在线玩家数量。执行两次后,频道不再刷新。

public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) {
    Guild guild = event.getGuild();
    long online = guild.getMembers().stream()
            .filter(member ->
                    !member.getOnlineStatus().equals(OnlineStatus.OFFLINE))
            .count();
    VoiceChannel channel = event.getGuild().getVoiceChannelById(742890118943080480L);
    channel.getManager().setName("在线人数: " + online).queue();
}
英文:

After joining discord, the channel should refresh and show the new number of players online. After executing twice, the channel does not refresh again.

public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) {
    Guild guild = event.getGuild();
    long online = guild.getMembers().stream()
            .filter(member -> 
                    !member.getOnlineStatus().equals(OnlineStatus.OFFLINE))
            .count();
    VoiceChannel channel = event.getGuild().getVoiceChannelById(742890118943080480L);
    channel.getManager().setName("Online: " + online).queue();
}

答案1

得分: 0

Discord不希望机器人这么频繁地更新频道。频道名称不应该被用来显示这样的统计数据。他们最近在这个更新过程中引入了每10分钟2次的更新速率限制。

这意味着你不能在10分钟内更新频道名称(或主题)超过两次。

英文:

Discord doesn't want bots to update channels this often. Channel names are not supposed to be used to display statistics like this. They recently introduced a 2 / 10 minute rate limit on this update process.

This means you cannot update the channel name (or topic) more than twice every 10 minutes.

huangapple
  • 本文由 发表于 2020年8月12日 08:30:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63368132.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定