diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-07-07 01:22:04 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 17:22:04 +0200 |
commit | 5f4281f7d17a4b9e940f9d2d43ec1a4494744d30 (patch) | |
tree | bc92a38710e04ebcc23ead5e07ffd175579a573a /src/main/kotlin | |
parent | 0c94c8cf85824c2a8798a4c72d345738b1583388 (diff) | |
download | NotEnoughUpdates-5f4281f7d17a4b9e940f9d2d43ec1a4494744d30.tar.gz NotEnoughUpdates-5f4281f7d17a4b9e940f9d2d43ec1a4494744d30.tar.bz2 NotEnoughUpdates-5f4281f7d17a4b9e940f9d2d43ec1a4494744d30.zip |
Adding /neustats repo (#748)
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.") |