From 3146ed7d6d02415f10a863d8bb8da48d6049b737 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 1 Jul 2024 22:56:52 +0100 Subject: [PATCH] fix dev commands --- src/main/java/cc/fascinated/bat/Consts.java | 7 ------- .../java/cc/fascinated/bat/config/Config.java | 17 +++++++++++++++++ .../fascinated/bat/service/CommandService.java | 2 +- src/main/resources/application.yml | 4 ++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/Consts.java b/src/main/java/cc/fascinated/bat/Consts.java index bc11684..4fd9722 100644 --- a/src/main/java/cc/fascinated/bat/Consts.java +++ b/src/main/java/cc/fascinated/bat/Consts.java @@ -7,11 +7,4 @@ public class Consts { public static final String INVITE_URL = "https://discord.com/oauth2/authorize?client_id=1254161119975833652&permissions=8&integration_type=0&scope=bot+applications.commands"; public static final String SUPPORT_INVITE_URL = "https://discord.gg/invite/yjj2U3ctEG"; public static String BOT_OWNER = "474221560031608833"; - public static String ADMIN_GUILD = "1203163422498361404"; - - static { - if (System.getenv("ADMIN_GUILD") != null) { - ADMIN_GUILD = System.getenv("ADMIN_GUILD"); - } - } } diff --git a/src/main/java/cc/fascinated/bat/config/Config.java b/src/main/java/cc/fascinated/bat/config/Config.java index 123e935..708b4bc 100644 --- a/src/main/java/cc/fascinated/bat/config/Config.java +++ b/src/main/java/cc/fascinated/bat/config/Config.java @@ -1,20 +1,37 @@ package cc.fascinated.bat.config; import lombok.Getter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; /** * @author Fascinated (fascinated7) */ +@Component @Getter public class Config { + public static Config INSTANCE; + /** * Is the app running in a production environment? */ @Getter private static final boolean production; + /** + * The ID of the admin guild + */ + private final String adminGuild; + static { // Are we running on production? String appEnv = System.getenv("APP_ENV"); production = appEnv != null && (appEnv.equals("production")); } + + @Autowired + public Config(@Value("${bat.admin-guild}") String adminGuild) { + INSTANCE = this; + this.adminGuild = adminGuild; + } } diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index def6e05..a7f4f46 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -75,7 +75,7 @@ public class CommandService extends ListenerAdapter { JDA jda = DiscordService.JDA; long before = System.currentTimeMillis(); - Guild adminGuild = jda.getGuildById(Consts.ADMIN_GUILD); + Guild adminGuild = jda.getGuildById(Config.INSTANCE.getAdminGuild()); if (!Config.isProduction()) { if (adminGuild == null) { log.error("Unable to find the admin guild to register commands"); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aacd46b..62814af 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -2,6 +2,10 @@ discord: token: "oh my goodnesssssssssss" +# Bat Configuration +bat: + admin-guild: 1203163422498361404 + # Sentry Configuration sentry: dsn: "CHANGE_ME"