Home FiveM Integrating Discord Notifications with Your FiveM Server

Integrating Discord Notifications with Your FiveM Server

Last updated on Feb 13, 2025

In this tutorial, you'll learn how to integrate Discord notifications into your FiveM server using a custom resource via the Pterodactyl panel (VolticHost Game Panel). This setup enables your server to send real-time alerts—such as player connections or important events—directly to your Discord channel, keeping you and your community informed. 🚀


📌 Prerequisites

  • A FiveM server purchased at VolticHost.com

  • Pre-installed FiveM with txAdmin, accessible via the VolticHost Game Panel

  • Basic knowledge of Lua scripting and file management

  • A Discord webhook URL (create one in your Discord channel settings under Integrations)


1️⃣ First Step - Creating the Discord Notification Resource

  1. Log in to VolticHost Game Panel.

  2. Navigate to the File Manager and go to the /resources/ directory.

  3. Create a new folder named discord_notifications.

  4. Inside the discord_notifications folder, create a new file named fxmanifest.lua with the following content:

    fx_version 'cerulean'
    game 'gta5'
    
    author 'YourName'
    description 'Discord Notification Integration'
    version '1.0.0'
    
    server_script 'discord_notify.lua'
    
  5. Save the file.

Discord notification resource and manifest created successfully!


2️⃣ Next Step - Uploading the Discord Notification Script

  1. In the discord_notifications folder, create a new file named discord_notify.lua.

  2. Open discord_notify.lua for editing and paste the following code:

    -- discord_notify.lua
    
    -- Set your Discord webhook URL here
    local discordWebhook = "YOUR_DISCORD_WEBHOOK_URL"
    
    -- Function to send a notification to Discord
    function sendDiscordNotification(message)
        local payload = {
            content = message
        }
        PerformHttpRequest(discordWebhook, function(err, text, headers) 
            if err ~= 200 then
                print("Discord notification error: " .. tostring(err))
            end
        end, 'POST', json.encode(payload), { ['Content-Type'] = 'application/json' })
    end
    
    -- Example: Notify when a player connects
    AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
        local msg = playerName .. " is connecting to the server."
        sendDiscordNotification(msg)
    end)
    
    -- Example: Notify when the server starts
    AddEventHandler('onResourceStart', function(resourceName)
        if GetCurrentResourceName() == resourceName then
            sendDiscordNotification("Server resource '" .. resourceName .. "' has started successfully!")
        end
    end)
    
  3. Replace "YOUR_DISCORD_WEBHOOK_URL" with your actual Discord webhook URL.

  4. Save the file.

Discord notification script uploaded and configured successfully!


3️⃣ Next Step - Activating the Discord Notification Resource

  1. In the Pterodactyl panel, open your server.cfg file located in the root directory of your FiveM server.

  2. Add the following line to ensure your new resource starts with the server:

    start discord_notifications
    
  3. Save your changes.

Discord notification resource added to server configuration successfully!


4️⃣ Next Step - Testing and Verifying Discord Notifications

  1. Restart your server from the Pterodactyl panel to load the new resource.

  2. Join your server and monitor the Discord channel linked to your webhook.

  3. Verify that:

    • A notification is sent when a player connects.

    • A message is sent when the resource starts.

  4. Check the server console for any errors related to the HTTP requests.

Discord notifications tested and functioning correctly!


🎉 Conclusion

You have now successfully integrated Discord notifications with your FiveM server using a custom resource via the Pterodactyl (VolticHost Game) panel! This setup ensures you receive real-time alerts for key events, helping you maintain an informed and responsive server environment. 🚀

For further assistance or advanced customization, contact VolticHost Support.