Skip to content
Components & Interactions addImageUpload

$addImageUpload

$addImageUpload adds a single image upload field to the modal being built with $newModal[]. It is a shortcut for $addModalFileUpload[] limited to one file.

Syntax

$addImageUpload[fieldID;label;(description);(required)]

Parameters

Parameter Description
fieldID Required. The custom ID of the field, read with $input[] or $saveUploadedImage[].
label Required. Text shown above the field.
description Optional. Text shown under the label.
required Optional. yes (default) or no.

Reading the image

When the modal is submitted, $input[fieldID] returns the link of the file. This link comes from Discord and stops working after 24 hours. $saveUploadedImage[fieldID] checks that the file really is an image (PNG, JPEG, GIF or WebP), stores it in the files of the bot and returns a link that does not expire.

Discord lets the user pick any file in an upload field: check the result of $saveUploadedImage[] with $try.

Example

$newModal[profile;Your profile]
$addModalTextInput[Name;;name]
$addImageUpload[avatar;Your picture;PNG, JPEG, GIF or WebP;no]

Try it

Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.