diff options
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/NEUStatsCommand.kt | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/NEUStatsCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/NEUStatsCommand.kt index 2bc8ae6f..e17e856c 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/NEUStatsCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/NEUStatsCommand.kt @@ -61,10 +61,19 @@ class NEUStatsCommand { .toString() ) }.withHelp("Copy the mod list to your clipboard") + thenLiteralExecute("repo") { + clipboardAndSendMessage( + DiscordMarkdownBuilder() + .also(::appendRepoStats) + .also(::appendAdvancedRepoStats) + .toString() + ) + }.withHelp("Copy the repo stats to your clipboard") thenLiteralExecute("full") { clipboardAndSendMessage( DiscordMarkdownBuilder() .also(::appendStats) + .also(::appendAdvancedRepoStats) .also(::appendModList) .toString() ) @@ -166,9 +175,7 @@ class NEUStatsCommand { ) builder.append("SB Profile", SBInfo.getInstance().currentProfile) builder.append("Has Advanced Tab", if (SBInfo.getInstance().hasNewTab) "TRUE" else "FALSE") - builder.category("Repo Stats") - builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit) - builder.append("Loaded Items", NotEnoughUpdates.INSTANCE.manager.itemInformation.size.toString()) + .also(::appendRepoStats) } private fun appendModList(builder: DiscordMarkdownBuilder): DiscordMarkdownBuilder { @@ -179,6 +186,40 @@ class NEUStatsCommand { return builder } + private fun appendRepoStats(builder: DiscordMarkdownBuilder): DiscordMarkdownBuilder { + val apiData = NotEnoughUpdates.INSTANCE.config.apiData + if (apiData.repoUser == "" || apiData.repoName == "" || apiData.repoBranch == "") { + NotEnoughUpdates.INSTANCE.config.executeRunnable(23) + NotEnoughUpdates.INSTANCE.config.executeRunnable(22) + builder.append("", "") + builder.category("Reset Repository location") + builder.append("", "") + } else { + builder.category("Repo Stats") + builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit) + builder.append("Loaded Items", NotEnoughUpdates.INSTANCE.manager.itemInformation.size.toString()) + builder.append("Repo Location", "https://github.com/${apiData.repoUser}/${apiData.repoName}/tree/${apiData.repoBranch}") + } + return builder + } + + private fun appendAdvancedRepoStats(builder: DiscordMarkdownBuilder): DiscordMarkdownBuilder { + if (NotEnoughUpdates.INSTANCE.manager.repoLocation.isDirectory) { + val files = NotEnoughUpdates.INSTANCE.manager.repoLocation.listFiles() + builder.category("Repo Files") + files?.forEach { file -> + if (file.isDirectory) { + builder.append(file.name, file.listFiles()?.size) + } else if (file.isFile) { + builder.append("", file.name) + } + } + } else { + builder.category("Repo folder not found!") + } + return builder + } + fun CommandContext<ICommandSender>.clipboardAndSendMessage(data: String?) { if (data == null) { reply("${DARK_RED}Error occurred trying to perform command.") |