Skip to content

Guild does not have a self member #2897

@alvin0319

Description

@alvin0319

General Troubleshooting

  • I have checked for similar issues on the Issue-tracker.
  • I have checked for PRs that might already address this issue.

Version of JDA

6.0.0-rc.2

Expected Behaviour

JDA should be able to retrieve the self member.

Code Example for Reproduction Steps

embed.addField(
                "동시 접속 서버",
                bot.shardManager.guilds
                    .count { g -> (g as GuildImpl).selfMember.voiceState?.inAudioChannel() == true }
                    .toString(),
                false
            )

Code for JDABuilder or DefaultShardManagerBuilder used

val shardManager =
        DefaultShardManagerBuilder
            .createDefault(config.token)
            .enableIntents(
                GatewayIntent.MESSAGE_CONTENT,
                GatewayIntent.GUILD_VOICE_STATES
            ).enableCache(CacheFlag.EMOJI, CacheFlag.VOICE_STATE)
            .setGatewayEncoding(GatewayEncoding.ETF)
            .setAutoReconnect(true)
            .setAudioPool(
                Executors.newScheduledThreadPool(
                    maxVirtualThreadPoolSize,
                    Thread.ofVirtual().name("JDA-AudioPool-Thread-", 0).factory()
                )
            ).setRateLimitScheduler(
                Executors.newScheduledThreadPool(
                    maxVirtualThreadPoolSize,
                    Thread.ofVirtual().name("JDA-RateLimit-Thread-", 0).factory()
                )
            ).setEventPool(
                Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("JDA-Event-Thread-", 0).factory()),
                true
            ).setCallbackPool(
                Executors.newCachedThreadPool {
                    Thread(it, "CallbackPool")
                },
                true
            ).setMemberCachePolicy(MemberCachePolicy.VOICE)
            .setHttpClientBuilder(Constant.OKHTTP_CLIENT_BUILDER)
            .setHttpClient(Constant.OKHTTP_CLIENT_BUILDER.build())
            .setLargeThreshold(50)
            .build()

Exception or Error

[16:55:16.986] [JDA-Event-Thread-235378/ERROR] - One of the EventListeners had an uncaught exception
java.lang.IllegalStateException: Guild does not have a self member
        at net.dv8tion.jda.internal.entities.GuildImpl.getSelfMember(GuildImpl.java:751)
        at com.github.wow.ttalker.util.Constant.getHelpCommands(Constant.kt:87)
        at com.github.wow.ttalker.command.slash.BaseSlashCommand.sendHelpMessage(BaseSlashCommand.kt:210)
        at com.github.wow.ttalker.command.slash.HelpSlashCommand.execute(HelpSlashCommand.kt:7)
        at com.github.wow.ttalker.command.slash.BaseSlashCommand.preExecute(BaseSlashCommand.kt:47)
        at com.github.wow.ttalker.JDAListener.onSlashCommandInteraction(JDAListener.kt:605)
        at com.github.wow.ttalker.JDAListener.onEvent(JDAListener.kt:57)
        at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:98)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.lambda$handle$0(EventManagerProxy.java:68)
        at java.base/java.util.concurrent.ThreadPerTaskExecutor$TaskRunner.run(ThreadPerTaskExecutor.java:314)
        at java.base/java.lang.VirtualThread.run(VirtualThread.java:329)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions