diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9606a4f..60d2baf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,14 +37,14 @@ jobs: distribution: 'temurin' - name: Build with Gradle and generate dependency Graph - if: ${{github.ref == 'refs/heads/main' && github.event_name != 'pull_request'}} + if: ${{github.ref == 'refs/heads/version/1.20.1' && github.event_name != 'pull_request'}} uses: gradle/gradle-build-action@v2 with: arguments: build dependency-graph: 'generate-and-submit' - name: Build with Gradle - if: ${{github.ref != 'refs/heads/main' || github.event_name == 'pull_request'}} + if: ${{github.ref != 'refs/heads/version/1.20.1' || github.event_name == 'pull_request'}} uses: gradle/gradle-build-action@v2 with: arguments: build diff --git a/Changelog.md b/Changelog.md index 4f1f34a..3fef427 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +# 1.2.1 +Allow providing token via config + # 1.2.0 - Unlink other Discord users with permissions - Customizable text for basically anything diff --git a/common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt b/common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt index 08dea35..8c38944 100644 --- a/common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt +++ b/common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt @@ -110,15 +110,17 @@ fun startAstralbot(server: MinecraftServer) { LOGGER.debug("Created $MODID directory") } - if (!env.containsKey("DISCORD_TOKEN")) { - LOGGER.warn("Not starting AstralBot because of missing DISCORD_TOKEN environment variable.") + val token: String? = env["DISCORD_TOKEN"] ?: AstralBotConfig.DISCORD_TOKEN.get() + + if (token == null || token == "") { + LOGGER.warn("Not starting AstralBot because no token was not provided") return } minecraftHandler = MinecraftHandler(server) jda = JDABuilder.createLight( - env["DISCORD_TOKEN"], + token, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MEMBERS diff --git a/common/src/main/kotlin/dev/erdragh/astralbot/config/AstralBotConfig.kt b/common/src/main/kotlin/dev/erdragh/astralbot/config/AstralBotConfig.kt index 63baa6f..6b58514 100644 --- a/common/src/main/kotlin/dev/erdragh/astralbot/config/AstralBotConfig.kt +++ b/common/src/main/kotlin/dev/erdragh/astralbot/config/AstralBotConfig.kt @@ -14,6 +14,12 @@ import java.net.URL object AstralBotConfig { val SPEC: ForgeConfigSpec + /** + * If the `DISCORD_TOKEN` environment variable isn't set, the bot will + * look for a token in this config option. + */ + val DISCORD_TOKEN: ForgeConfigSpec.ConfigValue + /** * Whether the default whitelisting process is respected or ignored. * Setting this to `true` will *force* every user who wants to join @@ -80,6 +86,9 @@ object AstralBotConfig { builder.comment("AstralBot Config") + DISCORD_TOKEN = builder.comment("Discord token for the bot. Can also be supplied via DISCORD_TOKEN environment variable") + .define("token", "") + REQUIRE_LINK_FOR_WHITELIST = builder.comment("Whether to require being linked to be whitelisted") .define("requireLinkForWhitelist", false) DISCORD_LINK = builder.comment("Link to the discord where your users can run the /link command") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index f6c1972..4bda19b 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,2 +1,2 @@ fabricApiVersion=0.77.0 -fabricKotlinVersion=1.10.17+kotlin.1.9.22 \ No newline at end of file +fabricKotlinVersion=1.10.19+kotlin.1.9.23 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c3507dd..0f924d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx3G # Minecraft things enabledPlatforms=fabric,forge # Specified here because it's used in both the fabric and common subproject -fabricLoaderVersion=0.15.6 +fabricLoaderVersion=0.15.7 -version=1.2.0 +version=1.2.1 group=dev.erdragh.astralbot minecraftVersion=1.18.2 @@ -16,8 +16,8 @@ forgeConfigAPIVersion=3.2.4 nightConfig=3.6.5 # Discord Interactions -jdaVersion=5.0.0-beta.20 +jdaVersion=5.0.0-beta.21 # Database Interactions -exposedVersion=0.47.0 +exposedVersion=0.48.0 sqliteJDBCVersion=3.44.1.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e846b64..a8382d7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 7b6a20d..55b0a42 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,7 +13,7 @@ pluginManagement { } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } include("common")