Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
560 stars 93 forks source link

Is it possible to set an image from http URL ? #174

Closed Ombrelin closed 2 years ago

Ombrelin commented 2 years ago

I see in the documentation that you can set an image on the rich presence using a asset id, but is possible to dynamically set an image from its URL ? If yes, how ?

Lachee commented 2 years ago

No you cannot, its a limitation on Discords end. You can only upload from the discord developer dashboard and use the id assigned there.

Edit: This is now possible

Ombrelin commented 10 months ago

Hi, actually it seems that this should be possible : 
https://www.reddit.com/r/discordapp/comments/rndazc/discord_finally_enabled_the_ability_to_load_rich/
Also a few library allow it, like for instance : https://github.com/EthanC/Perplex

However, using DiscordRpcCsharp, I tried to put my http url in the LargeImageKey field and it doesn't work.

Lachee commented 10 months ago

This issue is now out of date and since my previous message it has become possible to use image urls. My library has updated its documentation to reflect this fact.

However note that the URL in question must still fit within the 256 byte limitation of the LargeImageKey and must be publically accessible to Discord. If you are trying to use a host like Imgur, you might have some issues.

I can confirm this works as i have a open PR for OSU that implements this: https://github.com/ppy/osu/pull/24380/files#diff-a481dc7b726fa59909f0be8ec805a5f075aaa975d5d3efe773b373fce53a9ce5R126

Ombrelin commented 10 months ago

Thanks for the detailed answer !
I just checked the size of my urls (those are PLEX thumbnail urls), and despite them being only 202 bytes long, the image is not displayed :thinking:

Would you have any clue of what I am doing wrong ? 

        return new RichPresence
        {
            Details = $"♫ {session.MediaTitle}",
            State = $"{playerState} {session.MediaGrandParentTitle}",
            Timestamps = new Timestamps
            {
                End = endTimeStamp
            },
            Assets = new Assets()
            {
                LargeImageKey = session.Thumbnail
            }
        };