-
Notifications
You must be signed in to change notification settings - Fork 1
Activities
Discord SDK: Activities
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
- Discord_Activities_UpdateActivity
- Discord_Activities_AcceptInvite
- Discord_Activities_ClearActivity
- Discord_Activities_SendInvite
- Discord_Activities_SendRequestReply
This module offers a collection of structs, which serve as custom data models for organizing and structuring data. Explore the provided structs to better understand the relationships between data elements and simplify your data manipulation tasks.
This module includes a set of predefined constants that can be utilized for various purposes. Browse through the available constants to find values relevant to your needs and enhance the efficiency of your code.
Discord Function: UpdateActivity
This function sets a user's presence in Discord to a new activity.
Note
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.
Warning
This has a rate limit of 5 updates per 20 seconds.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
Discord_Activities_UpdateActivity(activity)
Argument | Type | Description |
---|---|---|
activity | Activity | The data to be applied to the user's activity |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "Discord_Activities_UpdateActivity"
|
result | Real | Result code of the async request. |
success | Boolean | Whether the current request was successful or not. |
Example:
identifier = 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 to differentiate between two requests in the Social Async 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.
Discord Function: AcceptInvite
This function accepts a game invitation from a given userId.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
Discord_Activities_AcceptInvite(userId)
Argument | Type | Description |
---|---|---|
userId | Int64 | The ID of the user who invited you |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "Discord_Activities_AcceptInvite"
|
result | Real | Result code of the async request. |
success | Boolean | Whether the current request was successful or not. |
Example:
Discord_Activities_AcceptInvite(userId);
Discord Function: ClearActivity
This function clears a user's presence in Discord to make it show nothing.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
Discord_Activities_ClearActivity()
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "Discord_Activities_ClearActivity"
|
result | Real | Result code of the async request. |
success | Boolean | Whether the current request was successful or not. |
Example:
Discord_Activities_ClearActivity();
Discord Function: SendInvite
This function 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.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
Discord_Activities_SendInvite(userId, type, content)
Argument | Type | Description |
---|---|---|
userId | Int64 | the ID of the user to invite |
type | Discord_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:
Key | Type | Description |
---|---|---|
type | String | The string "Discord_Activities_SendInvite"
|
result | Real | Result code of the async request. |
success | Boolean | Whether the current request was successful or not. |
Example:
Discord_Activities_SendInvite(otherUserId, Discord_ActivityActionType_Join, "Come join my awesome game!");
Discord Function: SendRequestReply
This function sends a reply to an Ask to Join request.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
Discord_Activities_SendRequestReply(userId, reply)
Argument | Type | Description |
---|---|---|
userId | Int64 | The user ID of the person who asked to join |
reply | Discord_ActivityJoinRequestReply |
Discord_ActivityJoinRequestReply_No , Discord_ActivityJoinRequestReply_Yes or Discord_ActivityJoinRequestReply_Ignore
|
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | The string "Discord_Activities_SendRequestReply"
|
result | Real | Result code of the async request. |
Whether | Boolean | the current request was successful or not. |
Example:
Discord_Activities_SendRequestReply(otherUserId, Discord_ActivityJoinRequestReply_Yes);
Discord Enum: ActivityType Enum
This represents the type of a user activity and is to be used with Discord_Activities_UpdateActivity
.
Member | 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 |
Discord Enum: ActivityActionType Enum
This represents the type of activity action and is to be used with Discord_Overlay_OpenActivityInvite
.
These constants are referenced by the following functions:
Member | Description |
---|---|
Discord_ActivityActionType_Join |
1 Represents the action of joining an activity. |
Discord_ActivityActionType_Spectate |
2 Represents the action of spectating an activity. |
Discord Enum: ActivityJoinRequestReply Enum
This enum provides options for how to respond to a user's request to join an activity.
These constants are referenced by the following functions:
Member | Description |
---|---|
Discord_ActivityJoinRequestReply_No |
0 Do not join |
Discord_ActivityJoinRequestReply_Yes |
1 Join |
Discord_ActivityJoinRequestReply_Ignore |
2 Ignore the join request |
Discord Struct: Activity Struct
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.
This struct is referenced by the following functions:
This struct is referenced by the following structs:
Member | Type | 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 | Boolean | Whether this activity is an instanced context, like a match. |
Discord Struct: ActivityTimestamps Struct
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.
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
startTimestamp | Int64 | Unix timestamp - send this to have an "elapsed" timer |
endTimestamp | Int64 | Unix timestamp - send this to have a "remaining" timer |
Discord Struct: ActivityAssets Struct
The ActivityAssets
struct contains assets to display on a player's profile, including both large and small images and corresponding hover text.
This struct is referenced by the following structs:
Member | Type | 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 |
Discord Struct: ActivityParty Struct
The ActivityParty
struct contains information about the player's party, including a unique identifier and party size.
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
id | String | A unique identifier for this party |
size | PartySize | Info about the size of the party |
Discord Struct: PartySize Struct
The PartySize
struct contains information about the size of a party, including both the current size and maximum possible size.
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
currentSize | Real | The current size of the party. |
maxSize | Real | The max possible size of the party. |
Discord Struct: ActivitySecrets Struct
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.
This struct is referenced by the following structs:
Member | Type | 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 |
YoYoGames 2024