Members
-
Contains the delimiter used for parsing fields with multiple elements
Default:
,
-
An object containing key value pairs where the key is an identifier for the type of information, and the value is a string identifier for the discord.js MessageEmbed object function to call when creating the embed object.
Properties:
Name Type Default Description url
string setURL Function called when setting embed url.
title
string setTitle Function called when setting embed title.
color
string setColor Function called when setting embed color.
author
string setAuthor Function called when setting embed author.
description
string setDescription Function called when setting embed description.
thumbnail
string setThumbnail Function called when setting embed thumbnail.
fields
string addFields Function called when setting embed fields.
image
string setImage Function called when setting embed image.
timestamp
string setTimestamp Function called when setting embed timestamp.
footer
string setFooter Function called when setting embed footer.
-
Contains an object with all key: value pairs for replacers added using
EmbedMD.setGlobalReplacer
.Default:
{}
-
Contains the regexp splitter used to determine newlines
Default:
/\r\n|\n\r|\n|\r/
-
Contains the main splitter used for parsing elements
Default:
#
Methods
-
EmbedMD._parseMD (filename, replacers, log, refresh)EmbedMD~Embed static
-
Name Type Default Description filename
string The file path for the markdown file to parse
replacers
object {} optional Object in format of {replacer: value}
log
boolean false optional Log the embed object to console for debugging?
refresh
boolean false optional Refresh the cache and reload data?
Returns:
Type Description EmbedMD~Embed Data used for future calls to EmbedMD.getEmbed
-
Name Type Description directory
string The directory to scan for .md files
Returns:
Type Description Array.<String> An array of strings each containing a path to a .md file within the given directory. -
A handy dandy helper function to format strings using object properties
Name Type Default Description base_string
string The string to format
replacers_objekt
object {} optional The object with properties to use as replacers.
Returns:
Type Description string The formatted string after using properties from given object as replacers. Example
EmbedMD.format("Hi name!", {name: 'DekiaRPG}); // => "Hi DekitaRPG!"
-
Name Type Default Description md_embed
EmbedMD~Embed An object returned from either
EmbedMD.prepareMD
orEmbedMD.parseDir
replacers
object {} optional The replacer object in format of {replacer: value}
log
boolean false optional Log the embed object to console for debugging?
refresh
boolean false optional Refresh the cache for file and reload data?
Returns:
Type Description MessageEmbed A discord.js message embed object. See discord.js documentation for full object details. -
A helper function to map arrays of strings that contain numbers or booleans to their respective types.
Name Type Description array
array the array to parse
Returns:
Type Description Array.<any> A clone of array with types converted where possible. Example
EmbedMD.parseArray(['1', '5', 'false', 'some description']) // => [1, 5, false, 'some description']
-
EmbedMD.parseDir (directory)Array.<EmbedMD~Embed> static
-
Scans a directory for all .md files within it, then stores each file within an internal cache using its filename as the id.
Name Type Description directory
string The directory to parse for .md files
Returns:
Type Description Array.<EmbedMD~Embed> An array of EmbedMD~Embed
objects for all .md files within given directory. -
EmbedMD.prepareMD (filename, refresh_cache)EmbedMD~Embed static
-
Name Type Default Description filename
string The filename.md to prepare for embed
refresh_cache
boolean false optional Should the cache for this file be refreshed?
Returns:
Type Description EmbedMD~Embed Data used for future calls to EmbedMD.getEmbed
-
Sets a global replacer string.(used for all md embeds)
Name Type Description string
string optional The id string to replace globally with value.
value
string optional The value to be replaced globally.
-
UN-Sets a global replacer string. (used for all md embeds)
Name Type Description string
string optional The id string for the replacer to remove.
Type Definitions
-
An object containing key value pairs where the key is a string identifier, and the value is an object with the properties detailed below:
Properties:
Name Type Description raw
string Contains the raw .md file data.
filename
string Contains the filename for this data.
description
undefined | string Contains the parsed description string.
thumbnail
undefined | string Contains the parsed thumbnail string.
timestamp
undefined | string Contains the timestamp of embed creation.
title
undefined | string Contains the parsed title string.
color
undefined | string Contains the parsed color string.
url
undefined | string Contains the parsed url string.
author
undefined | Array.<string> Contains the parsed author array.
footer
undefined | Array.<string> Contains the parsed footer array.
fields
undefined | Array.<object> Contains the parsed field objects array.