Lua based Discord API for FiveM development environment.
Note: This is a server-side script, use events for any client interactions.
Note: This script is under development and not fully functional, star and watch the repo for updates.
Download Link
ox_lib is required.
For initializing two variables need to be set in server.cfg.
discord_bot_tokenfound in discord's developers portal.discord_server_idfor the main server, finding guide.
Example:
set discord_bot_token "XYZ123XYZ123XYZ123XYZ123.AB1C2D.XYZ1234_XYZ123XYZ123XYZ1_XYZ123XYZ1234"
set discord_server_id "000000000000000000"To be able to use the API you have to load a file in your script manifest.
server_script '@discord_api/init.lua'Check some examples.
There is a built-in Alive/Dead API switch which takes place when discord_api resource is not started, the bot reached it's limit, etc...
What it does is pretty simple, just redefines some functions that we choose to be empty (dead) ones, so that we get empty results without have to go through a request that (we know for sure) will fail.
When the API is ready (discord_api resource is started again), it will automatically redefine those function to the Alive version again.
Check this live example.
- Handle rate limit.
- Install Sumneko Lua Language Server on Visual Studio Code.
- Check
diagnostic.meta.luafor definitions.