Discord Rich Presence failing to work

hi! ive been doing server development for like 1 year or 2 right… i know front and back about resources and shit so i aint dumb

so i load up to my vps and decide i wanna develop my rich presence for my server because it has some advertising leads to it since you can press and button and you can make players link it to a website which is sick as fuck right

i have an older resource that ive used for around 12 months now for previous servers and it’s worked perfectly fine since. i decide to make a new discord dev application so i dont use my previous server dev app. i ensure the script and i load into the server. i connect to the fivem rich presence and then it says im connecting to my server and then disappears. literally no client and server errors in any console and i dont know what i did wrong. i had a friend give me his rich presence resource and it works literally perfectly fine??? we have the same line of code. ill present both lines here in a second, but heres a video of my activity of when i open fivem and connect to my server.

friends code:

Citizen.CreateThread(function()
	while true do
		SetDiscordAppId(844781187087466497)
		SetDiscordRichPresenceAsset('big')
        SetDiscordRichPresenceAssetText('Dark Networks 2.0 | FiveM Community')
        SetDiscordRichPresenceAssetSmall('small')
        SetDiscordRichPresenceAssetSmallText('Join Today! discord.gg/3xPR4gHDeA')
		SetDiscordRichPresenceAction(0, "Make sure to Join Our Discord!", "https://discord.gg/3xPR4gHDeA")
        SetDiscordRichPresenceAction(1, "Might as Well Connect!", "https://cfx.re/join/r3ydj7")
		Citizen.Wait(60000)
	end
end)
Citizen.CreateThread(function()
	while true do
		local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
		if VehName == "NULL" then VehName = GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))) end
		local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true))
		local StreetHash = GetStreetNameAtCoord(x, y, z)
		local pId = GetPlayerServerId(PlayerId())
		local pName = GetPlayerName(PlayerId())
		Citizen.Wait(15000)
		if StreetHash ~= nil then
			StreetName = GetStreetNameFromHashKey(StreetHash)
			if IsPedOnFoot(PlayerPedId()) and not IsEntityInWater(PlayerPedId()) then
				if IsPedSprinting(PlayerPedId()) then
					SetRichPresence("ID: "..pId.." | "..pName.." is sprinting down "..StreetName)
				elseif IsPedRunning(PlayerPedId()) then
					SetRichPresence("ID: "..pId.." | "..pName.." is running down "..StreetName)
				elseif IsPedWalking(PlayerPedId()) then
					SetRichPresence("ID: "..pId.." | "..pName.." is walking down "..StreetName)
				elseif IsPedStill(PlayerPedId()) then
					SetRichPresence("ID: "..pId.." | "..pName.." is standing on "..StreetName.."")
				end
			elseif GetVehiclePedIsUsing(PlayerPedId()) ~= nil and not IsPedInAnyHeli(PlayerPedId()) and not IsPedInAnyPlane(PlayerPedId()) and not IsPedOnFoot(PlayerPedId()) and not IsPedInAnySub(PlayerPedId()) and not IsPedInAnyBoat(PlayerPedId()) then
				local MPH = math.ceil(GetEntitySpeed(GetVehiclePedIsUsing(PlayerPedId())) * 2.236936)
				if MPH > 50 then
					SetRichPresence("ID: "..pId.." | "..pName.." is speeding down "..StreetName.." at "..MPH.."MPH in a "..VehName)
				elseif MPH <= 50 and MPH > 0 then
					SetRichPresence("ID: "..pId.." | "..pName.." is cruising down "..StreetName.." at "..MPH.."MPH in a "..VehName)
				elseif MPH == 0 then
					SetRichPresence("ID: "..pId.." | "..pName.." is parked on "..StreetName.." in a "..VehName)
				end
			elseif IsPedInAnyHeli(PlayerPedId()) or IsPedInAnyPlane(PlayerPedId()) then
				if IsEntityInAir(GetVehiclePedIsUsing(PlayerPedId())) or GetEntityHeightAboveGround(GetVehiclePedIsUsing(PlayerPedId())) > 5.0 then
					SetRichPresence("ID: "..pId.." | "..pName.." is flying over "..StreetName.." in a "..VehName)
				else
					SetRichPresence("ID: "..pId.." | "..pName.." is landed at "..StreetName.." in a "..VehName)
				end
			elseif IsEntityInWater(PlayerPedId()) then
				SetRichPresence("ID: "..pId.." | "..pName.." is swimming")
			elseif IsPedInAnyBoat(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
				SetRichPresence("ID: "..pId.." | "..pName.." is sailing in a "..VehName)
			elseif IsPedInAnySub(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
				SetRichPresence("ID: "..pId.." | "..pName.." is in a yellow submarine")
			end
		end
	end
end)

my code:

Citizen.CreateThread(function()
    while true do
        
        --properties
        local name = GetPlayerName(PlayerId())
        local id = GetPlayerServerId(PlayerId())
        local street = GetStreetNameFromHashKey(GetStreetNameAtCoord(table.unpack(GetEntityCoords(player))))
        local vehicle = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
        local MPH = math.ceil(GetEntitySpeed(GetVehiclePedIsUsing(PlayerPedId())) * 2.236936)
        local NumberOfPlayers = 0

        for i = 0, 255 do
            if NetworkIsPlayerActive(i) then
                NumberOfPlayers = NumberOfPlayers + 1
            end
        end

        --game status app
        SetDiscordAppId(863587944127660043)

        --logo icon
        SetDiscordRichPresenceAsset('tempestlogo')
        SetDiscordRichPresenceAssetText('https://discord.tempestcommunity.com/')

        --buttons
        local button1name = 'Wanna know what Tempest is? Check out our website!'
        local button1url = 'https://www.tempestcommunity.com/'
        local button2name = 'Join our Discord community too!'
        local button2url = 'https://discord.tempestcommunity.com/'
        SetDiscordRichPresenceAction(0, button1name, button1url)
        SetDiscordRichPresenceAction(1, button2name, button2url)

        --small icon
        --SetDiscordRichPresenceAssetSmall('discordsmall')
        --SetDiscordRichPresenceAssetSmallText('https://discord.gg/cooley')

        --loop for rich presense change

         SetRichPresence('Players: ' .. NumberOfPlayers)
         Wait(5*1000)
         SetRichPresence('ID: ' .. id)
         Wait(5*1000)
         SetRichPresence('IGN: ' .. name)
         Wait(5*1000)
         SetRichPresence('www.tempestcommunity.com/')
         Wait(7*1000)


        --updates every selected seconds 
        Citizen.Wait(10000)
    end
end)


--[[
UNUSED RICH PRESENSES:
SetRichPresence( "AOP: " .. TriggerClientEvent('aop:updateAOP') )


]]

so wtf did i do wrong? am i supposed to wait for like discord to verify something or some shit like what? this is pissing me off because it literally works fine for my friend but it doesnt for me like what what did i do wrong :worried:

1 Like

Hope it works for you

Citizen.CreateThread(function()
    SetDiscordAppId(863587944127660043)
    SetDiscordRichPresenceAsset('tempestlogo')
    SetDiscordRichPresenceAssetText('https://discord.tempestcommunity.com')
    SetDiscordRichPresenceAction(0, 'Wanna know what Tempest is? Check out our website!', 'https://www.tempestcommunity.com')
    SetDiscordRichPresenceAction(1, 'Join our Discord community too!', 'https://discord.tempestcommunity.com')
    while true do
        Citizen.Wait(10000)
        local playerId = GetPlayerServerId(PlayerId())
        local playerName = GetPlayerName(PlayerId())
        SetRichPresence('Players: ' .. #GetActivePlayers())
        Citizen.Wait(5 * 1000)
        SetRichPresence('ID: ' .. playerId)
        Citzen.Wait(5 * 1000)
        SetRichPresence('IGN: ' .. playerName)
        Citzen.Wait(5 * 1000)
        SetRichPresence('www.tempestcommunity.com')
    end
end)
1 Like

hmm… no it still doesnt work, but the loop is working, proven by this:

def moving this situation to be something wrong with the natives above the small presence changing loop. i see LITERALLY nothing wrong with them, i dont understand

Try this, it should work now.

Citizen.CreateThread(function()
    while true do
        local playerId = GetPlayerServerId(PlayerId())
        local playerName = GetPlayerName(PlayerId())
        SetDiscordAppId(863587944127660043)
        SetDiscordRichPresenceAsset('tempestlogo')
        SetDiscordRichPresenceAssetText('https://discord.tempestcommunity.com')
        SetDiscordRichPresenceAction(0, 'Wanna know what Tempest is? Check out our website!', 'https://www.tempestcommunity.com')
        SetDiscordRichPresenceAction(1, 'Join our Discord community too!', 'https://discord.tempestcommunity.com')
        SetRichPresence(string.format('%s [%d] - Players: %d / 128', playerName, playerId, #GetActivePlayers()))
        Citizen.Wait(10000)
    end
end)
1 Like

Still doesn’t seem to work… I don’t know what the issue is here. I really hope I ain’t disturbing @nta by pinging him on the Forums but I personally don’t think something is right here… I’ll provide any necessary information if you need any but this is really annoying me…

Anyone find a fix yet?

I followed this tutorial and it works perfectly for me. So atleast the discord natives are working.

Make sure that you are using the right application ID. I’ve had a issue like this before and it was caused by a incorrect application ID.

Just followed the tutorial and it hasn’t worked for me. I’ve even tried changing the Application ID, resource name, clearing server cache and even clearing my own client cache and it still does not seem to work. What the absolute fuck am I doing wrong? Here is my current code:

--[[ Commented out as this was the original one.
Citizen.CreateThread(function()
    SetDiscordAppId(863587944127660043)
    SetDiscordRichPresenceAsset('tempestlogo')
    SetDiscordRichPresenceAssetText('https://discord.tempestcommunity.com')
    SetDiscordRichPresenceAction(0, 'Wanna know what Tempest is? Check out our website!', 'https://www.tempestcommunity.com')
    SetDiscordRichPresenceAction(1, 'Join our Discord community too!', 'https://discord.tempestcommunity.com')
    while true do
        Citizen.Wait(10000)
        local playerId = GetPlayerServerId(PlayerId())
        local playerName = GetPlayerName(PlayerId())
        SetRichPresence('Players: ' .. #GetActivePlayers())
        print("presense 1 sent: players")
        Citizen.Wait(5 * 1000)
        SetRichPresence('ID: ' .. playerId)
        print("presense 2 sent: ingame id")
        Citizen.Wait(5 * 1000)
        SetRichPresence('IGN: ' .. playerName)
        print("presense 3 sent: ingame name")
        Citizen.Wait(5 * 1000)
        SetRichPresence('www.tempestcommunity.com')
        print("presense 4 sent: website")
    end
end)]]


Citizen.CreateThread(function()
	while true do
        -- This is the Application ID (Replace this with you own)
		SetDiscordAppId(864921192539750400)
        print("Application ID set.")

        -- Here you will have to put the image name for the "large" icon.
		SetDiscordRichPresenceAsset('tempest_logo')
        print("Rich Presence Logo set.")
        
        -- (11-11-2018) New Natives:

        -- Here you can add hover text for the "large" icon.
        SetDiscordRichPresenceAssetText('Tempest Community')
        print("Rich Presence Logo Text set.")
       
        -- Here you will have to put the image name for the "small" icon.
        --SetDiscordRichPresenceAssetSmall('logo_name')

        -- Here you can add hover text for the "small" icon.
        --SetDiscordRichPresenceAssetSmallText('This is a lsmall icon with text')


        -- (26-02-2021) New Native:

        --[[ 
            Here you can add buttons that will display in your Discord Status,
            First paramater is the button index (0 or 1), second is the title and 
            last is the url (this has to start with "fivem://connect/" or "https://") 
        ]]--
        SetDiscordRichPresenceAction(0, "Wanna know what Tempest is? Click me!", "https://www.tempestcommunity.com")
        print("Button 1 set.")
        SetDiscordRichPresenceAction(1, "Join our Discord community too!", "https://discord.tempestcommunity.com")
        print("Button 2 set.")
        -- It updates every minute just in case.
		Citizen.Wait(60000)
	end
end)

Here is my console every time I join the server:

Has any other user tried this? If it works for other users, then we would know for sure that the issue isn’t in the code? Can you have some other player try if it works him?

We just confirmed that it doesn’t work for my friend’s server as well. This def has something wrong with the code.

Bump, still need help with this. Server release is starting soon and we need this ASAP.

100% Working :wink:

Citizen.CreateThread(function()
	while true do
		SetDiscordAppId(000000000000) -- App ID
		SetDiscordRichPresenceAsset('Logo')
        SetDiscordRichPresenceAssetText('Server Name')
        SetDiscordRichPresenceAssetSmall('1')
		SetDiscordRichPresenceAssetSmallText('Link')
		SetDiscordRichPresenceAction(0, "🌐 Connect 🌐", "Link")
		SetDiscordRichPresenceAction(1, "📢 Discord 📢", "Link")
		Citizen.Wait(60000)
	end
end)
Citizen.CreateThread(function()
	while true do
	Citizen.Wait(10000)
		local pId = GetPlayerServerId(PlayerId())

		-- Set here the amount of slots you have (Edit if needed)
		local maxPlayerSlots = 1024

		-- For loop to get active player (Legacy method)
		players = {}
		for i = 0, 255 do
			if NetworkIsPlayerActive( i ) then
				table.insert( players, i )
			end
		end

		-- Sets the string with variables as RichPresence (Don't touch)
		SetRichPresence(string.format("Players: %s/%s | ID: %s", #players + 20, maxPlayerSlots, pId))
		
		-- It updates every one minute just in case.
		Citizen.Wait(60000)
	end
end)

Yup, We already figured it out in discord. The issue was the application ID.

Yeah, the Application ID and some variables in the other natives are very specific on what it wants, for example, if you have too much characters in SetDiscordRichPresenceAction and such, it’ll trickled out and fail to work. Still configuring it so it works with buttons but it’s just very picky. I have no clue why this is still a bit of an issue for me and my server but it’s slowly working, still need to set up the buttons and such.

Found the error. There is a character limit for these variables. No idea what the limit is but try to keep everything small…

I am having the same issue, can I see your code? I am using the one your friend posted, and for some reason it still doesn’t show up. Its not even coming up in the resource monitor on client side. But in the VPS it says it’s running. I am honestly clueless. It was working fine a month ago, and randomly stopped working now.

Thanks mate!