Skip to content
YYBartT edited this page Aug 15, 2024 · 6 revisions

Images

Discord SDK: Images

Warning

The Game SDK's Images functionality has been deprecated by Discord.

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_Images_Fetch

Discord Function: Fetch

This function prepares an image to later retrieve data about it.

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_Images_Fetch(userId, size)
Argument Type Description
userId Int64 The ID of the user whose avatar you want to get.
size Real The resolution at which you want the image (needs to be a power of 2)



Returns:

N/A


Triggers:

Social Async Event

Key Type Description
type String "Discord_Images_Fetch"
result Real Result code of the async request.
success Boolean Whether the current request was successful or not.
userId Int64 The ID of the user whose avatar you requested.
width Real The width of the avatar image
height Real The height of the avatar image
buffer Buffer A buffer containing the avatar image data.

Example:

/// Create Event
Discord_Images_Fetch(userId, 64);

/// Async Event
if(async_load[?"result"] != Discord_OK)
{
    exit;
}

switch(async_load[?"type"])
{
    case "Discord_Images_Fetch":

        // If user ids don't match bail
        if (userId != async_load[?"userId"]) exit;

        var buffer = async_load[?"buffer"];

        surf = surface_create(async_load[?"width"], async_load[?"height"]);
        buffer_set_surface(buffer, surf, 0);

        buffer_delete(buffer);
        break;
}


Clone this wiki locally