ZeroK-RTS / Chobby

Spring RTS Ingame lobby project
17 stars 38 forks source link

Fill discord rich presence #433

Open Licho1 opened 6 years ago

Licho1 commented 6 years ago

Wrapper now provides full discord-rpc API clone. Use it to fill information about current game and implement spectate/join buttons.

Refer to discord dev docs about rich presence.

GoogleFrog commented 6 years ago

State is done as well as seems possible at the moment. I don't see how spectate/join is meant to work https://github.com/ZeroK-RTS/Chobby/commit/626d51bf12a9145ee2ee886a6b7d22b9e87a184b

Licho1 commented 6 years ago

Please read docs here https://discordapp.com/developers/docs/rich-presence/how-to I don't think you are the sort of person that would benefit from me retelling you the story. The API you get in LUA is 1:1 full exact copy to avoid confusion.

But in a nutshell, you set it up by sending joinSecret, or spectateSecret in update presence. Then when someone is going to spectate you (click stuff in discord) he will receive the spectate event with the same secret.

So in our case, secret could be either a) name of the host b) spring ip and port

Also another thing to do is images .. we should upload images where they are interesting, like important minimaps so that we could show them in discord.

GoogleFrog commented 5 years ago

[ChobbyMessage]
    [System.Serializable]
    public struct DiscordUpdatePresence
    {
        public string state; /* max 128 bytes */
        public string details; /* max 128 bytes */
        public long startTimestamp;
        public long endTimestamp;
        public string largeImageKey; /* max 32 bytes */
        public string largeImageText; /* max 128 bytes */
        public string smallImageKey; /* max 32 bytes */
        public string smallImageText; /* max 128 bytes */
        public string partyId; /* max 128 bytes */
        public int partySize;
        public int partyMax;
        public string matchSecret; /* max 128 bytes */
        public string joinSecret; /* max 128 bytes */
        public string spectateSecret; /* max 128 bytes */
        public bool instance;
    }
GoogleFrog commented 5 years ago

image