Skip to content

Commit defffb2

Browse files
authored
Merge pull request #11 from RickyBhatti/feat/permission-check
Resource name, permission, and version check
2 parents 95c021c + 07d3328 commit defffb2

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

fxmanifest.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ game "gta5"
44
name "DiscordAPI"
55
description "An all one in solution for Discord API, that controls chat tags, permissions."
66
author "ricky"
7-
version "v2.2.2"
7+
version "2.2.2"
88

99
lua54 "yes"
1010

@@ -15,6 +15,7 @@ client_scripts {
1515
server_scripts {
1616
"sv_config.lua",
1717
"sv_utility.lua",
18+
"sv_main.lua",
1819
"sv_discord_api.lua",
1920
"sv_ace_perms.lua",
2021
"sv_chat_tags.lua",

sv_main.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Citizen.CreateThread(function()
2+
local name = GetCurrentResourceName()
3+
local version = tostring(GetResourceMetadata(name, "version", 0))
4+
local principal = "resource." .. name
5+
6+
if name ~= "DiscordAPI" then
7+
Log("^1WARNING: The resource name is not DiscordAPI. Unless this is intentional, please change the resource name to DiscordAPI.")
8+
end
9+
10+
if not IsPrincipalAceAllowed(principal, "command.add_principal") then
11+
Log("^1WARNING: DiscordAPI is missing the 'command.add_principal' permission. The resource may not function as intended. Please grant this permission in the server.cfg.")
12+
end
13+
14+
if not IsPrincipalAceAllowed(principal, "command.add_ace") then
15+
Log("^1WARNING: DiscordAPI is missing the 'command.add_ace' permission. The resource may not function as intended. PPlease grant this permission in the server.cfg.")
16+
end
17+
18+
if not IsPrincipalAceAllowed(principal, "command.remove_principal") then
19+
Log("^1WARNING: DiscordAPI is missing the 'command.remove_principal' permission. The resource may not function as intended. Please grant this permission in the server.cfg.")
20+
end
21+
22+
if not IsPrincipalAceAllowed(principal, "command.remove_ace") then
23+
Log("^1WARNING: DiscordAPI is missing the 'command.remove_ace' permission. The resource may not function as intended. Please grant this permission in the server.cfg.")
24+
end
25+
26+
PerformHttpRequest("https://raw.githubusercontent.com/RickyBhatti/DiscordAPI/refs/heads/main/version.txt", function(code, text, _)
27+
if code ~= 200 then
28+
Log("^1WARNING: DiscordAPI was unable to check for updates. Please ensure you have an active internet connection.")
29+
return
30+
end
31+
32+
if version ~= tostring(text) then
33+
Log("^1WARNING: Your version of DiscordAPI doesn't match the latest version.")
34+
Log("^1WARNING: Your version: ^7" .. version)
35+
Log("^1WARNING: Latest version: ^7" .. text)
36+
end
37+
end)
38+
end)

0 commit comments

Comments
 (0)