Skip to content

Commit

Permalink
Write a default configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Aug 19, 2024
1 parent 827f786 commit ff3eaea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CamelotConfig {
}

void validate() {
if (!token) {
if (!token || token == '<insert bot api token here>') {
throw new IllegalArgumentException('Bot API Token must be provided!')
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/neoforged/camelot/BotMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ private static void loadConfig(Path config) {
}

LOGGER.warn("Migration complete. Please fix TODOs and check that the configuration is correct before restarting the bot.");
} else {
try {
Files.writeString(config, """
import net.neoforged.camelot.config.module.*
// Default Camelot configuration
// Please configure at least the API token for the bot to start.
// For more information, visit the documentation
camelot {
token = secret('<insert bot api token here>')
prefix = '!'
}""");
LOGGER.warn("Created default config. Please configure it according to the documentation.");
} catch (IOException e) {
LOGGER.error("Failed to create default config", e);
}
}

System.exit(1);
Expand Down

0 comments on commit ff3eaea

Please sign in to comment.