Skip to content
YYBartT edited this page Mar 30, 2023 · 8 revisions

Users

Functions

Data Types

Async Event TYpes

Constants

Functions

Back To Top

Discord_Users_GetCurrentUser

Fetch information about the currently connected user account.

Syntax

Discord_Users_GetCurrentUser()

Returns

User

Example

struct = Discord_User_GetCurrentUser();
username = struct.username;
bot = struct.bot;
userId = struct.userId;
discriminator = struct.discriminator;



Back To Top

Discord_Users_GetCurrentUserPremiumType

Get the PremiumType for the currently connected user.

Syntax

Discord_Users_GetCurrentUserPremiumType()

Returns

Discord_PremiumType

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;
}



Back To Top

Discord_Users_GetUser

Get user information for a given id.

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_Users_GetUser(userId)
Argument Type Description
userId int64 Identifier of the user

Returns

N/A

Triggers

Async Social Event of type Discord_User_GetUser

Example

Discord_Users_GetUser(userId);

The code sample above save the identifier that can be used inside an Async Social 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.




Back To Top

Discord_Users_SetCurrentUsername

Set the current user's username information.

Syntax

Discord_Users_SetCurrentUsername(name)
Argument Type Description
username string The new username to be applied to the current user.

Returns

String

Example

Discord_User_SetCurrentUsername("SuperUser");

The code sample above will update the current user's username.




Data Types

User

This extension has functions that return a data structure containing information about a Discord user.

Field 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 bool A boolean value indicating whether the user is a bot account or a human user.

Presence

The Presence struct contains information about a user's current online status and activity.

Field Type Description
Status The user's current online status.
Activity Activity The user's current activity, if any.


Async Event Types

Back To Top

Discord_Users_GetUser

Key Datatype Description
result real Result code of the async request
type string "Discord_User_GetUser"
user User The user data



Constants

Back To Top

Discord_PremiumType

The PremiumType enum describes the type of Nitro subscription a user has. It has the following values and descriptions:

Constant Value 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)


Clone this wiki locally