Skip to content

Relationships

YYBartT edited this page Aug 15, 2024 · 7 revisions

Relationships

Discord SDK: Relationships

Warning

The Game SDK's Relationships functionality has been deprecated by Discord.

Functions

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.

Structs

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.

Constants

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.



Back To Top

Discord_Relationships_Filter

Discord Function: Filter

This function performs a query over the relationships of the current user selection only the ones that match the given type.


Syntax:

Discord_Relationships_Filter(type)
Argument Type Description
type Discord_RelationshipType The type of relationship to filter when performing the query



Returns:

N/A


Example:

Discord_Relationship_Filter(Discord_RelationshipType_Friend);
count = Discord_Relationships_Count();
for(var a = 0 ; a < count ; a++)
{
    var _struct = Discord_Relationships_GetAt(a);
    type = _struct.type;
    username = _struct.username;
    avatar = _struct.avatar;
    id = _struct.id;
    bot = _struct.bot;
    discriminator = _struct.discriminator;
    //Do something each loop with this information..
}



Back To Top

Discord_Relationships_Count

Discord Function: Count

This function gets the number of relationships that match your previous query.


Syntax:

Discord_Relationships_Count()



Returns:

Any


Example:

Discord_Relationships_Filter(Discord_Relationship_Filter_Friend);
count = Discord_Relationships_Count();
for(var a = 0 ; a < count ; a++)
{
    var _struct = Discord_Relationships_GetAt(a);
    type = _struct.type;
    username = _struct.username;
    avatar = _struct.avatar;
    id = _struct.id;
    bot = _struct.bot;
    discriminator = _struct.discriminator;
    //Do something each loop with this information..
}



Back To Top

Discord_Relationships_Get

Discord Function: Get

This function gets the relationship between the current user and a given user by ID.


Syntax:

Discord_Relationships_Get(userId)
Argument Type Description
userId Int64 User identifier



Returns:

Relationship


Example:

var _struct = Discord_Relationships_Get(userId);
type = _struct.type;
username = _struct.username;
avatar = _struct.avatar;
userId = _struct.userId;
bot = _struct.bot;
discriminator = _struct.discriminator;



Back To Top

Discord_Relationships_GetAt

Discord Function: GetAt

This function gets the relationship at a given index when iterating over a list of relationships.

Warning

This function requires a previous call to the function Discord_Relationships_Filter.


Syntax:

Discord_Relationships_GetAt(index)
Argument Type Description
index Any Index of the relationship



Returns:

Relationship


Example:

Discord_Relationships_Filter(Discord_RelationshipType_Friend);
count = Discord_Relationships_Count();
for(var a = 0 ; a < count ; a++)
{
    var _struct = Discord_Relationships_GetAt(a);
    type = _struct.type;
    username = _struct.username;
    avatar = _struct.avatar;
    userId = _struct.id;
    bot = _struct.bot;
    discriminator = _struct.discriminator;

    //Do something each loop with this information..
}



Back To Top

Discord_RelationshipType

Discord Function: RelationshipType Enum

These constants are referenced by the following functions:

These constants are referenced by the following structs:


Member Description
Discord_RelationshipType_None 0 User has no intrinsic relationship on Discord.
Discord_RelationshipType_Friend 1 User is a friend of the connected user, and they can see each other's online status, send direct messages, etc.
Discord_RelationshipType_Blocked 2 User is blocked by the connected user and cannot interact with them on Discord.
Discord_RelationshipType_PendingIncoming 3 User has sent a friend request to the connected user, but it has not yet been accepted.
Discord_RelationshipType_PendingOutgoing 4 Connected user has sent a friend request to the other user, but it has not yet been accepted.
Discord_RelationshipType_Implicit 5 Users are not friends but interact with each other often, based on frequency and recency of interactions.


Back To Top

Relationship

Discord Struct: Relationship Struct

This struct contains information about the user with whom the connected user has a relationship. It includes the type of relationship with the user, the other user's presence and details on the other user. The details on the other user are stored in the user field, which holds a struct with: the username of the user (the name displayed on their profile and in chat messages), the avatar field (the URL of the user's avatar image), the userId field (the unique user ID assigned by Discord), the bot field (a boolean value indicating whether the user is a bot account or a human user) and the discriminator field (contains the four-digit number that appears after the username, used to distinguish between users with the same username).

Here is a table summarizing the fields in the "relationship" structure and their meanings:

This struct is referenced by the following functions:


Member Type Description
type Discord_RelationshipType The username of the user, which is the name displayed on their profile and in chat messages.
user User The user the relationship is for.
presence Presence That user's current presence