Provides a number of functions for formatting text, cards and decks on Slack using the Slack API and Markdown.
- Source:
Members
(inner) alliances :module
The alliances module is required for calculating the decklist influence total.
Type:
- module
- Source:
(inner) colours :object
The faction colours are loaded from a JSON file.
Type:
- object
- Source:
(inner) headings :Array.<Array.<string>>
Headings used in Decklists, in the order they appear in the decklist output.
Type:
- Array.<Array.<string>>
- Source:
(inner) messages :object
Various text messages conveniently combined into one object.
Type:
- object
- Source:
(inner) packs :Array.<string>|Array.<Array.<string>>
The pack and cycle names are loaded from a JSON file.
Type:
- Array.<string> | Array.<Array.<string>>
- Source:
(inner) stats :Array.<Array.<string>>
An array of pairs of card stats and corresponding emoji, in the order they should appear in card descriptions.
Type:
- Array.<Array.<string>>
- Source:
(inner) thumbsURL :string
The URL where the card thumbnails are hosted, loaded from the environment variable THUMBS_URL
Type:
- string
- Source:
Methods
(inner) cardHelpMessage(command) → {object}
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The Slack command that was used to invoke the help request, used in the examples returned. Can be left blank to invoke the fallback brackets help text. |
- Source:
Returns:
A Slack API message object of a help response message.
- Type
- object
(inner) cardNoHitsMessage(cards) → {string}
Generates a message indicating that cards weren't found, by concatenating the names with commas and 'or'
Parameters:
Name | Type | Description |
---|---|---|
cards |
Array.<string> | An array of card titles that weren't found. |
- Source:
Returns:
A randomized Slack API message object stating that the given cards weren't found.
- Type
- string
(inner) deckHelpMessage(command) → {object}
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The Slack command that was used to invoke the help request, used in the examples returned. |
- Source:
Returns:
A Slack API message object of a help response message.
- Type
- object
(inner) deckNoHitsMessage() → {string}
Generates a message indicating that a deck wasn't found.
- Source:
Returns:
A randomized Slack API message object stating that the deck wasn't found.
- Type
- string
(inner) formatCards(cardsopt, cardsopt) → {object}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cards |
Array.<object> |
<optional> |
The cards to be converted into a Slack message. |
cards |
Array.<object> |
<optional> |
The cards that weren't found and should be mentioned in an error message. |
- Source:
Returns:
A Slack API Message object either containing the cards as attachments or containing an error message that the cards couldn't be found, or both.
- Type
- object
(inner) formatDecklist(decklist) → {object}
Parameters:
Name | Type | Description |
---|---|---|
decklist |
object | The decklist to be converted into a Slack message. |
- Source:
Returns:
A Slack API message object containing the decklist or an error message.
- Type
- object
(inner) formatText(text) → {string}
Replace all the html and nrdb text with the Slack equivalent.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The body of text to convert to Slack formatting. |
- Source:
Returns:
The text, formatted in Slack markdown syntax.
- Type
- string
(inner) formatTitle(title, urlopt) → {string}
Applies Slack markdown formatting to the given title to bolden and optionally apply the link.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
title |
string | The text to display as the title. | |
url |
string |
<optional> |
The URL to link the title to. |
- Source:
Returns:
A string containing the title with Slack markdown formatting applied.
- Type
- string