Skip to content
Files fileSaveURL

$fileSaveURL[]

$fileSaveURL downloads the file found at an address and stores it in the files of the bot, like $fileUpload does for a text. Use it to keep an attachment or an upload before its Discord link expires.

Syntax

bdfd
$fileSaveURL[path;url;(contentType)]

Parameters

Parameter Description
path Required. Logical path such as uploads/report.pdf (same rules as $fileUpload). Writing to an existing path replaces the file.
url Required. An http or https address. Private and local addresses are refused on hosted bots.
contentType Optional. MIME type to store. By default the type the server announces.

Errors

  • file_invalid_url: the address is not an http(s) address, or it is not allowed.
  • file_download_failed: the server did not answer with the file (error, timeout, too many redirections).
  • file_too_large: the file is larger than 25 MB (the download limit of this function).
  • file_invalid_path, file_quota_exceeded, files_unavailable: same as $fileUpload.

Examples

$fileSaveURL[uploads/$authorID.pdf;$input[document]]
Saved. Link: $fileURL[uploads/$authorID.pdf;permanent]

In JavaScript: await bc.files.saveFromUrl('uploads/a.pdf', url).

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.