Tommy’s Discord API
This tool easily allows for discord integration in scripts.
Why this API?
There are many resources that already serve a similar purpose, however, the methods in which these resources acquire discord information is not reliable. Discord Data Saver stores players discord ids and caches role information. No longer will your players have issues with discord permissions.
How do I use it?
Confiure the Guild ID & Bot Token in the config.lua
file and add the following to your resources fxmanifest.lua: dependency 'ddSaver'
Client Exports
exports.ddSaver:getRoles() -- Returns a table of roles ids
exports.ddSaver:getId() -- Returns the players discord id
exports.ddSaver:refreshData() -- Refreshes the players discord data
exports.ddSaver:hasRole("roleid") -- Returns true or false
Server Exports
exports.ddSaver:getRoles(source) -- Returns a table of roles ids
exports.ddSaver:getId(source) -- Returns the players discord id
exports.ddSaver:refreshData(source) -- Refreshes the players discord data
exports.ddSaver:hasRole(source, "roleid") -- Returns true or false
Examples:
client.lua
local leoRole = "909620367654543381"
if exports.ddSaver:hasRole(leoRole) then
print("omg you have the role")
end
RegisterCommand('permcheck', function(source)
exports.ddSaver:refreshData()
TriggerEvent("chatMessage", "Discord Permissions", {20, 20, 20}, "Permissions Updated.")
end, false)
server.lua
RegisterCommand('printRoles', function(source)
local roles = exports.ddSaver:getRoles(source)
if roles then
for role in pairs(roles) do
print("Role Found: " .. roles[role]
end
end
end, false)