I’m currently using the Discord command /approved @member, which allows me to approve a player directly from Discord and automatically add them to the txAdmin allowlist.
I’m also developing a website with Discord authentication where players submit their whitelist applications.
I would like to reproduce the same behavior directly from the website:
Whitelist accepted on the website → automatically approve the player’s Discord ID in txAdmin → player can connect to the server.
Is there an official API, event, function, or other supported method in txAdmin that would allow an external application to do the same thing as the /approved command?
Ideally, I would also like to be able to revoke a player’s approval automatically from the website if their whitelist is removed or revoked.
I’m looking for a supported solution rather than directly modifying txAdmin’s JSON database.
There’s no official txAdmin API for this — and worth flagging, since you specifically asked for a supported solution: both of those repos drive txAdmin’s internal web endpoints with a stored admin session. That’s the same category as editing the JSON directly, just one layer further away. No contract, breaks whenever those routes change, and your website ends up holding live admin credentials for your panel.
The supported route is to not use txAdmin’s allowlist at all. playerConnecting and deferrals are first-party documented API, and your website already has the source of truth. Set txAdmin’s allowlist to Disabled first, or the two will fight over the same connection.
AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
local src = source
deferrals.defer()
Wait(0) -- required: at least one tick after defer()
deferrals.update('Checking your whitelist application...')
local ident = GetPlayerIdentifierByType(src, 'discord')
if not ident then
return deferrals.done('Link your Discord to FiveM, then reconnect.')
end
local row = MySQL.single.await(
'SELECT status FROM whitelist_applications WHERE discord_id = ?',
{ (ident:gsub('discord:', '')) })
Wait(0)
if row and row.status == 'approved' then
deferrals.done()
else
deferrals.done('Your application is not approved yet.')
end
end)
That’s oxmysql syntax for the query — swap in whatever your server uses.
Approving is then just your site writing status = 'approved'. And revoking — your second question — is an UPDATE plus a DropPlayer if they’re online, with no round trip to the game server at all. That part is actually harder through txAdmin.
Two things that catch people out: GetPlayerIdentifierByType returns nil if the player hasn’t linked Discord to their Cfx account, so handle that branch explicitly or it silently falls through to reject. And you must wait a tick after defer() before done() — the docs are explicit — otherwise you get intermittent rejections with no message.