diff --git a/build.gradle b/build.gradle index 6cbd478..931c4f2 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,26 @@ tasks.register('run', JavaExec).configure { }) } +abstract class Log extends DefaultTask { + @OutputFile + abstract RegularFileProperty getOutput() + + Log() { + outputs.upToDateWhen { false } + } + + @TaskAction + void exec() { + new ProcessBuilder('git', 'log', '-5', '--pretty=oneline') + .redirectOutput(getOutput().asFile.get()) + .start().waitFor() + } +} + +tasks.register('gitLog', Log) { + it.output.set(new File(project.buildDir, 'gitlog')) +} + java.toolchain.languageVersion = JavaLanguageVersion.of(21) java.toolchain.vendor = JvmVendorSpec.GRAAL_VM @@ -151,6 +171,8 @@ shadowJar { mergeServiceFiles() archiveClassifier = 'all' archiveFile.set(project.file("$buildDir/libs/camelot-all.jar")) + dependsOn(tasks.gitLog) + from(tasks.gitLog.output) } publishing { diff --git a/src/main/java/net/neoforged/camelot/commands/information/HelpCommand.java b/src/main/java/net/neoforged/camelot/commands/information/HelpCommand.java index d700015..16bad23 100644 --- a/src/main/java/net/neoforged/camelot/commands/information/HelpCommand.java +++ b/src/main/java/net/neoforged/camelot/commands/information/HelpCommand.java @@ -22,7 +22,7 @@ public HelpCommand(ButtonManager buttonManager) { super(buttonManager); this.name = "help"; this.help = "Show information about the bot's commands"; - this.itemsPerPage = 25; + this.itemsPerPage = 15; } @Override @@ -45,7 +45,20 @@ public CompletableFuture createMessage(int page, SimpleData dat public EmbedBuilder getHelpStartingAt(int index) { EmbedBuilder embed = new EmbedBuilder(); embed.setAuthor(Common.NAME_WITH_VERSION, Common.REPO, BotMain.get().getSelfUser().getAvatarUrl()); - embed.setDescription("All registered commands:"); + embed.setDescription("## Latest commits:\n"); + + appendCommits: try (var is = HelpCommand.class.getResourceAsStream("/gitlog")) { + if (is == null) break appendCommits; + var lines = new String(is.readAllBytes()).split("\n"); + for (String line : lines) { + var split = line.split(" ", 2); + embed.appendDescription(STR."- [\{split[1]}](\{Common.REPO}/commit/\{split[0]})\n"); + } + } catch (Exception ex) { + embed.appendDescription("Failed to read git log.\n"); + } + + embed.appendDescription("\n## Registered commands:"); List commandList = Commands.get().getCommands(); commandList.addAll(Commands.get().getSlashCommands());