Tommy's Scripts
  • Information
    • FiveM Escrow System
  • Paid Scripts
    • Tommy's ELS
    • Tommy's Radar Detector
    • Tommy's POV
    • Tommy's Radio
    • Tommy's HUD (Legacy V1)
    • Custom Unit Number
    • GTA:O Loading Screen
  • Free Scripts
    • Tommy's Lights Sync
    • Tommy's Discord API
    • Priority Status
Powered by GitBook
On this page
  • Why this API?
  • How do I use it?
  • Examples
  1. Free Scripts

Tommy's Discord API

Configuration guide, common issues & solutions, code snippets, and more.

Last updated 9 months ago

|

Escrow Encrypted: Yes

Requirements: None

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?

  1. Configure the Guild ID & Bot Token in the config.lua file.

  2. Add the following to your resources fxmanifest.lua:

dependency 'ddSaver'

Client Exports

luaCopy codeexports.ddSaver:getRoles() -- Returns a table of role IDs
exports.ddSaver:getId() -- Returns the player's discord ID
exports.ddSaver:refreshData() -- Refreshes the player's discord data
exports.ddSaver:hasRole("roleid") -- Returns true or false

Server Exports

luaCopy codeexports.ddSaver:getRoles(source) -- Returns a table of role IDs
exports.ddSaver:getId(source) -- Returns the player's discord ID
exports.ddSaver:refreshData(source) -- Refreshes the player's discord data
exports.ddSaver:hasRole(source, "roleid") -- Returns true or false

Examples

client.lua

luaCopy codelocal 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

luaCopy codeRegisterCommand('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)
FiveM Post
Store Page
Page cover image