Skip to content
Nikita Krapivin edited this page May 27, 2020 · 10 revisions

Welcome to the NekoPresence wiki, nya~

Here I'm going to explain a set of np_ functions provided by NekoPresence. And also asynchronous events.

I highly recommend you read this page first https://discord.com/developers/docs/rich-presence/how-to#so-how-does-it-work and then return here, in order to understand what are image keys, user ids, etc. (Callbacks are Social Async events in NekoPresence)

Functions

np_initdiscord

np_initdiscord(client_id, autoRegister, steam_id)

(String) client_id - Your Discord app's client/app id

(Bool) autoRegister - whether or not to register an application protocol for your game on the player's computer—necessary to launch games from Discord

(String) steam_id - Your game's Steam ID, pass "0" if none.

Initializes connection with your Discord client. Please call it before calling any other function.

Returns true if initialization was successful, and false if an error occurred.

np_update

np_update()

Updates extension's state, must be called every Step to trigger asynchronous events.

Returns true if operation was successful, and false if an error occurred.

np_setpresence

np_setpresence(state, details, large_image_key, small_image_key)

(String) state - the user's current party status

(String) details - what the player is currently doing

(String) large_image_key - Large Image Key as a string (as in App Assets menu in Discord Devs dashboard)

(String) small_image_key - Small Image Key as a string (as in App Assets menu in Discord Devs dashboard)

Updates player's Rich Presence. To set more information call np_setpresence_more BEFORE this function!

Returns true if operation was successful, and false if an error occurred.

np_setpresence_more

np_setpresence_more(small_image_text, large_image_text, instance)

(String) small_image_text - tooltip for the small_image_key

(String) large_image_text - tooltip for the large_image_key

(Boolean) instance - Currently unused, as this extension doesn't support lobbies yet. (just pass false)

Sets additional info for Rich Presence, must be called BEFORE np_setpresence in order to do anything!

Returns true if operation was successful, and false if an error occurred.

Async Social Events

They're basically the results of Discord-RPC callbacks.

Each event has an event_type key, this is the way how you check for a specific event.

And that's how I'm going to explain these.

DiscordReady

(String) user_id - User's Discord User ID.

(String) discriminator - User's username discriminator.

(String) username - User's username (without discriminator).

(String) avatar - User's avatar id.

DiscordError

(String) error_message - Error message.

(Integer) error_code - Error code.

There are more events but they can't be triggered as this extension doesn't support lobbies yet.

Clone this wiki locally