{"id":193116,"date":"2025-08-17T19:43:50","date_gmt":"2025-08-17T17:43:50","guid":{"rendered":"https:\/\/fivemx.com\/?p=193116"},"modified":"2025-12-23T16:43:20","modified_gmt":"2025-12-23T15:43:20","slug":"liste-blanche-discord-fivem","status":"publish","type":"post","link":"https:\/\/fivemx.com\/fr\/discord-whitelist-fivem\/","title":{"rendered":"How to Set Up a Discord Whitelist for Your FiveM Server (&#8230;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Audience:<\/strong> FiveM server owners &amp; developers<br><strong>Difficulty:<\/strong> Easy \u2192 Intermediate<br><strong>Outcome:<\/strong> Role\u2011based allowlist using Discord roles (with optional blacklist), minimal maintenance, clear player feedback.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note on versions<\/strong>: The open\u2011source repo <code>FAXES\/DiscordWhitelist<\/code> is community\u2011maintained and last updated in 2022. It still works for many servers. A maintained commercial version exists; if you need support\/SLA, consider it. This guide covers the free GitHub version.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">TL;DR<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a Discord <strong>Bot<\/strong> \u2192 enable <strong>Server Members Intent<\/strong> \u2192 invite it to your Discord.<\/li>\n\n\n\n<li>Copy your <strong>Guild (Server) ID<\/strong> and <strong>Role ID(s)<\/strong>.<\/li>\n\n\n\n<li><strong>Download<\/strong>: <a href=\"https:\/\/github.com\/FAXES\/DiscordWhitelist\" target=\"_blank\" rel=\"noopener\">FAXES\/DiscordWhitelist on GitHub<\/a> \u2192 put it in <code>resources\/<\/code> \u2192 configure <code>server.js<\/code>.<\/li>\n\n\n\n<li>Add <code>ensure DiscordWhitelist<\/code> to <code>server.cfg<\/code> (or start in txAdmin).<\/li>\n\n\n\n<li>Test: join without the role (blocked) \u2192 add role \u2192 rejoin (allowed).<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Related tutorials:<\/strong><br>\u2022 <a href=\"https:\/\/fivemx.com\/fivem-whitelist\/\">FiveM Whitelist \u2014 Complete Guide (txAdmin, Scripts, DB)<\/a><br>\u2022 <a href=\"https:\/\/fivemx.com\/how-to-create-discord-donation-tiers\/\">How to Create Discord Donation Tiers<\/a><\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Why Discord\u2011based Whitelisting?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Dynamic<\/strong>: Grant\/deny access by adding\/removing a Discord role\u2014no ACE or DB edits.<\/li>\n\n\n\n<li><strong>Scalable<\/strong>: Mods can manage access from Discord on mobile.<\/li>\n\n\n\n<li><strong>Auditable<\/strong>: Role history + moderation logs show who allowed whom.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Discord server (you are Admin\/Owner).<\/li>\n\n\n\n<li>FiveM server with txAdmin or manual control.<\/li>\n\n\n\n<li>Players must have the <strong>Discord desktop app running<\/strong> when connecting (so FiveM exposes a <code>discord:<\/code> identifier).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 \u2014 Create a Discord Bot &amp; Enable Intents<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to the <strong>Discord Developer Portal<\/strong> \u2192 <strong>New Application<\/strong> \u2192 name it (e.g., <code>FiveMX Whitelist Bot<\/code>).<\/li>\n\n\n\n<li><strong>Add a Bot<\/strong> (Bot tab) \u2192 <strong>Reset Token<\/strong> \u2192 copy the <strong>Bot Token<\/strong> (store it securely).<\/li>\n\n\n\n<li>Under <strong>Privileged Gateway Intents<\/strong>, enable <strong>Server Members Intent<\/strong>. (Presence intent is not required.)<\/li>\n\n\n\n<li><strong>Invite the Bot<\/strong> to your Discord: OAuth2 \u2192 URL Generator \u2192 Scopes: <code>bot<\/code>; Permissions: minimal (can be none beyond joining). Use the generated URL and add it to your guild.<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Security<\/strong>: Treat the Bot Token like a password. Do <strong>not<\/strong> commit it to Git or share it in screenshots. Rotate if leaked.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 \u2014 Get Your IDs (Guild &amp; Roles)<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In Discord \u2192 <strong>User Settings \u2192 Advanced \u2192 Developer Mode<\/strong>: ON.<\/li>\n\n\n\n<li>Right\u2011click your <strong>server name<\/strong> \u2192 <strong>Copy Server ID<\/strong>.<\/li>\n\n\n\n<li><strong>Server Settings \u2192 Roles<\/strong> \u2192 right\u2011click the role you\u2019ll use as the whitelist (e.g., <code>Whitelisted<\/code>) \u2192 <strong>Copy Role ID<\/strong>.<\/li>\n\n\n\n<li>(Optional) Copy IDs for any roles you want to <strong>blacklist<\/strong> (e.g., <code>Banned<\/code>).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Keep these handy:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>GUILD_ID = 123456789012345678<\/code><\/li>\n\n\n\n<li><code>WHITELIST_ROLE_IDS = [\"111111111111111111\", \"222222222222222222\"]<\/code><\/li>\n\n\n\n<li><code>BLACKLIST_ROLE_IDS = [\"333333333333333333\"]<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 \u2014 Download &amp; Install the Resource<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Download<\/strong> the ZIP from <strong><a href=\"https:\/\/github.com\/FAXES\/DiscordWhitelist\" target=\"_blank\" rel=\"noreferrer noopener\">FAXES\/DiscordWhitelist (GitHub)<\/a><\/strong>.<\/li>\n\n\n\n<li>Extract to your server at:<br><code>resources\/[discord]\/DiscordWhitelist<\/code><\/li>\n\n\n\n<li>Verify the folder contains at least:\n<ul class=\"wp-block-list\">\n<li><code>fxmanifest.lua<\/code><\/li>\n\n\n\n<li><code>server.js<\/code><\/li>\n\n\n\n<li><code>package.json<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a class=\"wpil_keyword_link\" href=\"https:\/\/fivemx.com\/fivem-server-cfg\/\" title=\"FiveM server.cfg &#8211; Full Guide\" data-wpil-keyword-link=\"linked\" data-wpil-monitor-id=\"1821\">server.cfg<\/a><\/strong> (or txAdmin <strong>Recipe \/ Startup<\/strong>):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Start after your identifier providers and before join\u2011logic that depends on it\nensure DiscordWhitelist\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In <strong>txAdmin \u2192 Resources<\/strong>, mark <strong>DiscordWhitelist<\/strong> to start on boot (if you manage resources via UI).<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Planning your access strategy?<\/strong> Read our broader guide: <strong><a href=\"https:\/\/fivemx.com\/fivem-whitelist\/\">FiveM Whitelist \u2014 Complete Guide (txAdmin, Scripts, DB)<\/a><\/strong> for alternatives (ACE, DB, hybrid) and when to use each.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4 \u2014 Configure <code>server.js<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open <code>resources\/[discord]\/DiscordWhitelist\/server.js<\/code> and set the config block. The file may already expose a simple config object\u2014adjust values accordingly. A typical configuration looks like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ DiscordWhitelist configuration \u2014 example\nconst config = {\n  botToken: \"PASTE_YOUR_DISCORD_BOT_TOKEN_HERE\",\n  guildId: \"123456789012345678\",               \/\/ Your server (guild) ID\n\n  \/\/ Players must have at least ONE of these role IDs to join\n  whitelistRoles: [\n    \"111111111111111111\", \/\/ Whitelisted\n    \/\/ \"222222222222222222\", \/\/ Staff (optional)\n  ],\n\n  \/\/ If a player has ANY of these roles, reject the connection\n  blacklistRoles: [\n    \/\/ \"333333333333333333\", \/\/ Banned\n  ],\n\n  \/\/ Cache fetched role data to reduce Discord API calls (seconds)\n  cacheMaxTime: 90,\n\n  \/\/ Deferral messages\n  messages: {\n    noDiscord: \"Open Discord and rejoin. Your Discord app must be running.\",\n    notWhitelisted: \"You are not whitelisted. Join our Discord: discord.gg\/yourinvite\",\n    blacklisted: \"Access denied. Please contact staff.\",\n    welcome: \"Welcome \u2014 you are verified. Loading\u2026\"\n  },\n};\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Monetization tip:<\/strong> If your server uses perks, pair this with <strong><a href=\"https:\/\/fivemx.com\/how-to-create-discord-donation-tiers\/\">Discord Donation Tiers<\/a><\/strong> to automate role\u2011based benefits for supporters\/donors.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5 \u2014 Restart &amp; Test<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Restart<\/strong> just the resource or the whole server: <code>txAdmin \u2192 Restart resource<\/code> or console <code>refresh<\/code> then <code>restart DiscordWhitelist<\/code>.<\/li>\n\n\n\n<li><strong>Negative test<\/strong>: Try connecting <strong>without<\/strong> the whitelist role \u2192 you should see the deferral message and be kicked.<\/li>\n\n\n\n<li><strong>Positive test<\/strong>: Grant yourself the whitelist role \u2192 reconnect \u2192 you should be allowed in.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Optional: Multiple Roles &amp; Staff Bypass<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add <strong>several whitelist roles<\/strong> to allow multiple funnels (e.g., <code>Donator<\/code>, <code>Police<\/code>, <code>EMS<\/code>).<\/li>\n\n\n\n<li>Add <strong>blacklist roles<\/strong> for hard blocks regardless of whitelist (e.g., <code>Banned<\/code>).<\/li>\n\n\n\n<li>You can include a <strong>staff role<\/strong> in <code>whitelistRoles<\/code> to guarantee access for admins.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Operational Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Automation<\/strong>: Connect Discord role assignment to your <a href=\"https:\/\/fivemx.com\/how-to-create-a-whitelist\/#google-forms-whitelist\" data-type=\"link\" data-id=\"https:\/\/fivemx.com\/how-to-create-a-whitelist\/#google-forms-whitelist\">application forms<\/a> or <a href=\"https:\/\/fivemx.com\/how-to-use-add-a-ticket-system-for-discord\/\" data-type=\"post\" data-id=\"162574\">ticket approvals<\/a> (e.g., with a bot, Google Forms \u2192 webhook \u2192 role add).<\/li>\n\n\n\n<li><strong>Player UX<\/strong>: Pin a <code>#how-to-whitelist<\/code> post with \u2705 role requirements and your server invite.<\/li>\n\n\n\n<li><strong>Moderation<\/strong>: Log role changes in a private <code>#mod-logs<\/code> channel.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u201cBot offline\u201d or never updates roles<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Token wrong or bot not invited to the correct guild.<\/li>\n\n\n\n<li><strong>Server Members Intent<\/strong> not enabled.<\/li>\n\n\n\n<li>Firewall blocks outbound HTTPS from your game host (allow Discord API).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u201cNo Discord identifier found\u201d \/ everyone blocked<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Players must run the <strong>Discord desktop app<\/strong> before launching FiveM. Ask them to restart Discord, then FiveM.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Role changes only apply after a restart<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce <code>cacheMaxTime<\/code> to 30\u201360 seconds.<\/li>\n\n\n\n<li>If you set it extremely low and still see delays, check rate limits and avoid restarting frequently.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>403\/Permissions error when fetching guild members<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure the bot is in the target guild <strong>and<\/strong> Server Members Intent is enabled.<\/li>\n\n\n\n<li>The bot does <strong>not<\/strong> need Admin perms to read member roles.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>High API usage \/ rate limiting<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Increase <code>cacheMaxTime<\/code>. Avoid mass\u2011kicking\/restarts that spam API calls.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Security Best Practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Store the <strong>Bot Token<\/strong> outside of version control. If you self\u2011host configs, consider reading it from an environment variable or server.cfg convar, not in plain text committed to Git.<\/li>\n\n\n\n<li><strong>Rotate<\/strong> the token if leaked.<\/li>\n\n\n\n<li>Restrict who has write access to the resource.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Uninstall \/ Disable<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Remove <code>ensure DiscordWhitelist<\/code> from <code>server.cfg<\/code> (or disable in txAdmin \u2192 Resources).<\/li>\n\n\n\n<li>Remove the folder from <code>resources\/<\/code> if you\u2019re decommissioning it.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do players need Discord running?<\/strong><br>Yes. Without the <code>discord:<\/code> identifier, the script can\u2019t verify roles.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Which intents do I need?<\/strong><br>Only <strong>Server Members Intent<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can I use multiple whitelist roles?<\/strong><br>Yes. Access is granted if the user has <strong>any<\/strong> of the listed roles.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can I hard\u2011deny certain roles?<\/strong><br>Yes. Add them to <code>blacklistRoles<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>It stopped working after I changed roles.<\/strong><br>Lower <code>cacheMaxTime<\/code>, then test again. Ensure the bot is online with the correct token and guild.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is there a maintained version?<\/strong><br>Yes. A commercial, actively maintained edition exists if you need updates\/support.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Appendix \u2014 Example <code>server.cfg<\/code><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Discord whitelist\nensure DiscordWhitelist\n\n# (Optional) put related Discord resources here as a block\n# ensure discord_perms\n# ensure discordrolesync\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Appendix \u2014 Example Player Messaging (Deferrals)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keep messages short and actionable:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">messages: {\n  noDiscord: \"Open Discord and rejoin. Your Discord app must be running.\",\n  notWhitelisted: \"Not whitelisted. Apply in #how-to-whitelist \u2192 discord.gg\/yourinvite\",\n  blacklisted: \"Access denied. Contact staff via ticket.\",\n  welcome: \"Verified \u2014 loading city\u2026\"\n}\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Changelog (Editor\u2011facing)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>v1.1 \u2014 Added natural internal links to Donation Tiers, FiveM Whitelist Complete Guide, and GitHub download.<\/li>\n\n\n\n<li>v1.0 \u2014 Initial guide: bot creation, intents, IDs, install, config, testing, FAQ.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Audience: FiveM server owners &amp; developersDifficulty: Easy \u2192 IntermediateOutcome: Role\u2011based allowlist using Discord roles (with optional blacklist), minimal maintenance, clear player feedback. Note on versions: The open\u2011source repo FAXES\/DiscordWhitelist is community\u2011maintained and last updated in 2022. It still works for many servers. A maintained commercial version exists; if you need support\/SLA, consider it. This guide [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":193117,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2885],"tags":[],"class_list":["post-193116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-discord-guides"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/posts\/193116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/comments?post=193116"}],"version-history":[{"count":0,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/posts\/193116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/media\/193117"}],"wp:attachment":[{"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/media?parent=193116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/categories?post=193116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemx.com\/fr\/wp-json\/wp\/v2\/tags?post=193116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}