英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论