$addFile[] — File Component
$addFile[] shows a file attached to the message as a component. Discord only displays files that are attached to the same message: attach the file first with $addAttachment[], $fileAttach[] or $attachImage[], then give its name here.
Syntax
$addFile[file;(spoiler);(containerId)]
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
file |
Yes | — | Name of the attached file, for example report.pdf. A value written attachment://report.pdf is accepted too. |
spoiler |
No | no |
yes/true to mark the file as a spoiler, no/false otherwise. An empty value means no; any other value is an error (Expected yes or no, got "..."). |
containerId |
No | — | ID of a container created with $addContainer[id]: the file is placed inside it (Container <id> not found. otherwise). |
Return value
None (empty string). The file component is added to the components of the pending message.
Components V2 message
A file is a rich (Components V2) component. When the message contains one, it is sent as a Components V2 message, which cannot carry text content or embeds: the text of the message and the embeds are not sent. Put any text in a $addTextDisplay[] component instead.
Examples
Attaching and showing a file
$attachment[Sales: 42;report.txt;true]
$addTextDisplay[Here is the requested report]
$addFile[report.txt]
$attachment[...;true] builds the file from a text; $addAttachment[https://example.com/report.pdf;report.pdf] takes it from an address.
Spoiler file inside a container
$addAttachment[https://example.com/ending.png;ending.png]
$addContainer[box]
$addTextDisplay[Warning: ending spoiler!;box]
$addFile[ending.png;yes;box]
A file of the bot
$fileAttach[exports/week-12.csv;week-12.csv]
$addTextDisplay[Export of the week]
$addFile[week-12.csv]
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.