From 8b1c1b4d041d23ffc7a3260653a094dc01370197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 16 Jan 2023 00:41:45 +0100 Subject: [PATCH] Make repository URL a property --- src/main/java/wtf/beatrice/hidekobot/Cache.java | 10 ++++++++++ .../wtf/beatrice/hidekobot/commands/base/BotInfo.java | 5 +++-- src/main/resources/default.properties | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/Cache.java b/src/main/java/wtf/beatrice/hidekobot/Cache.java index c9ac207..f438f4f 100644 --- a/src/main/java/wtf/beatrice/hidekobot/Cache.java +++ b/src/main/java/wtf/beatrice/hidekobot/Cache.java @@ -218,6 +218,16 @@ public class Cache return propertiesSource.getProperty("bot.version"); } + /** + * Get the bot's source code URL. + * + * @return a String containing the base URL of the repository, including a trailing slash. + */ + public static String getRepositoryUrl() { + String url = propertiesSource.getProperty("repo.base_url"); + return url.endsWith("/") ? url : url + "/"; + } + /** * Get the bot's global color. * diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/base/BotInfo.java b/src/main/java/wtf/beatrice/hidekobot/commands/base/BotInfo.java index 651865d..d9eb74a 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/base/BotInfo.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/base/BotInfo.java @@ -105,9 +105,10 @@ public class BotInfo embedBuilder.addField("Uptime", FormatUtil.getNiceTimeDiff(Cache.getStartupTime()), true); // issue tracker field + + String link = "[Issue tracker](" + Cache.getRepositoryUrl() + "issues)"; embedBuilder.addField("Support", - "[Issue tracker](https://git.beatrice.wtf/bea/HidekoBot/issues)", - true); //todo: we should probably make this a final field in the config class + link, true); // bot birthday field embedBuilder.addField("Bot age", diff --git a/src/main/resources/default.properties b/src/main/resources/default.properties index f98ac11..c9d3851 100644 --- a/src/main/resources/default.properties +++ b/src/main/resources/default.properties @@ -1 +1,2 @@ -bot.version=${project.version} \ No newline at end of file +bot.version=${project.version} +repo.base_url=https://git.beatrice.wtf/bea/HidekoBot/ \ No newline at end of file