Skip to content

API reference

This page contains the API reference for JagTag-JS.

JagTagParser (string<String>, args<Object>)

Main parser function. Takes a string and an args object, which will be parsed and the output will be returned.

Edge cases
  • If no string is passed to the parser, undefined will be returned.
  • If there is an unclosed tag within a string, no tags will be parsed in the string until the issue is corrected (String is returned unchanged).
  • If there are no tags within a string, the string is returned unchanged.

A note about the callback parameter

Those who have browsed the source code may have noticed that the parser function also takes a callback parameter. Do not define it unless you willingly want the parser to go haywire. It is used internally to track tag nesting and parse them appropriately; it's not meant to be used by anyone else. Treat it as private.


The args object is required to be passed along to most parsers. It's good practice to pass args object along with every parser call.

Object property reference

Property Description Type Used by Optional?
disabledParsers Parser groups to disable from use. Array<String> Parser Yes
enableLogging Enable logging of exceptions in method calls. If not set, no logging output will be provided. Boolean Parser Yes
tagArgs Additional arguments to pass to certain tags. Array<String> Args Yes
id The ID of the message the tag is in ( String Variables No
author Tag author object (Message). Member Discord No*
channel The current channel (TextChannel). TextChannel Discord No*
guild The current guild (Message.guild). Guild Discord No*
channels Array of all channels in the current guild. (Message.guild.channels). Array<Guild> Discord No*
members Array of all members in the current guild (Message.guild.members). Array<Member> Discord No*

*: If the Discord parser is enabled, these properties must be passed to the parser.


If you don't need certain parser groups, you can disable them with by setting the disabledParsers option in the arguments. The parser groups that can be disabled are args, discord, functional, strings, time and variables.


JagTagParser('string with {upper:tags}', {
  tagArgs: ['arg1', 'arg2'],
  disabledParsers: [ 'time', 'variables' ]
  author: erisAuthorObject,
  channel: erisChannelObject,
  guild: erisGuildObject,
  channels: erisChannelsArray,
  members: erisMembersArray