From e6adabc46dd8cb0792b84ea86f96f836b64bb09e Mon Sep 17 00:00:00 2001 From: Hammy Date: Sat, 18 Sep 2021 13:35:45 +0100 Subject: [PATCH] Load in owner guild --- src/main/java/me/goudham/config/BotConfig.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/goudham/config/BotConfig.java b/src/main/java/me/goudham/config/BotConfig.java index b7952583..1a454fae 100644 --- a/src/main/java/me/goudham/config/BotConfig.java +++ b/src/main/java/me/goudham/config/BotConfig.java @@ -5,14 +5,12 @@ import io.micronaut.context.annotation.Value; import io.micronaut.core.annotation.Introspected; import jakarta.inject.Inject; import jakarta.inject.Singleton; -import java.util.Collections; import java.util.List; -import java.util.Map; import javax.security.auth.login.LoginException; -import me.goudham.command.ICommand; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.entities.Activity; +import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -20,15 +18,22 @@ import net.dv8tion.jda.api.utils.cache.CacheFlag; @Introspected public class BotConfig { private final String token; + private final String guildId; @Inject - public BotConfig(@Value(value = "${bot.token}") String token) { + public BotConfig(@Value("${bot.token}") String token, + @Value("${bot.guild.id}") String guildId) { this.token = token; + this.guildId = guildId; } @Singleton - Map> commandsMap() { - return Collections.emptyMap(); + public Guild guild(JDA jda) { + Guild ownerGuild = jda.getGuildById(guildId); + if (ownerGuild == null) { + throw new RuntimeException("Owner Guild Not Found"); + } + return ownerGuild; } @Singleton