Cadburry ScriptsCadburry Scripts

Discord

Quality of life scripts for your FiveM server. Performance optimized resources that install in minutes, with free updates and support that actually answers.

lua
Config = Config or {}

Config.Discord = {
    bot_token = 'BOT_TOKEN', -- the bot must be in every server listed below
    cache_enabled = true, -- keep on, saves Discord requests
    cache_expiry = 600, -- seconds before role changes are picked up

    -- Your Discord servers. A player's roles come from the first one they are found in.
    Servers = {
        ['SERVER_ID'] = {
            -- label    = name shown on the welcome card
            -- name     = 'all', or a job name to only show characters with that job
            -- points   = higher points = further ahead in the queue (only for name = 'all')
            -- reserved = can join even when the server is full
            -- required = if any role has this, players need one of those roles to join
            roles = {
                -- ['ROLE_ID1'] = { label = 'Whitelisted', name = 'all', points = 0, required = true },
                -- ['ROLE_ID2'] = { label = 'COP', name = 'police', points = 10, required = false },
                -- ['ROLE_ID3'] = { label = 'EMS', name = 'ambulance', points = 15, required = false },
                -- ['ROLE_ID4'] = { label = 'Developer', name = 'all', points = 90, reserved = true, required = false },
                -- ['ROLE_ID5'] = { label = 'Crew', name = 'all', points = 95, reserved = false },
                -- ['ROLE_ID6'] = { label = 'Management', name = 'all', points = 100, reserved = true, required = false },
            },
        },
    },
}

-- Run queue commands from a Discord channel, e.g. '!queue getqcount'
-- The bot needs Read Messages, Send Messages and Message Content permissions
Config.Bot = {
    enabled = false,
    channel_id = 'CHANNEL_ID',
    prefix = '!queue',
    poll_interval = 3000, -- milliseconds
    allowed_roles = {
        -- ['ROLE_ID'] = true,
    },
    allowed_users = {
        -- ['USER_ID'] = true,
    },
}

-- Players that always skip the queue
Config.ReservedIdentifiers = {
    ['discord:000000000000000000'] = true,
}

-- Webhook for join/leave logs (leave empty to disable)
Config.LogsWebhook = ''

-- Sends join/leave logs to the webhook above (edit to change the message)
Config.SendLog = function(source, action, data)
    if not Config.LogsWebhook or Config.LogsWebhook == '' then return end

    local name = source and GetPlayerName(source) or 'Console'
    local title = ('[%s] - %s - %s'):format(tostring(source or 0), name, action)
    local description = data.playerIds
        and ('\n** Identifiers :** %s \n ** Message : ** %s'):format(json.encode(data.playerIds), data.message)
        or ('** Message : ** %s'):format(data.message)

    local payload = json.encode({
        username = 'Queue',
        embeds = { {
            title = title,
            color = 10650848,
            author = { name = 'Cadburry Scripts' },
            description = description,
            footer = { text = os.date('%c') },
        } },
    })

    PerformHttpRequest(Config.LogsWebhook, function() end, 'POST', payload, { ['Content-Type'] = 'application/json' })
end
Last updated Cadburry Scripts