Tagscript

FilesParser

Attach files to the reply by URL.

files lists URLs to send as attachments. The list lands on response.actions.files.

For template authors

Syntax

{files:url,url,...}

Separate URLs with ~ or ,.

Examples

{files:https://example.com/a.png,https://example.com/b.png}

For developers

Register the parser

import { FilesParser } from '@tagscript/plugin-discord';
import { Interpreter } from 'tagscript';

const ts = new Interpreter(new FilesParser());

Behaviour

The payload is required. parse splits it with the exported split(payload, true) helper and sets ctx.response.actions.files to the resulting array, then returns an empty string.

The array holds raw strings from a template. Nothing checks that they are URLs, that the host is one you trust, or that the file is a reasonable size. Passing them to your Discord library unchecked makes your bot fetch whatever a template author names, including addresses on your own network. Match them against an allowlist of hosts before you send.

const files = (response.actions.files ?? []).filter(isAllowedAttachmentUrl);

API reference

FilesParser

Last updated on

On this page

Edit on Github