From cacc601ee7ed320d6d1ef1be38587af7dad5b5f1 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 19 Sep 2021 01:17:26 +0100 Subject: [PATCH] Get owner guild from config --- src/main/java/me/goudham/config/BotConfig.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/goudham/config/BotConfig.java b/src/main/java/me/goudham/config/BotConfig.java index 4dbaeff9..71ec6d2d 100644 --- a/src/main/java/me/goudham/config/BotConfig.java +++ b/src/main/java/me/goudham/config/BotConfig.java @@ -3,6 +3,7 @@ package me.goudham.config; import io.micronaut.context.annotation.Factory; import io.micronaut.context.annotation.Value; import io.micronaut.core.annotation.Introspected; +import io.micronaut.core.annotation.Order; import jakarta.inject.Inject; import jakarta.inject.Singleton; import java.util.List; @@ -28,7 +29,10 @@ public class BotConfig { } @Singleton - public Guild ownerGuild(JDA jda) { + @Order(2) + public Guild ownerGuild(JDA jda) throws InterruptedException { + jda.awaitStatus(JDA.Status.CONNECTED); + Guild ownerGuild = jda.getGuildById(guildId); if (ownerGuild == null) { throw new RuntimeException("Owner Guild Not Found"); @@ -37,11 +41,11 @@ public class BotConfig { } @Singleton + @Order(1) public JDA jda() throws LoginException { return JDABuilder .createDefault(token) .setActivity(Activity.playing("With Hamothy")) - .addEventListeners() .enableIntents( List.of( GatewayIntent.GUILD_MEMBERS,