From 7b7999cc76f91bf1c2c347603292db48b60453bb Mon Sep 17 00:00:00 2001 From: Musiker15 Date: Fri, 17 Mar 2023 12:41:20 +0100 Subject: [PATCH] Update v1.1 * Fixed if fields = false --- VERSION | 2 +- fxmanifest.lua | 2 +- server.lua | 73 +++++++++++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/VERSION b/VERSION index 9f8e9b6..b123147 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0 \ No newline at end of file +1.1 \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 72c0e48..1618648 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ games { 'gta5' } author 'Musiker15 - MSK Scripts' name 'msk_webhook' description 'Send Discord Webhooks' -version '1.0' +version '1.1' lua54 'yes' diff --git a/server.lua b/server.lua index 73b912c..40c3286 100644 --- a/server.lua +++ b/server.lua @@ -14,6 +14,8 @@ if Config.testCommand.enable then end exports('sendDiscordLog', function(webhook, botColor, botName, botAvatar, title, description, fields, footer, time) + local content = {} + if footer then if time then footer = { @@ -28,13 +30,22 @@ exports('sendDiscordLog', function(webhook, botColor, botName, botAvatar, title, end end - local content = {{ - ["title"] = title, - ["description"] = description, - ["color"] = botColor, - ["fields"] = fields, - ["footer"] = footer - }} + if fields then + content = {{ + ["title"] = title, + ["description"] = description, + ["color"] = botColor, + ["fields"] = fields, + ["footer"] = footer + }} + else + content = {{ + ["title"] = title, + ["description"] = description, + ["color"] = botColor, + ["footer"] = footer + }} + end PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({ username = botName, @@ -45,27 +56,29 @@ exports('sendDiscordLog', function(webhook, botColor, botName, botAvatar, title, }) end) ----- GitHub Updater ---- -function GetCurrentVersion() - return GetResourceMetadata( GetCurrentResourceName(), "version" ) -end - -local CurrentVersion = GetCurrentVersion() -local resourceName = "^4["..GetCurrentResourceName().."]^0" +GithubUpdater = function() + GetCurrentVersion = function() + return GetResourceMetadata( GetCurrentResourceName(), "version" ) + end + + local CurrentVersion = GetCurrentVersion() + local resourceName = "^4["..GetCurrentResourceName().."]^0" -if Config.VersionChecker then - PerformHttpRequest('https://raw.githubusercontent.com/MSK-Scripts/msk_webhook/main/VERSION', function(Error, NewestVersion, Header) - print("###############################") - if CurrentVersion == NewestVersion then - print(resourceName .. '^2 ✓ Resource is Up to Date^0 - ^5Current Version: ^2' .. CurrentVersion .. '^0') - elseif CurrentVersion ~= NewestVersion then - print(resourceName .. '^1 ✗ Resource Outdated. Please Update!^0 - ^5Current Version: ^1' .. CurrentVersion .. '^0') - print('^5Newest Version: ^2' .. NewestVersion .. '^0 - ^6Download here: ^9https://github.com/MSK-Scripts/msk_webhook/releases/tag/v'.. NewestVersion .. '^0') - end - print("###############################") - end) -else - print("###############################") - print(resourceName .. '^2 ✓ Resource loaded^0') - print("###############################") -end \ No newline at end of file + if Config.VersionChecker then + PerformHttpRequest('https://raw.githubusercontent.com/MSK-Scripts/msk_webhook/main/VERSION', function(Error, NewestVersion, Header) + print("###############################") + if CurrentVersion == NewestVersion then + print(resourceName .. '^2 ✓ Resource is Up to Date^0 - ^5Current Version: ^2' .. CurrentVersion .. '^0') + elseif CurrentVersion ~= NewestVersion then + print(resourceName .. '^1 ✗ Resource Outdated. Please Update!^0 - ^5Current Version: ^1' .. CurrentVersion .. '^0') + print('^5Newest Version: ^2' .. NewestVersion .. '^0 - ^6Download here:^9 https://github.com/MSK-Scripts/msk_webhook/releases/tag/v'.. NewestVersion .. '^0') + end + print("###############################") + end) + else + print("###############################") + print(resourceName .. '^2 ✓ Resource loaded^0') + print("###############################") + end +end +GithubUpdater() \ No newline at end of file