Tagscript

Parsers

Discord specific tags for embeds, cooldowns, permissions and timestamps.

Every parser here except date renders an empty string and records what the template asked for on response.actions. Nothing is sent, deleted or restricted until your bot reads that object and acts.

const response = await ts.run(template, seedVariables);

// response.body is the text. response.actions is the request list.

Available parsers

PageTagsRecords
Embedembedactions.embed
Cooldowncooldown, cdactions.cooldown
Require and denyrequire, deny and their aliasesactions.require, actions.deny
Delete and silentdelete, del, silentactions.deleteMessage, actions.silentResponse
Filesfilesactions.files
Datedate, unix, currenttimeNothing, renders inline

The core built-in parsers work alongside these, so a Discord tag can still use if, random and the rest.

Typing

The plugin declaration-merges IActions, so importing it types the fields above on response.actions without any setup on your side.

import '@tagscript/plugin-discord';

response.actions.embed; // APIEmbed | undefined
response.actions.cooldown; // { cooldown: number; message: string | null } | undefined

Last updated on

On this page

Edit on Github