Skip to content

GMRPC functions

Sa_Ko edited this page Jan 12, 2022 · 4 revisions

gmrpc_init(intAPPID)

Call this function before anything else discord related. This will allocate the callback handlers in the dll.

Returns: boolean value: Successful or not, plus: Triggers a callback EVENT_OTHER_SOCIAL, aka Asynchronous -> Social Event

Read from the callback:

The ds map in social event is called async_load and can be accessed like a "normal" dsmap

Key Value
"event_type" "GMRPC_READY"
"user_id" The User's ID
"username" The Username
"discriminator" The 4 Digit Number
"avatar" The hash of the User's avatar

For example, to get the User's name: In Async Social Event:

show_debug_message(async_load[?"username"])

gmrpc_setStarttime(int timeSinceEpoch)

Call this function when you want to display "Playing since" on the profile. The time passed to this is seconds since epoch. In Gamemaker, you can use

var diff = date_second_span(date_create_datetime(1970,1,1,1,0,0), date_current_datetime());
show_debug_message(diff)
gmrpc_setStarttime(diff)

to get the seconds since epoch and now. Don't forget to call gmrpc_setPresence to actually set the presence.


gmrpc_setEndtime(int timeSinceEpoch)

Call this function when you want to display "Time left" on the profile. Time time passed is seconds since epoch.


gmrpc_setPresence(string state, string details, string largeKey, string smallKey)

This sets the overall presence.

parameter description
State is the state text displayed on the user's profile
Details are the details displayed on the user's profile
largeImage is the large image displayed on the user's profile
smallImage is the small image in the bottom right corner of the large image

gmrpc_clear()

Resets the discord presence.


gmrpc_exit()

Exits the dll. You have to call init again after this. Current isssue: Please only call this on GAME END! Otherwise, it will break the dll.