[How-to] [Updated] Discord rich presence Custom Image 🏞

discord
rich-presence

#1

First of all a BIG thanks to @IceHax for making this possible, here is a link to his Github go check him out :snail:

  • (11-11-2018) New Natives added, check out the bottom of this tutorial!

.
First thing you have to do is make a discord https://discordapp.com/ account if you haven’t done that already.

If you have a discord account go to https://discordapp.com/developers/applications/

  • First make a new application by clicking the “Create an application”

  • When you create a new application, you will see a similar page as shown below on the foto.
  • You will have to copy the Application id (See the arrow) and save it for later.

  • Now you need to navigate to te left navigation bar and go to Rich Presence>Art Assets.

  • This is where the magic starts, here you can upload you image.(The image has to be 512x512 pixels or lager)

  • If you have uploaded the image you will need to remember the image name and don’t forget to hit “Save Changes”

Now we have the discord application id and the image name. Last, we have to put those values into a script.
I have made a very very getto and simple script for you to test it with.

  • make a folder inside the server resource folder and call it discord
  • make 2 files one called __resource.lua and one called client.lua
  • paste the code below into the correct file

Thanx to @d0p3t, we have 3 new natives now
New Natives:

  • SetDiscordRichPresenceAssetSmall
  • SetDiscordRichPresenceAssetSmallText
  • SetDiscordRichPresenceAssetText

Check the code below to see how to use them and what they do!

__resource.lua:

resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
client_script 'client.lua'

client.lua:

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

        --Here you will have to put the image name for the "large" icon.
		SetDiscordRichPresenceAsset('logo_name')
        
        --(11-11-2018) New Natives:

        --Here you can add hover text for the "large" icon.
        SetDiscordRichPresenceAssetText('This is a lage icon with text')
       
        --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')

        --It updates every one minute just in case.
		Citizen.Wait(60000)
	end
end)

If you followed all the steps and used common knowledge, you will see this:

And with the new natives:

you might want to leave a like :heart: if you found this post helpfull
Enjoy!

(This post might contain grammar mistakes)


[FIXED] Discord rich presence picture, help
Discord Presence, Set image on thumbnail?
Location display for Discord's Rich Presence
Playing Discord Server
Name of server
How to do the something like that?
Fivem discord show server as game
Name of server
#2

good job! :slight_smile:


#3

This is great, Would be awesome to have the ability to click “Join game” and it loads them into your server IP


#4

This is great, Would be awesome to have the ability to click “Join game” and it loads them into your server IP

This isn’t a public feature, it could be possible but needs manual approval by discord itself. I dont’t see this feature coming in the near feature, but maby some day.


#5

yep, discord has already said it wont accept mods, only games.


#6

SetRichPresence('This is a rich presence message under the server name and description')

image
Should add that to the script as well


#7


If u want to do Krizfrost’s screen


#8

how do you get the player count


#9

How can we add this to yours sir ?

Citizen.CreateThread(function()
while true do
–This is the Application ID (Replace this with you own)
SetDiscordAppId(123456788967867867)

    --Here you will have to put the image name.
	SetDiscordRichPresenceAsset('logo_name')

    --It updates every one minute just in case.
	Citizen.Wait(60000)
end

end)


Fivem discord show server as game
#10

huh? your question is unclear.


#11

Im sorry I was looking to put his code into your RichPresence code so it was one resource, however I ended up making to resources works like a charm :smiley: Thanks both of you!


#12

i never made a richpresence resource… i’ve contributed to the fivem discord rich presence implementation, which is quite different :thinking: .


#13

Ah, sorry about that well thanks for the help and the quick reply reguardless


#14

I tried it but it didn’t work. Sad, it was a pretty cool idea.


#15

It works fine. You probably didn’t setup the Discord application correctly.

Please provide information instead of just saying “it doesn’t work”.


#16

I don’t know if i’ll get called a scum for reposting this but i worked on it for a while and thought i would share it. It combines the code from this post “Location Display for Discord Rich Presence” by @ IllusiveTea, the discord asset natives shown here and some touches of my own into one with too many comments so you can modify the script and learn how it works :slight_smile:.

__resource.lua:

resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
client_script 'client.lua'

Client.lua:

