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 titledescription
- The embed descriptioncolor
- The embed color (hex code or number)author
- The embed author namethumbnail
- URL for the thumbnail imageimage
- URL for the main imagefooter
- The footer texttimestamp
- Set totrue
to add current timestampfield
- Add a field with format:name|value|inline
Field Format
Fields use the format: {embed(field):name|value|inline}
name
- The field namevalue
- The field valueinline
-true
orfalse
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