修复安装systemd服务且未提供Discord令牌时出现的空指针

This commit is contained in:
TheWhiteDog9487
2026-07-30 17:08:42 +08:00
parent 737e2a5def
commit 0d87eede70
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ plugins {
} }
group = "xyz.thewhitedog9487" group = "xyz.thewhitedog9487"
version = "0.8.1" version = "0.8.2"
java { java {
toolchain { toolchain {
@@ -21,7 +21,7 @@ class OpenApiConfiguration {
.contact(Contact() .contact(Contact()
.name("TheWhiteDog9487") .name("TheWhiteDog9487")
.url("https://www.github.com/TheWhiteDog9487/WebAPI")) .url("https://www.github.com/TheWhiteDog9487/WebAPI"))
.version("0.8.1") .version("0.8.2")
.license(License() .license(License()
.name("WTFPL") .name("WTFPL")
.url("https://spdx.org/licenses/WTFPL")) ) .url("https://spdx.org/licenses/WTFPL")) )
@@ -63,7 +63,7 @@ fun ProcessArguments(CommandLineArguments: Array<String>) {
val DiscordBotToken = if ("--Discord_Bot_Token" in CommandLineArguments && val DiscordBotToken = if ("--Discord_Bot_Token" in CommandLineArguments &&
CommandLineArguments.getOrNull(CommandLineArguments.indexOf("--Discord_Bot_Token") + 1) != null ){ CommandLineArguments.getOrNull(CommandLineArguments.indexOf("--Discord_Bot_Token") + 1) != null ){
CommandLineArguments[CommandLineArguments.indexOf("--Discord_Bot_Token") + 1] } CommandLineArguments[CommandLineArguments.indexOf("--Discord_Bot_Token") + 1] }
else System.getenv("Discord_Bot_Token") else System.getenv().getOrDefault("Discord_Bot_Token", "")
if (DiscordBotToken.isEmpty()) { if (DiscordBotToken.isEmpty()) {
Logger.error { "必须通过--Discord_Bot_Token参数或Discord_Bot_Token环境变量提供Discord机器人的令牌以使本程序正常工作。" } Logger.error { "必须通过--Discord_Bot_Token参数或Discord_Bot_Token环境变量提供Discord机器人的令牌以使本程序正常工作。" }
throw IllegalArgumentException("缺少必须的--Discord_Bot_Token参数") } throw IllegalArgumentException("缺少必须的--Discord_Bot_Token参数") }