Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
API.Discord Class Reference

Discord integration functions. More...

Public Member Functions

integer Init (string applicationID)
 Initializes Discord integration.
void UpdateRichPresence (string details, string state, string largeImageKey, string smallImageKey)
 Updates Discord Rich Presence.
void UpdateRichPresence (string details, string state, string largeImageKey, integer startTime)
 Updates Discord Rich Presence.
void UpdateRichPresence (string details, string state, string largeImageKey, string smallImageKey, integer startTime)
 Updates Discord Rich Presence.
void SetActivityDetails (string details)
 Sets the first line of text of the activity.
void SetActivityState (string details)
 Sets the second line of text of the activity.
void SetActivityLargeImage (string largeImageKey, string largeImageText)
 Sets the image (and optionally) the hover text of the large image asset.
void SetActivitySmallImage (string smallImageKey, string smallImageText)
 Sets the image (and optionally) the hover text of the small image asset.
void SetActivityElapsedTimer (integer timestamp)
 Sets the elapsed timer of the activity.
void SetActivityRemainingTimer (integer timestamp)
 Sets the remaining timer of the activity.
void SetActivityPartySize (integer currentSize, integer maxSize)
 Sets the current party size (and optionally) the max party size of the activity.
void UpdateActivity (string details)
 Updates the user's presence.
string GetCurrentUsername ()
 Gets the current user's username.
string GetCurrentUserID ()
 Gets the current user's ID.
void GetCurrentUserAvatar (integer size, function callback)
 Gets the current user's avatar.

Detailed Description

Discord integration functions.

They require the Game SDK library to be present.

Member Function Documentation

◆ GetCurrentUserAvatar()

void API.Discord.GetCurrentUserAvatar ( integer size,
function callback )

Gets the current user's avatar.

The callback function must have two parameters: responseCode and image. responseCode receives the API response code, and image receives an Image if the operation succeeded, or null if it failed. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
sizeThe size of the avatar to fetch. Must be one of: 16, 32, 64, 128, 256, 512, 1024
callbackThe callback to execute.

◆ GetCurrentUserID()

string API.Discord.GetCurrentUserID ( )

Gets the current user's ID.

This returns null if the integration hasn't received the user's information yet. The integration must have been initialized with API.Discord.Init before calling this.

Returns
Returns a string value, or null.

◆ GetCurrentUsername()

string API.Discord.GetCurrentUsername ( )

Gets the current user's username.

This returns null if the integration hasn't received the user's information yet. The integration must have been initialized with API.Discord.Init before calling this.

Returns
Returns a string value, or null.

◆ Init()

integer API.Discord.Init ( string applicationID)

Initializes Discord integration.

Parameters
applicationIDThe Discord Application ID. This will have needed to be created via the Discord Developer Portal.
Returns
Returns an API response code.

◆ SetActivityDetails()

void API.Discord.SetActivityDetails ( string details)

Sets the first line of text of the activity.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe first line of text in the Rich Presence.

◆ SetActivityElapsedTimer()

void API.Discord.SetActivityElapsedTimer ( integer timestamp)

Sets the elapsed timer of the activity.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
timestampA Unix timestamp of when the timer started. If 0, the timer is disabled.

◆ SetActivityLargeImage()

void API.Discord.SetActivityLargeImage ( string largeImageKey,
string largeImageText )

Sets the image (and optionally) the hover text of the large image asset.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
largeImageKeyThe internal name of the large image asset to display, created via the Discord Developer Portal.
largeImageTextThe hover text of the large image.

◆ SetActivityPartySize()

void API.Discord.SetActivityPartySize ( integer currentSize,
integer maxSize )

Sets the current party size (and optionally) the max party size of the activity.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
currentSizeThe current size of the party.
maxSizeThe max size of the party.

◆ SetActivityRemainingTimer()

void API.Discord.SetActivityRemainingTimer ( integer timestamp)

Sets the remaining timer of the activity.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
timestampA Unix timestamp of when the timer will end. If 0, the timer is disabled.

◆ SetActivitySmallImage()

void API.Discord.SetActivitySmallImage ( string smallImageKey,
string smallImageText )

Sets the image (and optionally) the hover text of the small image asset.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
smallImageKeyThe internal name of the small image asset to display, created via the Discord Developer Portal.
smallImageTextThe hover text of the small image.

◆ SetActivityState()

void API.Discord.SetActivityState ( string details)

Sets the second line of text of the activity.

This doesn't update the user's presence; you must call API.Discord.UpdateActivity. The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe second line of text, appearing below details.

◆ UpdateActivity()

void API.Discord.UpdateActivity ( string details)

Updates the user's presence.

The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe first line of text in the Rich Presence.

◆ UpdateRichPresence() [1/3]

void API.Discord.UpdateRichPresence ( string details,
string state,
string largeImageKey,
integer startTime )

Updates Discord Rich Presence.

The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe first line of text in the Rich Presence.
stateThe second line of text, appearing below details.
largeImageKeyThe internal name of the large image asset to display, created via the Discord Developer Portal.
startTimeA Unix timestamp of when the activity started. If 0, the timer is disabled.

◆ UpdateRichPresence() [2/3]

void API.Discord.UpdateRichPresence ( string details,
string state,
string largeImageKey,
string smallImageKey )

Updates Discord Rich Presence.

The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe first line of text in the Rich Presence.
stateThe second line of text, appearing below details.
largeImageKeyThe internal name of the large image asset to display, created via the Discord Developer Portal.
smallImageKeyThe internal name of the small image asset to display, also created via the Discord Developer Portal.

◆ UpdateRichPresence() [3/3]

void API.Discord.UpdateRichPresence ( string details,
string state,
string largeImageKey,
string smallImageKey,
integer startTime )

Updates Discord Rich Presence.

The integration must have been initialized with API.Discord.Init before calling this.

Parameters
detailsThe first line of text in the Rich Presence.
stateThe second line of text, appearing below details.
largeImageKeyThe internal name of the large image asset to display, created via the Discord Developer Portal.
smallImageKeyThe internal name of the small image asset to display, also created via the Discord Developer Portal.
startTimeA Unix timestamp of when the activity started. If 0, the timer is disabled.