Get owner guild from config

java-rewrite
Hammy 3 years ago
parent 982a682a39
commit cacc601ee7

@ -3,6 +3,7 @@ package me.goudham.config;
import io.micronaut.context.annotation.Factory; import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Value; import io.micronaut.context.annotation.Value;
import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.Order;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Singleton; import jakarta.inject.Singleton;
import java.util.List; import java.util.List;
@ -28,7 +29,10 @@ public class BotConfig {
} }
@Singleton @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); Guild ownerGuild = jda.getGuildById(guildId);
if (ownerGuild == null) { if (ownerGuild == null) {
throw new RuntimeException("Owner Guild Not Found"); throw new RuntimeException("Owner Guild Not Found");
@ -37,11 +41,11 @@ public class BotConfig {
} }
@Singleton @Singleton
@Order(1)
public JDA jda() throws LoginException { public JDA jda() throws LoginException {
return JDABuilder return JDABuilder
.createDefault(token) .createDefault(token)
.setActivity(Activity.playing("With Hamothy")) .setActivity(Activity.playing("With Hamothy"))
.addEventListeners()
.enableIntents( .enableIntents(
List.of( List.of(
GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_MEMBERS,

Loading…
Cancel
Save