Refactor DiscordBotInstance to initialize JDA lazily and standardize "Discord ID" terminology in appeal form.

This commit is contained in:
akastijn 2025-11-23 03:34:20 +01:00
parent 7d59885395
commit af9e1e627f
2 changed files with 21 additions and 5 deletions

View File

@ -17,10 +17,26 @@ public class DiscordBotInstance {
private DiscordBotInstance() {}
@Getter
private JDA jda;
private volatile boolean ready = false;
public JDA getJda() {
if (jda == null) {
String discordToken = System.getProperty("DISCORD_TOKEN");
if (discordToken == null) {
log.error("Discord token not found, put it in the DISCORD_TOKEN environment variable");
System.exit(1);
}
start(discordToken);
try {
jda.awaitReady();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
return jda;
}
public synchronized void start(String token) {
if (jda != null) {
return;

View File

@ -41,15 +41,15 @@
@if (currentPageIndex === 2) {
<section class="formPage">
<div class="description">
<p>Please enter your discord id below.</p>
<p>You can find your discord id by going to User settings -> Advanced -> Developer Mode and turning it
<p>Please enter your Discord ID below.</p>
<p>You can find your Discord ID by going to User settings -> Advanced -> Developer Mode and turning it
on</p>
<p>With Developer Mode on in Discord click your profile in the bottom left and click Copy User Id</p>
<p>With Developer Mode on in Discord click your profile in the bottom left and click Copy User ID</p>
<p>We use this to find your punishment on our Discord server.</p>
</div>
<mat-form-field appearance="fill">
<mat-label>Discord Id</mat-label>
<input matInput placeholder="Discord Id" [(ngModel)]="discordId"
<input matInput placeholder="Discord ID" [(ngModel)]="discordId"
maxlength="17" minlength="18" pattern="^[0-9]+$">
</mat-form-field>
<button mat-raised-button (click)="checkPunishment()" [disabled]="authService.username() == null">