Skip to content

Overlay

YYBartT edited this page Aug 15, 2024 · 6 revisions

Overlay

Discord SDK: Overlay

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.



Back To Top

Discord_Overlay_OpenActivityInvite

Discord Function: OpenActivityInvite

This function opens the overlay modal for sending game invitations to users, channels, and servers. If you do not have a valid activity with all the required fields, this call will error. See Activity Action Field Requirements for the fields required to have join and spectate invites function properly.


Syntax:

Discord_Overlay_OpenActivityInvite(value)
Argument Type Description
value Discord_ActivityActionType What type of invite to send



Returns:

N/A


Example:

Discord_Overlay_OpenActivityInvite(Discord_ActivityActionType_Spectate);

The code sample above triggers an activity invite overlay that can be listened for inside an Social Async Event.

if (async_load[? "type"] == "Discord_Overlay_OpenActivityInvite")
{
    if (async_load[? "result"] == Discord_OK)
    {
        show_debug_message("succeeded!");
    }
    else
    {
        show_debug_message("failed!");
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

Discord_Overlay_IsEnabled

Discord Function: IsEnabled

This function checks whether the user has the overlay enabled or disabled. If the overlay is disabled, all the functionality in this manager will still work. The calls will instead focus the Discord client and show the modal there instead.


Syntax:

Discord_Overlay_IsEnabled()



Returns:

Boolean


Example:

var _overlay_is_enabled = Discord_Overlay_IsEnabled();



Back To Top

Discord_Overlay_IsLocked

Discord Function: IsLocked

This function checks if the overlay is currently locked or unlocked.


Syntax:

Discord_Overlay_IsLocked()



Returns:

Boolean


Example:

var _overlay_is_locked = Discord_Overlay_IsLocked();



Back To Top

Discord_Overlay_OpenGuildInvite

Discord Function: OpenGuildInvite

This function opens the overlay modal for joining a Discord guild, given its invite code.

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_Overlay_OpenGuildInvite(code)
Argument Type Description
code String The server invitation code



Returns:

N/A


Triggers:

Social Async Event

Key Type Description
result Real The result code of the async request
type String The string "Discord_Overlay_OpenGuildInvite"

Example:

identifier = Discord_Overlay_OpenGuildInvite();

The code above saves the identifier that can be used inside an Social Async Event.

if (async_load[? "identifier"] == identifier)
if (async_load[? "type"] == "Discord_Overlay_OpenGuildInvite")
{
    if (async_load[? "status"] == Discord_OK)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

Discord_Overlay_OpenVoiceSettings

Discord Function: OpenVoiceSettings

This function opens the overlay widget for voice settings for the currently connected application. These settings are unique to each user within the context of your application. That means that a user can have different favorite voice settings for each of their games!

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_Overlay_OpenVoiceSettings()



Returns:

N/A


Triggers:

Social Async Event

Key Type Description
result Real The result code of the async request
success Boolean Whether the request was successful
type String The string "Discord_Overlay_OpenVoiceSettings"

Example:

identifier = Discord_Overlay_OpenVoiceSettings();

The code sample above saves the identifier that can be used inside an Social Async Event.

if (async_load[? "type"] == "Discord_Overlay_OpenVoiceSettings")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == Discord_OK)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

Discord_Overlay_SetLocked

Discord Function: SetLocked

This function locks or unlocks input in the overlay. Calling Discord_Overlay_SetLocked(true) will also close any modals in the overlay or in-app from things like IAP purchase flows and disallow input.

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_Overlay_SetLocked(value)
Argument Type Description
value Boolean Whether to lock (true) or unlocked (false) the overlay



Returns:

Real


Triggers:

Social Async Event

Key Type Description
id Real The asynchronous request ID
type String The string "Discord_Overlay_SetLocked"

Example:

identifier = Discord_Overlay_SetLocked();

The code above saves the identifier that can be used inside an Social Async Event.

if (async_load[? "type"] == "Discord_Overlay_SetLocked")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == Discord_OK)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}