Rename Enso to EnsoBot

java-rewrite
Hammy 3 years ago
parent e78f080e18
commit 64610061c0

@ -1,13 +1,13 @@
package me.goudham; package me.goudham;
import io.micronaut.context.ApplicationContext; import io.micronaut.context.ApplicationContext;
import me.goudham.bot.Enso; import me.goudham.bot.EnsoBot;
public class Application { public class Application {
public static void main(String[] args) { public static void main(String[] args) throws InterruptedException {
ApplicationContext applicationContext = ApplicationContext.run(); ApplicationContext applicationContext = ApplicationContext.run();
Enso enso = applicationContext.getBean(Enso.class); EnsoBot ensoBot = applicationContext.getBean(EnsoBot.class);
enso.startup(); ensoBot.startup();
// GuildsRepository bean = run.getBean(GuildsRepository.class); // GuildsRepository bean = run.getBean(GuildsRepository.class);
// bean.saveOnConflictDoNothing(new Guilds(1234L, "to", null, 1)); // bean.saveOnConflictDoNothing(new Guilds(1234L, "to", null, 1));

@ -1,5 +1,5 @@
package me.goudham.bot; package me.goudham.bot;
public interface Bot { public interface Bot {
void startup(); void startup() throws InterruptedException;
} }

@ -7,20 +7,21 @@ import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
@Singleton @Singleton
public class Enso implements Bot { public class EnsoBot implements Bot {
private final JDA bot; private final JDA jda;
private final Guild guild; private final Guild guild;
private final CommandManager commandManager; private final CommandManager commandManager;
@Inject @Inject
public Enso(JDA bot, Guild guild, CommandManager commandManager) { public EnsoBot(JDA jda, Guild guild, CommandManager commandManager) {
this.bot = bot; this.jda = jda;
this.guild = guild; this.guild = guild;
this.commandManager = commandManager; this.commandManager = commandManager;
} }
@Override @Override
public void startup() { public void startup() throws InterruptedException {
jda.awaitReady();
commandManager.registerSlashCommands(guild); commandManager.registerSlashCommands(guild);
} }
} }

@ -28,7 +28,7 @@ public class BotConfig {
} }
@Singleton @Singleton
public Guild guild(JDA jda) { public Guild ownerGuild(JDA jda) {
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,7 +37,7 @@ public class BotConfig {
} }
@Singleton @Singleton
public JDA jda() throws LoginException, InterruptedException { public JDA jda() throws LoginException {
return JDABuilder return JDABuilder
.createDefault(token) .createDefault(token)
.setActivity(Activity.playing("With Hamothy")) .setActivity(Activity.playing("With Hamothy"))
@ -52,7 +52,6 @@ public class BotConfig {
GatewayIntent.GUILD_MESSAGE_REACTIONS GatewayIntent.GUILD_MESSAGE_REACTIONS
) )
).enableCache(CacheFlag.VOICE_STATE) ).enableCache(CacheFlag.VOICE_STATE)
.build() .build();
.awaitReady();
} }
} }

Loading…
Cancel
Save