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

Users 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.




Clone this wiki locally