FiveM Discord Integration: Roles, Bots & Webhooks Guide
Learn how to integrate Discord with your FiveM server using role-based whitelists, OAuth access gates, webhook logging, Rich Presence, and automated announcements for your community.
On this page
For the vast majority of FiveM communities, Discord is where everything happens — applications, staff coordination, ban appeals, announcements, and customer support. But Discord's role in your server stack can go far beyond a community chat hub. With the right integrations, Discord becomes your access control layer, your audit log pipeline, your storefront gating system, and your player engagement tool.
This guide covers the four major integration patterns: role-based whitelist and access control via Discord OAuth, webhook-based logging, Discord Rich Presence for discoverability, and automated announcements. Each section explains how it works, why it matters, and what you need to implement it.
Integration Types at a Glance
| Integration Type | What It Does | Requires |
|---|---|---|
| Role-based whitelist | Blocks non-members or non-role holders from connecting | Discord bot + server-side Lua check |
| OAuth-gated web/download access | Shows purchase downloads only to buyers with the correct role | Discord OAuth app + web backend + bot for role grant |
| Webhook logging | Posts in-game events to Discord channels as embed messages | Webhook URL + Lua PerformHttpRequest |
| Discord Rich Presence | Shows server name + player count in player Discord status | server.cfg variables (sets Discord, sets tags) |
| Announcement bot | Posts scheduled server news, restarts, or promotions to channels | Discord bot with channel write permissions |
| Ban/moderation sync | Mirrors in-game bans to a Discord log channel instantly | Webhook or bot + ban event handler in Lua |
Role-Based Whitelisting with Discord OAuth
The most powerful whitelist pattern ties server access directly to Discord guild membership and roles. A connecting player must have authorized your Discord OAuth application, and your server checks — via the Discord API — whether that player is in your guild and holds the required whitelist role.
How the Flow Works
- Player links their Discord account to your FiveM server (via a web portal or in-game prompt that opens a Discord OAuth authorization URL).
- Your backend exchanges the OAuth code for an access token, reads the player's guild membership and roles from the Discord API, and stores the result against their identifier.
- When the player connects, a server-side connection deferrals script queries the stored Discord data.
- If the player holds the whitelist role, the connection is allowed. If not, it is rejected with a custom message (e.g., "Join our Discord and apply for whitelist at discord.gg/yourserver").
- When staff grant or revoke the whitelist role in Discord, the change is reflected on the next connection attempt automatically.
This approach is more maintainable than a static identifier list in a database — staff manage whitelist through Discord roles, which most communities already do for other purposes. Role changes propagate without touching the server config.
Role-Gated Store and Download Access
The same OAuth pattern powers role-gated content delivery — the system used by shops like CRM Development to ensure only verified buyers can access purchased resource packs. After a customer completes a purchase, a bot grants them a buyer role in the Discord server. When they log into the web platform with Discord OAuth, the platform reads their roles and conditionally shows the download button.
This approach has several advantages over traditional email-based download links: access can be revoked by removing the Discord role (useful for chargebacks or license violations), buyers can re-download at any time without contacting support, and the entire access control system lives in Discord where the team is already operating.
Webhook Logging: Real-Time Server Events in Discord
Discord webhooks let your server-side Lua scripts POST formatted messages to any Discord channel without a bot. You create the webhook in Discord's channel settings, copy the URL, and your script sends HTTP requests to it whenever a loggable event occurs.
Example Webhook Payload
-- Lua server-side: send a Discord webhook embed
local webhookUrl = "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN"
local function sendDiscordLog(title, description, color)
PerformHttpRequest(webhookUrl, function(err, text, headers) end, "POST",
json.encode({
embeds = {{
title = title,
description = description,
color = color or 3447003,
timestamp = os.date("!%Y-%m-%dT%H:%M:%SZ")
}}
}),
{ ["Content-Type"] = "application/json" }
)
end
-- Usage: log a player ban
AddEventHandler("txAdmin:events:playerBanned", function(data)
sendDiscordLog(
"Player Banned",
string.format("**Player:** %s\n**Reason:** %s\n**Admin:** %s",
data.targetName, data.reason, data.author),
15158332 -- red
)
end)Common events worth logging include player connections and disconnections, ban and kick actions, admin command usage, robbery/heist start and completion, large money transactions, and server restarts. Keeping these logs in a dedicated Discord channel gives your moderation team a permanent, searchable audit trail.
Webhook JSON Structure Reference
Discord webhooks accept a JSON body. The most useful fields for FiveM logging are shown below.
{
"username": "Server Logs",
"avatar_url": "https://yoursite.com/icon.png",
"embeds": [
{
"title": "Event Title",
"description": "Event detail text here",
"color": 3066993,
"fields": [
{ "name": "Player", "value": "PlayerName", "inline": true },
{ "name": "Server ID", "value": "42", "inline": true }
],
"timestamp": "2026-05-21T14:00:00Z",
"footer": { "text": "MyServer RP" }
}
]
}Discord Rich Presence
Discord Rich Presence displays your server's name in a player's Discord status while they are in-game, along with an elapsed timer and optionally a Join button. This is configured entirely in server.cfg using native FiveM variables — no bot or script required.
# server.cfg — Discord Rich Presence configuration
sets Discord "https://discord.gg/yourserver"
sets tags "roleplay, serious, fivem"
# The Discord invite URL (sets Discord) becomes the Rich Presence join link
# Players see your server name and a clickable join link in their Discord status
# "sets tags" helps with FiveM server list discovery as wellRich Presence is low-effort, high-reward. Friends of your players see the server name while they are playing, which is organic word-of-mouth promotion. Always set a valid Discord invite URL here — ideally a permanent (non-expiring) invite link.
Announcement Automation
A Discord bot can automate the announcement lifecycle for your server — posting scheduled restart warnings, new update changelogs, event announcements, and promotional messages without requiring a staff member to be online at the right time.
- Post scheduled restart countdowns (30 min, 10 min, 5 min) to a public announcements channel automatically when txAdmin fires restart events.
- Send a "Server is back online" message after a restart completes by monitoring the server heartbeat.
- Automate weekly event announcements on a cron schedule so recurring server events are never forgotten.
- Post changelogs to an updates channel whenever you push a new resource version — tie this to your deployment pipeline.
- Use a separate high-traffic announcements channel with @everyone mentions for critical downtime notices, and a lower-noise updates channel for routine changes.
Moderation and Ban Sync
A complete moderation setup mirrors in-game bans to your Discord in real time. Staff can see at a glance who was banned, by whom, and for what reason without logging into txAdmin. Extend this pattern to log warnings, kicks, and spectate actions so there is a complete record of staff activity — useful for handling ban appeals and staff misconduct reports.
For cross-platform bans, a bot can also ban or kick a player from the Discord server when they are banned in-game. This prevents banned players from organizing ban evasion or harassing staff in the Discord chat.
Security Considerations for Discord Integrations
- Never expose your bot token or webhook URL in client-side scripts — these are server-side secrets only.
- Rate-limit your webhook calls in Lua; Discord enforces rate limits per webhook URL (roughly 30 requests per minute), and exceeding them will result in temporary 429 blocks.
- Validate Discord OAuth tokens on your backend — do not trust the client to report its own Discord ID.
- Use permanent Discord invite links for Rich Presence; expiring links break the Join button for everyone.
- Regularly audit which bots are in your Discord server and what permissions they hold — remove bots you no longer use.
Conclusion
Discord integration is no longer optional for a serious FiveM server — it is the connective tissue between your in-game community and the management layer around it. Role-based whitelisting ties access to your existing community structure. Webhook logging gives your moderation team a permanent audit trail. Rich Presence turns every active player into organic discovery. And announcement automation means your community stays informed without requiring staff to be on duty around the clock.
CRM Development builds Discord role-gating into its delivery system so buyers of server packs and custom scripts get instant, verified access the moment their purchase is confirmed — and access can be managed centrally without touching a database. If you want a turnkey server setup with Discord integration already wired in, explore the CRM Development pack lineup and see what a properly integrated server stack looks like from day one.
Frequently asked questions
How does Discord role-based whitelisting work for FiveM?+
A Discord bot reads a connecting player's guild membership and roles via the Discord API (using an OAuth token the player authorizes). If the player holds the required role, the server allows them to connect. If not, the connection is rejected with a message directing them to the Discord server.
Can I use Discord webhooks for FiveM server logs?+
Yes. Your server-side Lua scripts can fire HTTP POST requests to a Discord webhook URL, which posts formatted embed messages to a designated channel. Common uses include player join/leave logs, admin action logs, death logs, robbery alerts, and ban notifications.
What is Discord Rich Presence in FiveM?+
Discord Rich Presence lets FiveM display your server's name, player count, and a "Join" button directly in the player's Discord profile status. It is configured in your server.cfg using the `sets Discord` and `sets tags` variables, making your server more discoverable to friends.
How do role-gated downloads work for FiveM resource shops?+
After a customer purchases a resource, a bot grants them a specific Discord role. A web platform then checks guild membership and role status via the Discord OAuth flow — if the role is present, the download link is shown. This ties access to Discord membership, making it easy to revoke if needed.
Do I need coding knowledge to set up Discord webhooks for FiveM?+
Basic webhook logging requires only creating a webhook in your Discord channel settings and pasting the URL into your Lua script's HTTP request. More advanced integrations — OAuth whitelisting, role-sync bots — require either an existing resource from the community or custom scripting.
