will this work on the main thread?

This commit is contained in:
Braydon 2023-12-01 23:46:48 -05:00
parent 1eda57a7e3
commit 5c7c7e9f68
2 changed files with 32 additions and 30 deletions

@ -6,13 +6,13 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version> <version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>me.braydon</groupId> <groupId>me.braydon</groupId>
<artifactId>LicenseServer</artifactId> <artifactId>LicenseServer</artifactId>
<version>1.0.4</version> <version>1.0.5</version>
<description>A simple open-source licensing server for your products.</description> <description>A simple open-source licensing server for your products.</description>
<properties> <properties>

@ -153,34 +153,36 @@ public final class DiscordService {
return; return;
} }
// Initialize the bot // Initialize the bot
new Thread(() -> { long before = System.currentTimeMillis();
long before = System.currentTimeMillis(); log.info("Logging in..."); // Log that we're logging in
log.info("Logging in..."); // Log that we're logging in System.out.println("Step 1");
jda = JDABuilder.createDefault(token) jda = JDABuilder.createDefault(token)
.enableIntents( .enableIntents(
GatewayIntent.GUILD_MEMBERS GatewayIntent.GUILD_MEMBERS
).setStatus(OnlineStatus.DO_NOT_DISTURB) ).setStatus(OnlineStatus.DO_NOT_DISTURB)
.setActivity(Activity.watching("your licenses")) .setActivity(Activity.watching("your licenses"))
.addEventListeners(new EventHandler()) .addEventListeners(new EventHandler())
.build(); .build();
try { System.out.println("step 2");
jda.awaitReady(); // Await JDA to be ready try {
jda.awaitReady(); // Await JDA to be ready
// Log that we're logged in System.out.println("await complete");
log.info("Logged into {} in {}ms",
jda.getSelfUser().getEffectiveName(), System.currentTimeMillis() - before // Log that we're logged in
); log.info("Logged into {} in {}ms",
jda.getSelfUser().getEffectiveName(), System.currentTimeMillis() - before
// Registering slash commands );
jda.updateCommands().addCommands(
Commands.slash("license", "Manage one of your licenses") // Registering slash commands
.addOption(OptionType.STRING, "key", "The license key", true) jda.updateCommands().addCommands(
.addOption(OptionType.STRING, "product", "The product the license is for", true) Commands.slash("license", "Manage one of your licenses")
).queue(); .addOption(OptionType.STRING, "key", "The license key", true)
} catch (InterruptedException ex) { .addOption(OptionType.STRING, "product", "The product the license is for", true)
ex.printStackTrace(); ).queue();
} } catch (InterruptedException ex) {
}, "Discord Bot Thread").start(); ex.printStackTrace();
}
System.out.println("finish");
} }
/** /**