Tommy's Discord API (tool for devs)

Tommy’s Discord API :izakaya_lantern:

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)

Comp 2_00001
Comp 2_00002

1 Like

There are other resources using the discord API. Why pay for something that developers have to integrate with?

3 Likes

0.01€

so you are encrypting and charging for a simple discord api wrapper. lame.

If you read the post, it’s more than a “simple discord api wrapper”. It’s out here for the people that want it. Thanks for the feedback. :+1:

This resource solves the #1 problem in all the other current resources using the discord API. It’s something I created to solve these problems in my server, and I decided to share it since I haven’t seen it anywhere else.

Difference between Badger api and this?

Discord Data Saver caches and stores players discord ids and allows for refreshing player data on the fly. The #1 problem this solves is that now you will still have access to a player’s discord data even if FiveM does not provide their discord id (no more issues with telling players to restart their game with discord open). And the script is extremely lightweight on the discord api to avoid rate limiting.

@DaBestServerOwner I can’t contact you anywhere

I’ve sent you a pm. :+1:

1 Like