diff --git a/src/main/java/me/goudham/Application.java b/src/main/java/me/goudham/Application.java index 9f18ff21..346c4ff4 100644 --- a/src/main/java/me/goudham/Application.java +++ b/src/main/java/me/goudham/Application.java @@ -1,13 +1,13 @@ package me.goudham; import io.micronaut.context.ApplicationContext; -import me.goudham.bot.Enso; +import me.goudham.bot.EnsoBot; public class Application { - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { ApplicationContext applicationContext = ApplicationContext.run(); - Enso enso = applicationContext.getBean(Enso.class); - enso.startup(); + EnsoBot ensoBot = applicationContext.getBean(EnsoBot.class); + ensoBot.startup(); // GuildsRepository bean = run.getBean(GuildsRepository.class); // bean.saveOnConflictDoNothing(new Guilds(1234L, "to", null, 1)); diff --git a/src/main/java/me/goudham/bot/Bot.java b/src/main/java/me/goudham/bot/Bot.java index bf5ec922..2d53d038 100644 --- a/src/main/java/me/goudham/bot/Bot.java +++ b/src/main/java/me/goudham/bot/Bot.java @@ -1,5 +1,5 @@ package me.goudham.bot; public interface Bot { - void startup(); + void startup() throws InterruptedException; } diff --git a/src/main/java/me/goudham/bot/Enso.java b/src/main/java/me/goudham/bot/EnsoBot.java similarity index 65% rename from src/main/java/me/goudham/bot/Enso.java rename to src/main/java/me/goudham/bot/EnsoBot.java index 40bac509..f6e88fa4 100644 --- a/src/main/java/me/goudham/bot/Enso.java +++ b/src/main/java/me/goudham/bot/EnsoBot.java @@ -7,20 +7,21 @@ import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; @Singleton -public class Enso implements Bot { - private final JDA bot; +public class EnsoBot implements Bot { + private final JDA jda; private final Guild guild; private final CommandManager commandManager; @Inject - public Enso(JDA bot, Guild guild, CommandManager commandManager) { - this.bot = bot; + public EnsoBot(JDA jda, Guild guild, CommandManager commandManager) { + this.jda = jda; this.guild = guild; this.commandManager = commandManager; } @Override - public void startup() { + public void startup() throws InterruptedException { + jda.awaitReady(); commandManager.registerSlashCommands(guild); } } diff --git a/src/main/java/me/goudham/config/BotConfig.java b/src/main/java/me/goudham/config/BotConfig.java index 1a454fae..4dbaeff9 100644 --- a/src/main/java/me/goudham/config/BotConfig.java +++ b/src/main/java/me/goudham/config/BotConfig.java @@ -28,7 +28,7 @@ public class BotConfig { } @Singleton - public Guild guild(JDA jda) { + public Guild ownerGuild(JDA jda) { Guild ownerGuild = jda.getGuildById(guildId); if (ownerGuild == null) { throw new RuntimeException("Owner Guild Not Found"); @@ -37,7 +37,7 @@ public class BotConfig { } @Singleton - public JDA jda() throws LoginException, InterruptedException { + public JDA jda() throws LoginException { return JDABuilder .createDefault(token) .setActivity(Activity.playing("With Hamothy")) @@ -52,7 +52,6 @@ public class BotConfig { GatewayIntent.GUILD_MESSAGE_REACTIONS ) ).enableCache(CacheFlag.VOICE_STATE) - .build() - .awaitReady(); + .build(); } }