Reputation: 3
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();
}
Upvotes: 0
Views: 467
Reputation: 6131
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.
Upvotes: 0