Tagscript

EmbedParser

The embed tag creates Discord embeds that can be sent along with messages. There are two ways to use the embed tag: either by using properly formatted embed JSON or by manually inputting the accepted embed properties.

Usage

import { Interpreter } from 'tagscript';
import { EmbedParser } from '@tagscript/plugin-discord';
const ts = new Interpreter(new EmbedParser());
const { Interpreter } = require('tagscript');
const { EmbedParser } = require('@tagscript/plugin-discord');
const ts = new Interpreter(new EmbedParser());

API

Check EmbedParser for the API documentation.

For End Users

Syntax

Using JSON:

{embed:json}

Using properties:

{embed(property):value}

Examples

JSON Format:

{embed:{"title": "Hello!", "description": "This is a test embed."}}
{embed:{
    "title": "Here's a random duck!",
    "image": {"url": "https://random-d.uk/api/randomimg"},
    "color": 15194415
}}

Property Format:

{embed(color):0x37b2cb}
{embed(title):Rules}
{embed(description):Follow these rules to ensure a good experience in our server!}
{embed(field):Rule 1|Respect everyone you speak to.|false}
{embed(author):Author Name}
{embed(thumbnail):https://example.com/image.png}
{embed(footer):Footer text}
{embed(timestamp):true}

Available Properties

  • title - The embed title
  • description - The embed description
  • color - The embed color (hex code or number)
  • author - The embed author name
  • thumbnail - URL for the thumbnail image
  • image - URL for the main image
  • footer - The footer text
  • timestamp - Set to true to add current timestamp
  • field - Add a field with format: name|value|inline

Field Format

Fields use the format: {embed(field):name|value|inline}

  • name - The field name
  • value - The field value
  • inline - true or false for inline display

Notes

  • Multiple embed tags in the same TagScript will merge properties
  • Color values can be hex codes (0x37b2cb) or decimal numbers
  • JSON format allows for more complex embed structures
  • Developers need to construct the embed builder with the parser output

Developer Example

import { Interpreter } from 'tagscript';
import { EmbedParser } from '@tagscript/plugin-discord';
import { EmbedBuilder } from 'discord.js';

const ts = new Interpreter(new EmbedParser());
const result = await ts.run('{embed:{"title": "Hello!", "description": "This is a test embed."}}');

// You might need to modify the embed object before passing to EmbedBuilder
const embed = new EmbedBuilder(result.actions.embed);

Last updated on