Skip to content

Activities

YYBartT edited this page Mar 29, 2023 · 10 revisions

Activities

Functions

Async Event Types

Data Types

Constants



Functions

Back To Top

Discord_Activities_UpdateActivity

Sets a user's presence in Discord to a new activity.

This is an asynchronous function that will trigger the Async Social Event when the task is finished, after which you can use the following functions.

ℹ️ INFO It is possible for users to hide their presence on Discord (User Settings -> Game Activity). Presence set through this SDK may not be visible when this setting is toggled off.

⚠️ IMPORTANT This has a rate limit of 5 updates per 20 seconds.

Syntax

Discord_Activities_UpdateActivity(activityData)
Argument Type Description
activityData ActivityData struct The data to be applied to the user's activity

Returns

N/A

Triggers

Async Social Event of type Discord_Activities_UpdateActivity

Example

Discord_Activity_UpdateActivity({
   state: "Creating Games",
   type: Discord_Activity_Type_Playing,
   details: "Details...",
   smallImage: "mySmallImageName",
   smallText: "mySmallText",
   largeImage: "myLargeImageName",
   largeText: "myLargeText"
});

The code sample above saves the identifier that can be used inside an Async Social Event.

if (async_load[? "type"] == "Discord_Activity_UpdateActivity")
{
    if (async_load[? "result"] == Discord_OK)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed!");
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

Discord_Activities_AcceptInvite

Accepts a game invitation from a given userId.

This is an asynchronous function that will trigger the Async Social Event when the task is finished, after which you can use the following functions.

Syntax

Discord_Activities_AcceptInvite(userId)
Argument Type Description
userId int64 The id of the user who invited you

Returns

N/A

Triggers

Async Social Event of type Discord_Activities_AcceptInvite

Example

Discord_Activities_AcceptInvite(userId);



Back To Top

Discord_Activities_ClearActivity

Clears a user's presence in Discord to make it show nothing.

This is an asynchronous function that will trigger the Async Social Event when the task is finished, after which you can use the following functions.

Syntax

Discord_Activities_ClearActivity()

Returns

N/A

Triggers

Async Social Event of type Discord_Activities_ClearActivity

Example

Discord_Activities_ClearActivity();



Back To Top

Discord_Activities_SendInvite

Sends a game invite to a given user. If you do not have a valid activity with all the required fields, this call will error. See Activity Action Field Requirements for the fields required to have join and spectate invites function properly.

Syntax

Discord_Activities_SendInvite(userId, type, content)
Argument Type Description
userId int64 the id of the user to invite
type ActivityActionType marks the invite as an invitation to join or spectate
content string a message to send along with the invite

Returns

N/A

Triggers

Async Social Event of type Discord_Activities_SendInvite

Example

Discord_Activities_SendInvite(otherUserId, Discord_ActivityActionType_Join, "Come join my awesome game!")



Back To Top

Discord_Activities_SendRequestReply

Sends a reply to an Ask to Join request.

This is an asynchronous function that will trigger the Async Social Event when the task is finished, after which you can use the following functions.

Syntax

Discord_Activities_SendRequestReply(userId, requestReply)
Key Datatype Description
userId int64 The user id of the person who asked to join
reply ActivityJoinRequestReply No, Yes or Ignore

Returns

N/A

Triggers

Async Social Event of type Discord_Activities_SendRequestReply

Example

Discord_Activities_SendRequestReply(otherUserId, Discord_ActivityJoinRequestReply_Yes);



Async Event Types

Back To Top

Discord_Activities_UpdateActivity

Key Datatype Description
type string "Discord_Activities_UpdateActivity"
result real Result code of the async request.
success bool Whether the current request was successful or not.


Back To Top

Discord_Activities_AcceptInvite

Key Datatype Description
type string "Discord_Activities_AcceptInvite"
result real Result code of the async request.
success bool Whether the current request was successful or not.


Back To Top

Discord_Activities_ClearActivity

Key Datatype Description
type string "Discord_Activities_ClearActivity"
result real Result code of the async request.
success bool Whether the current request was successful or not.


Back To Top

Discord_Activities_SendInvite

Key Datatype Description
type string "Discord_Activities_SendInvite"
result real Result code of the async request.
success bool Whether the current request was successful or not.


Back To Top

Discord_Activities_SendRequestReply

Key Datatype Description
type string "Discord_Activities_SendRequestReply"
result real Result code of the async request.
success bool Whether the current request was successful or not.

Data Types

ActivityData

Field Type Description
state string The state of the user activity.
type ActivityType The type of the user activity.
details string The details of the user activity.
smallImage string The user's small image asset value (see Activity Asset Image).
smallText string The user's small image tooltip.
largeImage string The user's larger image asset value (see Activity Asset Image).
largeText string The user's larger image tooltip.

Activity

The Activity struct contains information about a user's current activity, including the application ID, name of the application, current party status, what the player is currently doing, timestamps, assets to display on the player's profile, party information, and secret passwords for joining and spectating the player's game.

Key Datatype Description
applicationId int64 Your application ID. This is a read-only field.
name string Name of the application. This is a read-only field.
state string The player's current party status.
details string What the player is currently doing.
timestamps ActivityTimestamps Helps create elapsed/remaining timestamps on a player's profile.
assets ActivityAssets Assets to display on the player's profile.
party ActivityParty Information about the player's party.
secrets ActivitySecrets Secret passwords for joining and spectating the player's game.
instance bool Whether this activity is an instanced context, like a match.

ActivityTimestamps

The ActivityTimestamps struct is used to create elapsed/remaining timestamps on a player's profile. It contains two fields: Start and End, both of which are Unix timestamps.

Key Datatype Description
startTimestamp int64 Unix timestamp - send this to have an "elapsed" timer
endTimestamp int64 Unix timestamp - send this to have a "remaining" timer

ActivityAssets

The ActivityAssets struct contains assets to display on a player's profile, including both large and small images and corresponding hover text.

Key Datatype Description
largeImage string The key for the large image asset
largeText string The text to display when hovering over the asset
smallImage string The key for the small image asset
smallText string The text to display when hovering over the asset

ActivityParty

The ActivityParty struct contains information about the player's party, including a unique identifier and party size.

Key Datatype Description
partyId string A unique identifier for this party
size Struct.PartySize Info about the size of the party

PartySize

The PartySize struct contains information about the size of a party, including both the current size and maximum possible size.

Key Datatype Description
currentSize int32 The current size of the party.
maxSize int32 The max possible size of the party.

ActivitySecrets

The ActivitySecrets struct contains secret passwords for joining and spectating the player's game, as well as a unique hash for the given match context.

Key Datatype Description
match string unique hash for the given match context
join string unique hash for chat invites and Ask to Join
spectate string unique hash for Spectate button

Constants

Back To Top

Discord_ActivityType

This represents the type of a user activity and is to be used with Discord_Activities_UpdateActivity.

Constant Value Description
Discord_ActivityType_Playing 0 Represents the playing activity type; useful when user is playing games.
Discord_ActivityType_Streaming 1 Represents the streaming activity type; useful when user is streaming on discord, twitch or other platforms.
Discord_ActivityType_Listening 2 Represents the listening activity type; useful when user is listening to music on spotify or other platforms.
Discord_ActivityType_Watching 3 Represents the watching activity type; useful when user is watching their favorite shows.
Discord_ActivityType_Custom 4 Represents any custom activity type
Discord_ActivityType_Competing 5 Represents the competing activity type


Back To Top

Discord_ActivityActionType

This represents the type of activity action and is to be used with Discord_Overlay_OpenActivityInvite.

Constant Value Description
Discord_ActivityActionType_Join 1 Represents the action of joining an activity.
Discord_ActivityActionType_Spectate 2 Represents the action of spectating an activity.


Back To Top

Discord_ActivityJoinRequestReply

The ActivityJoinRequestReply enum provides options for how to respond to a user's request to join an activity.

Constant Value Description
Discord_ActivityJoinRequestReply_No 0 Do not join
Discord_ActivityJoinRequestReply_Yes 1 Join
Discord_ActivityJoinRequestReply_Ignore 2 Ignore the join request


Clone this wiki locally