Version.VersionChecker(repoPath, tebex)

---Pass a github username and repo name to check for the latest version of the resource.
---
---
---Tebex is a optional boolean to determine if the message should be for a escrowed resource or not.
---
---
---Example Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge")
---@param repoPath string
---@param tebex boolean | nil
---@return nil
This commit is contained in:
MrNewb committed 2025-03-04 17:50:47 -05:00
1 parent 498433cd03
commit 7e9f0df74a
1 file changed
+12 -1
+12 -1
View File
@@ -1,6 +1,16 @@
Version = Version or {}
function Version.VersionChecker(repoPath)
---Pass a github username and repo name to check for the latest version of the resource.
---
---
---Tebex is a optional boolean to determine if the message should be for a escrowed resource or not.
---
---
---Example Version.VersionChecker("The-Order-Of-The-Sacred-Framework/community_bridge")
---@param repoPath string
---@param tebex boolean | nil
---@return nil
function Version.VersionChecker(repoPath, tebex)
local resource = repoPath:match("([^/]+)$")
if not resource then return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0') end
@@ -28,6 +38,7 @@ function Version.VersionChecker(repoPath)
local currentVersion, latestVersion = version:gsub('%D', ''), latest:gsub('%D', '')
if currentVersion < latestVersion then
if tebex then return print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from the portal/keymaster.^7\r\n%s'):format(resource, version, "https://portal.cfx.re/assets/granted-assets")) end
return print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from the GitHub release page.^7\r\n%s'):format(resource, version, response.html_url))
end
end, 'GET')