In this comprehensive tutorial, I'll show you step by step how to set up a Discord whitelist for your FiveM server.
What exactly is a whitelist? A whitelist allows you to restrict server access only to selected players who are members of your Discord server. This greatly helps to increase the quality of the gaming experience and reduce unwanted behavior. From creating the Discord bot to configuring the Scripts all necessary steps are covered.
Contents
Here you can find a detailed YouTube video that explains the process again visually.
Step 1: Requirements
Before you start, make sure you meet the following requirements:
- A working FiveM server. (If you don't have one yet, check out our guide on creating a FivePD server.)
- A Discord server where you want to manage the whitelist.
- Administrator rights on both the FiveM server and the Discord server.
- Basic knowledge of using Discord and FiveM
Step 2: Create a Discord bot
To manage the whitelist, you need a Discord bot. Go to https://discord.com/developers/applications and log in with your Discord account. Click on "New Application" and give your bot a name. After you have created the application, go to "Bot" in the left menu and click on "Add Bot". Make a note of the generated bot token, as you will need it later.
Step 3: Add Discord bot to server
To add the Discord bot to your server, navigate to the "OAuth2" page of your application. Under "Scopes", select "bot" and set the required permissions under "Bot Permissions". To be whitelisted, the bot should have at least the "View Channels" and "Manage Roles" permissions. Copy the generated link, paste it into the address bar of your browser and select your Discord server. Finally, click "Authorize".
Step 4: Download DiscordWhitelist script
Visit the GitHub page of the DiscordWhitelist script for FiveM and download the script by clicking on "Code" and then "Download ZIP". Extract the ZIP file to your computer.
Step 5: Integrating the script into the FiveM server
Copy the extracted "discord-whitelist-master" folder to the "resources" directory of your FiveM server. Rename the folder to "discord-whitelist" to make installation easier. Open your server's "server.cfg" file with a text editor and add the following line to the end of the file:
ensure discord whitelist
Step 6: Configuring the DiscordWhitelist script
In the “resources” directory of your FiveM server, navigate to the “discord-whitelist” folder and open the “config.lua” file with a text editor to configure it.
- Bot token: Paste your Discord bot token into the corresponding line: luaCopy code
Config.DiscordToken = 'Your_Bot_Token'
- Discord role: Define the Discord role required to access the FiveM server: luaCopy code
Config.WhitelistRole = 'Name_of_Discord_Role'
You can also configure other settings, such as sending a message to players who are not on the whitelist. Then save the changes.
Step 7: Create and assign the Discord role
Create a new role on your Discord server with the name you specified in the config.lua file. Assign the role to the members you want to have access to your FiveM server. Make sure the role is visible and does not grant additional permissions that are not needed.
Step 8: Restart the FiveM server
Restart your FiveM server for the changes to take effect. Check that the DiscordWhitelist script loaded successfully and no error messages appear.
Step 9: Test whitelist
To test the functionality of the Discord whitelist, connect to your FiveM server and check that only players with the specified Discord role have access. Temporarily remove the role from your own Discord account and try connecting to the server again to ensure that access is denied.
Step 10: Discord whitelist maintenance and management
To ensure effective whitelist management, you should regularly check that the Discord bot is online and working correctly. Make sure that the Discord role is assigned only to the desired members. You can also add additional features to your bot to further facilitate whitelist management.
Now you are all set to set up a Discord whitelist on your FiveM server!