Helper functions for managing the SQLite database
- Source:
Members
(static) locateMessageMaps
- Source:
Looks up all the rows associated with the given Slack Message ID and returns it
(static) messageMap
- Source:
Stores the ID pairs for Slack Messages and Discord Messages (Warning: The function is very much fire and forget. It may also be asynchronous so changes won't be made instantly. Use the callback if you need something to run after it finished or to check to see if it is successful)
(static) startup
- Source:
Starts up the database and sets it up if it does not already exist. Promise resolves once this is complete.
(static) Tables :Object
- Source:
Immutable object containing the names of the SQL tables
Type:
- Object
Methods
(inner) locateChannelMap(SlackChannelID) → {Promise.<string>}
- Source:
Returns the Discord channel id linked with the SlackChannelID passed into this function from the ChannelMap table
Parameters:
Name | Type | Description |
---|---|---|
SlackChannelID |
string | Timestamp of the Slack channel |
Returns:
Returns the matching Discord channel's ID if found
- Type
- Promise.<string>
(inner) locateMessageMaps(SlackMessageID) → {Promise.<Array.<Object>>}
- Source:
Returns all rows from the MessageMap table with the matching SlackMessageID
Parameters:
Name | Type | Description |
---|---|---|
SlackMessageID |
string | Timestamp of the Slack message |
Returns:
Array of rows with the matching SlackMessageID or an empty array
- Type
- Promise.<Array.<Object>>
(inner) locateThreadMap(SlackThreadID) → {Promise.<string>}
- Source:
Returns the Discord thread id equivalent from the ThreadMap table of the matching SlackThreadID
Parameters:
Name | Type | Description |
---|---|---|
SlackThreadID |
string | Timestamp of the thread's main/original message |
Returns:
Returns the matching Discord thread's ID if found
- Type
- Promise.<string>
(inner) messageMap(data) → {Promise}
- Source:
Add a new entry to the database to link together Discord Message IDs with Slack Message IDs
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | Object containing all the keys to add to the table. All properties are mandatory Properties
|
Returns:
Resolves after inserting the new row
- Type
- Promise
(inner) tableLocateMap(SelectProperty, tableName, WhereProperty, SlackObjectID) → {Promise.<Array.<Object>>}
- Source:
Helper function that returns all rows from a table with a specific name where a specific property has a specific value
WARNING: SQL Injection possible for all parameters except SlackObjectID. Do NOT take user input for this function for all properties except SlackObjectID
Parameters:
Name | Type | Description |
---|---|---|
SelectProperty |
string | Property from table to return from each row. Use '*' to match all |
tableName |
string | Table to search (Must contain property) |
WhereProperty |
string | Property to compare with value |
SlackObjectID |
string | Value to find in table |
Returns:
Returns matching rows with the selected property
- Type
- Promise.<Array.<Object>>
(inner) tableMap(tableName, SlackObjectID, DiscordObjectID) → {Promise}
- Source:
Inserts a new row into a table pairing the Slack and Discord IDs together if they are not duplicates
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string | Name of table to add to |
SlackObjectID |
string | An ID from Slack's end |
DiscordObjectID |
string | An ID from Discord's end |
Returns:
Resolves once the query completes
- Type
- Promise