-
Notifications
You must be signed in to change notification settings - Fork 1
Activities
- Discord_Activities_UpdateActivity
- Discord_Activities_AcceptInvite
- Discord_Activities_ClearActivity
- Discord_Activities_SendInvite
- Discord_Activities_SendRequestReply
- Discord_Activities_UpdateActivity
- Discord_Activities_AcceptInvite
- Discord_Activities_ClearActivity
- Discord_Activities_SendInvite
- Discord_Activities_SendRequestReply
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.
Discord_Activities_UpdateActivity(activityData)
Argument | Type | Description |
---|---|---|
activityData | Activity struct | The data to be applied to the user's activity |
N/A
Async Social Event of type
Discord_Activities_UpdateActivity
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.
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.
Discord_Activities_AcceptInvite(userId)
Argument | Type | Description |
---|---|---|
userId | int64 | The id of the user who invited you |
N/A
Discord_Activities_AcceptInvite(userId);
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.
Discord_Activities_ClearActivity()
N/A
Discord_Activities_ClearActivity();
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.
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 |
N/A
Discord_Activities_SendInvite(otherUserId, Discord_ActivityActionType_Join, "Come join my awesome game!")
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.
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 |
N/A
Async Social Event of type
Discord_Activities_SendRequestReply
Discord_Activities_SendRequestReply(otherUserId, Discord_ActivityJoinRequestReply_Yes);
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. |
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. |
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. |
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. |
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. |
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. |
The ActivityTimestamps
struct is used to create elapsed/remaining timestamps on a player's profile. It contains two fields: startTimestamp
and endTimestamp
, 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 |
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 |
The ActivityParty
struct contains information about the player's party, including a unique identifier and party size.
Key | Datatype | Description |
---|---|---|
id | string | A unique identifier for this party |
size | Struct.PartySize | Info about the size of the party |
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. |
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 |
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 |
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. |
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 |
YoYoGames 2024