Load in owner guild

java-rewrite
Hammy 3 years ago
parent 68b65fce4f
commit e6adabc46d

@ -5,14 +5,12 @@ import io.micronaut.context.annotation.Value;
import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Introspected;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Singleton; import jakarta.inject.Singleton;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import me.goudham.command.ICommand;
import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity; 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.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.cache.CacheFlag; import net.dv8tion.jda.api.utils.cache.CacheFlag;
@ -20,15 +18,22 @@ import net.dv8tion.jda.api.utils.cache.CacheFlag;
@Introspected @Introspected
public class BotConfig { public class BotConfig {
private final String token; private final String token;
private final String guildId;
@Inject @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.token = token;
this.guildId = guildId;
} }
@Singleton @Singleton
Map<String, List<ICommand>> commandsMap() { public Guild guild(JDA jda) {
return Collections.emptyMap(); Guild ownerGuild = jda.getGuildById(guildId);
if (ownerGuild == null) {
throw new RuntimeException("Owner Guild Not Found");
}
return ownerGuild;
} }
@Singleton @Singleton

Loading…
Cancel
Save