Citizen.CreateThread(function()
	while true do
		SetDiscordAppId(123456789012345678) --Discord app id
		SetDiscordRichPresenceAsset('Big_Picture') --Big picture asset name
        SetDiscordRichPresenceAssetText('Big picture text.') --Big picture hover text
        SetDiscordRichPresenceAssetSmall('small_picture') --Small picture asset name
        SetDiscordRichPresenceAssetSmallText('Small picture text') --Small picture hover text
		Citizen.Wait(600000) --How often should this script check for updated assets? (in MS)
	end
end)
--No Need to mess with anything pass this point!
Citizen.CreateThread(function()
	while true do
		local x,y,z = table.unpack(GetEntityCoords(PlayerPedId(),true)) --Gets the XYZ of the player
		local StreetHash = GetStreetNameAtCoord(x, y, z) --Get the street name at XYZ
		local pId = GetPlayerServerId(PlayerId()) --Get the player's ID from the server
		local pName = GetPlayerName(PlayerId()) --Gets the player's name from the server
		Citizen.Wait(15000) --How often should it push this information to discord?
		if StreetHash ~= nil then
			StreetName = GetStreetNameFromHashKey(StreetHash)
			if IsPedOnFoot(PlayerPedId()) and not IsEntityInWater(PlayerPedId()) then
				if IsPedSprinting(PlayerPedId()) then --If the player is sprinting then
					SetRichPresence("ID: "..pId.." | "..pName.." is sprinting down "..StreetName) --Display EX: ID: 6 | DEV | Brown is sprinting down Panorama Dr. 
				elseif IsPedRunning(PlayerPedId()) then --If the player is running then 
					SetRichPresence("ID: "..pId.." | "..pName.." is running down "..StreetName) --Display EX: ID: 6 | DEV | Brown is running down Panorama Dr.
				elseif IsPedWalking(PlayerPedId()) then --If the player is walking then
					SetRichPresence("ID: "..pId.." | "..pName.." is walking down "..StreetName) --Display EX: ID: 6 | DEV | Brown is walking down Panorama Dr.
				elseif IsPedStill(PlayerPedId()) then --If the player is stil then
					SetRichPresence("ID: "..pId.." | "..pName.." is standing on "..StreetName) --Display EX: ID: 6 | DEV | Brown is standing on Panorama Dr.
				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)
				local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
				if MPH > 50 then --If the player is in a vehicle traveling greater than 50MPH then
					SetRichPresence("ID: "..pId.." | "..pName.." is speeding down "..StreetName.." at "..MPH.."MPH in a "..VehName) --Display EX: ID: 6 | DEV | Brown is speeding down Panorama Dr at 67MPH in a Vacca
				elseif MPH <= 50 and MPH > 0 then --If the play is in a vehicle traveling 0<MPH<50 then 
					SetRichPresence("ID: "..pId.." | "..pName.." is cruising down "..StreetName.." at "..MPH.."MPH in a "..VehName) --Display EX: ID: 6 | DEV | Brown is cruising down Panorama Dr at 42MPH in a Vacca
				elseif MPH == 0 then --If the play is in a vehicle stopped then 
					SetRichPresence("ID: "..pId.." | "..pName.." is parked on "..StreetName.." in a "..VehName) --Display EX: ID: 6 | DEV | Brown is parked on Panorama Dr in a Vacca
				end
			elseif IsPedInAnyHeli(PlayerPedId()) or IsPedInAnyPlane(PlayerPedId()) then
				local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
				if IsEntityInAir(GetVehiclePedIsUsing(PlayerPedId())) or GetEntityHeightAboveGround(GetVehiclePedIsUsing(PlayerPedId())) > 5.0 then --Stuff for planes
					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 --stuff for in water
				SetRichPresence("ID: "..pId.." | "..pName.." is swimming")
			elseif IsPedInAnyBoat(PlayerPedId()) and IsEntityInWater(GetVehiclePedIsUsing(PlayerPedId())) then
				local VehName = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))))
				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)

again if someone has a problem with me reposting this please remove it or let me know.
DiscordRP.zip (1.1 KB)


#18

Hello guys . Can you help how to do like the picture above ? Thank you !! https://imgur.com/w6pouL7


#19

Huh? Read the post and it tells you how to do it.