From 9a96248e708b44fd9ce8159a6877bd1626777814 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Fri, 24 Dec 2021 22:46:23 +0100 Subject: [PATCH] Update discord.lua Removed parts that aren't used and commented out that print that fills the server console. (keeping them commented incase anyone needs to test something) --- ND_Core/source/server/discord.lua | 46 ++++++------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/ND_Core/source/server/discord.lua b/ND_Core/source/server/discord.lua index fd93569..6eafb5f 100644 --- a/ND_Core/source/server/discord.lua +++ b/ND_Core/source/server/discord.lua @@ -1,4 +1,4 @@ --- original discord roles author: https://forum.cfx.re/t/discord-roles-for-permissions-im-creative-i-know/233805?u=andyyy7666 +-- This is a edited version of discord-roles, original discord-roles resource: https://forum.cfx.re/t/discord-roles-for-permissions-im-creative-i-know/233805?u=andyyy7666 local FormattedToken = "Bot "..config.DiscordToken function DiscordRequest(method, endpoint, jsondata) @@ -14,42 +14,12 @@ function DiscordRequest(method, endpoint, jsondata) return data end - --[[ we don't use this in this resource. -function GetRoles(user) - local discordId = nil - for _, id in ipairs(GetPlayerIdentifiers(user)) do - if string.match(id, "discord:") then - discordId = string.gsub(id, "discord:", "") - print("Found discord id: "..discordId) - break - end - end - - if discordId then - local endpoint = ("guilds/%s/members/%s"):format(config.GuildId, discordId) - local member = DiscordRequest("GET", endpoint, {}) - if member.code == 200 then - local data = json.decode(member.data) - local roles = data.roles - local found = true - return roles - else - print("Error occurred, maybe they are not in discord?") - return false - end - else - print("missing identifier") - return false - end -end -]] - function IsRolePresent(user, role) local discordId = nil for _, id in ipairs(GetPlayerIdentifiers(user)) do if string.match(id, "discord:") then discordId = string.gsub(id, "discord:", "") - print("Found discord id: "..discordId) + --print("Found discord id: "..discordId) break end end @@ -62,7 +32,7 @@ function IsRolePresent(user, role) end if theRole == "0" then - print("Role Given (0 in config)") + --print("Role Given (0 in config)") return true elseif discordId then local endpoint = ("guilds/%s/members/%s"):format(config.GuildId, discordId) @@ -73,18 +43,18 @@ function IsRolePresent(user, role) local found = true for i=1, #roles do if roles[i] == theRole then - print("Found role") + --print("Found role") return true end end - print("Not found!") + --print("Not found!") return false else - print("Error occurred, maybe they are not in discord?") + --print("Error occurred, maybe they are not in discord?") return false end else - print("missing identifier") + --print("missing identifier") return false end end @@ -97,4 +67,4 @@ Citizen.CreateThread(function() else print("An error occured, please check your config and ensure everything is correct. Error: "..(guild.data or guild.code)) end -end) \ No newline at end of file +end)