-
Notifications
You must be signed in to change notification settings - Fork 1
Users
Discord SDK: Users
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_Users_GetCurrentUser
- Discord_Users_GetCurrentUserPremiumType
- Discord_Users_GetUser
- Discord_Users_SetCurrentUsername
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: GetCurrentUser
This function fetches information about the currently connected user account.
Syntax:
Discord_Users_GetCurrentUser()
Returns:
Example:
var _struct = Discord_User_GetCurrentUser();
username = _struct.username;
bot = _struct.bot;
userId = _struct.userId;
discriminator = _struct.discriminator;
Discord Function: GetCurrentUserPremiumType
This function gets the Discord_PremiumType for the currently connected user.
Syntax:
Discord_Users_GetCurrentUserPremiumType()
Returns:
Example:
switch(Discord_User_GetCurrentUserPremiumType())
{
case Discord_PremiumType_None:
show_debug_message("User is not a Nitro subscriber");
break;
case Discord_PremiumType_Tier1:
show_debug_message("User has Nitro Classic");
break;
case Discord_PremiumType_Tier2:
show_debug_message("User has Nitro");
break;
}
Discord Function: GetUser
This function gets user information for a given ID.
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_Users_GetUser(userId)
Argument | Type | Description |
---|---|---|
userId | Int64 | Identifier of the user |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
result | Real | The result code of the async request |
type | String | The string "Discord_User_GetUser"
|
user | User | The user data |
Example:
Discord_Users_GetUser(userId);
The code sample above saves the identifier that can be used inside an Social Async Event.
if (async_load[? "type"] == "Discord_User_GetUser")
{
if (async_load[? "result"] == Discord_OK)
{
show_debug_message(async_load[? "type"] + " succeeded!");
show_debug_message(async_load[? "user"]);
}
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: N/A
This function sets the current user's username information.
Syntax:
Discord_Users_SetCurrentUsername(username)
Argument | Type | Description |
---|---|---|
username | String | The new username to be applied to the current user. |
Returns:
N/A
Example:
Discord_User_SetCurrentUsername("SuperUser");
The code sample above will update the current user's username.
Discord Enum: Status Enum
The Status enum represents the online status of a user on Discord.
These constants are referenced by the following structs:
Member | Description |
---|---|
Discord_UserStatus_Offline |
0 The user is offline. |
Discord_UserStatus_Online |
1 The user is online. |
Discord_UserStatus_Idle |
2 The user is idle (i.e., away from keyboard or has been inactive for a certain amount of time). |
Discord_UserStatus_DoNotDisturb |
3 The user is in "do not disturb" mode, indicating that they do not want to be disturbed or receive notifications. |
Discord Enum: PremiumType Enum
The PremiumType enum describes the type of Nitro subscription a user has. It has the following values and descriptions:
These constants are referenced by the following functions:
Member | Description |
---|---|
Discord_PremiumType_None |
0 Not a Nitro subscriber |
Discord_PremiumType_Tier1 |
1 Nitro Classic subscriber |
Discord_PremiumType_Tier2 |
2 Nitro subscriber |
Discord_PremiumType_Tier3 |
3 Nitro Basic subscriber (formerly Nitro) |
Discord Struct: User Structure
This struct stores information about a Discord user.
This struct is referenced by the following functions:
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
userId | Int64 | The unique ID assigned to the user by Discord. |
username | String | The username of the user, which is the name displayed on their profile and in chat messages. |
discriminator | String | The four-digit number that appears after the username, used to distinguish between users with the same username. |
avatar | String | The hash of the user's avatar image. |
bot | Boolean | A boolean value indicating whether the user is a bot account or a human user. |
Discord Struct: Presence Struct
The Presence struct contains information about a user's current online status and activity.
This struct is referenced by the following structs:
Member | Type | Description |
---|---|---|
Status | Discord_UserStatus | The user's current online status. |
Activity | Activity | The user's current activity, if any. |
YoYoGames 2024