fix: MemberCachePolicy.ALL only when GUILD_MEMBERS intent enabled
Auxiliary music/radio bots don't enable GUILD_MEMBERS, so JDA checkIntents threw 'Cannot use MemberCachePolicy.ALL without GatewayIntent.GUILD_MEMBERS' and the whole cluster crashed at startup. Apply member cache + chunking only for the main bot; aux bots keep MemberCachePolicy.NONE / ChunkingFilter.NONE (also saves memory).
This commit is contained in:
parent
c54a0d66dc
commit
2865f05fff
1 changed files with 3 additions and 2 deletions
|
|
@ -16,13 +16,14 @@ public final class JdaFactory {
|
|||
|
||||
public static JDABuilder createBuilder(
|
||||
final String token, final String activity, final GatewayIntent... intents) {
|
||||
boolean members = List.of(intents).contains(GatewayIntent.GUILD_MEMBERS);
|
||||
return JDABuilder.createDefault(token)
|
||||
.setStatus(OnlineStatus.ONLINE)
|
||||
.setActivity(Activity.playing(activity))
|
||||
.enableIntents(List.of(intents))
|
||||
.enableCache(CacheFlag.VOICE_STATE)
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.setChunkingFilter(ChunkingFilter.ALL);
|
||||
.setMemberCachePolicy(members ? MemberCachePolicy.ALL : MemberCachePolicy.NONE)
|
||||
.setChunkingFilter(members ? ChunkingFilter.ALL : ChunkingFilter.NONE);
|
||||
}
|
||||
|
||||
public static JDA awaitJda(final JDA jda) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue