DiscordManager

DiscordManager

Handles all things related to the Discord end of things. Most functions take in a specific subtype of SyntaxTree
Meant to be a static class (Do not initialize members of this class)

Constructor

new DiscordManager()

Source:

Members

attachableFormats :Array.<string>

Source:

Array containing a list of formats that Discord embeds consider attachable.
Files with these extensions are sent in embeds instead of by themselves.
Audio extensions removed from attachable formats because they automatically embed themselves (Wow flac files are huge!)
Video formats removed from attachable formats because they automatically embed themselves then fail to load (Still available via "Open Original" download link though)
Type gif was removed because they don't work in embeds for some reason. Also, gifv technically is not real.

Type:
  • Array.<string>

client :Discord.Client

Source:

The Discord bot client being used by the manager. Remember to call start() before using

Type:
  • Discord.Client

LoggingGuild :Discord.Guild

Source:

Discord Server/Guild to log messages into

Type:
  • Discord.Guild

Methods

(static) embedFromFile(file, templateEmbed) → {Object}

Source:

Converts a file object from a Syntax Tree into an embed

Parameters:
Name Type Description
file FileData

Data about the file to convert into an embed

templateEmbed Discord.MessageEmbed

Blank embed that the file will be added onto. Set colors, timestamps, and more before passing it into this function

Returns:

Final Discord message payload. Contains two arrays: embeds which should be sent first and files which should be sent after

Type
Object

(static) embedFromSyntaxTree(syntaxTree)

Source:

Does not handle attachments. Only top level data (depth of 1) for a syntax tree AKA the main embed

Parameters:
Name Type Description
syntaxTree SyntaxTreeBase

A SyntaxTreeBase or anything extending it that can be used to create a blank embed (Sets colors, author, timestamp, and text)

(async, static) fakeMessage(threadID, syntaxTreeBase, syntaxTreeMessageSkeleton) → {string}

Source:

Creates and sends out a fake message and links it to a Slack Message. Used when creating threads without an existing starting point on the Discord end

Parameters:
Name Type Description
threadID string

ID for the thread that the fake message is for

syntaxTreeBase MessageSyntaxTree

Syntax tree for the next message in the thread

syntaxTreeMessageSkeleton MessageSyntaxTree

An empty syntax tree to use for the fake message

Returns:

Returns the DiscordMessageID of the fake message (Now the starting point of a thread)

Type
string

(async, static) handleChanges(syntaxTree) → {Promise}

Source:

Handles reflecting edits/changes on Discord

Parameters:
Name Type Description
syntaxTree ChangeSyntaxTree

Syntax tree with edits to parse and send. Mostly identical to MessageSyntaxTree

Returns:

Resolves when messages have been successfully sent/edited

Type
Promise

(async, static) handleChannelUpdates(syntaxTree) → {Promise}

Source:

Handles reflecting channel metadata updates on Discord

Parameters:
Name Type Description
syntaxTree ChannelSyntaxTree

Syntax tree with channel metadata. It's literally the same as the base syntax tree class

Returns:

Resolves when channel data has been updated

Type
Promise

(async, static) handleDeletes(syntaxTree) → {Promise}

Source:

Handles reflecting message deletions on Discord. Safely ignores messages that cannot be found

Parameters:
Name Type Description
syntaxTree DeleteSyntaxTree

Syntax tree with information about what messages to delete

Returns:

Resolves when messages have been successfully deleted

Type
Promise

(async, static) handleMessages(syntaxTree) → {Promise}

Source:

Handles sending messages to Discord

Parameters:
Name Type Description
syntaxTree MessageSyntaxTree

Syntax tree to parse and send

Returns:

Resolves when messages have been successfully sent

Type
Promise

(async, static) locateThread(syntaxTree, channel) → {Discord.ThreadChannel}

Source:

Finds a specific thread channel given information about it and the main channel it should be in. Creates one if it does not exist

Parameters:
Name Type Description
syntaxTree SyntaxTreeBase

Syntax tree containing the thread id to look up

channel Discord.TextChannel

Discord channel to find or make thread channel in

Returns:

Returns the located thread channel

Type
Discord.ThreadChannel

(static) syntaxTreeParseText(syntaxTree) → {string}

Source:

Converts text from Slack Markdown to Discord Markdown

Parameters:
Name Type Description
syntaxTree SyntaxTreeBase

Syntax tree to fetch message from

Returns:

Parsed message. Returns a default string if there is no message

Type
string