Methods
(inner) addOwn(uid, type, target, flag)
Takes information about a new own achievement and adds it to our records.
Parameters:
Name | Type | Description |
---|---|---|
uid |
number | The ID of the user associated with the achievement. |
type |
string | A string value describing the thing / milestone owned, e.g. "root", "user", "challenge", "endgame", "akerva" etc. |
target |
number | string | If a machine user/system own, use the numeric machine ID (e.g. 238). If a challenge or fortress own, use the title. |
flag |
string | For pro labs and fortresses with multiple flags, use this field to specify the milestone title. |
(inner) andifyList(str) → {string}
Converts a textual list (e.g. "Bob, Jane, Alice") to "Bob, Jane, and Alice".
Parameters:
Name | Type | Description |
---|---|---|
str |
string | A ", " separated textual list |
Returns:
The converted text.
- Type
- string
(inner) any()
Returns one of the items passed as parameters, at random. Ex. usage: any("Hi","Hello","Hey")
(inner) elapsedDays(date) → {number}
Returns the number of days that have elapsed since the provided date.
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | The Date object to compare against. |
Returns:
- Type
- number
(inner) exportData(object, filename)
A local file-based export method that serializes a specific HTB state data to a JSON file. Useful for pre-deployment testing.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | The object to back up as JSON. |
filename |
* | The name to use for the JSON file. |
(inner) FMT(str, inType) → {string}
Uses unicode special character sets to prettify text, despite all of Discord's precautions.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to format |
inType |
string | The style / alphabet to apply. One of: [bold sans-serif ('bs'), sans-serif ('s'), bold ('b'), monospaced ('m')] |
Returns:
- Type
- string
(inner) genRanHex(size)
Arrow function to generate a random hexadecimal nonce so images always get re-downloaded in Discord client.
Parameters:
Name | Type | Description |
---|---|---|
size |
* | The length of the desired hex nonce. |
(inner) getChallengeByName(name) → {HtbChallenge|null}
Get the challenge object whose name matches the parameter string.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The challenge name. |
Returns:
- Type
- HtbChallenge | null
(inner) getFlag(countryCode) → {string}
Returns a pretty emoji flag for a given country code. If not recognized, returns the Jolly Roger.
Parameters:
Name | Type | Description |
---|---|---|
countryCode |
string | Example: "EU", "AU", "NZ" |
Returns:
- The emoji, e.g. 🏴☠️
- Type
- string
(inner) getIdFromDiscordName(username) → {number|null}
Gets the HTB user ID for a given Discord username, if such an association exists.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | The Discord username to lookup linked account for. |
Returns:
- Type
- number | null
(inner) getMachineById(id) → {HtbMachine|null}
Get the machine object whose id matches the parameter string.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The machine id. |
Returns:
- Type
- HtbMachine | null
(inner) getMachineByName(name) → {HtbMachine|null}
Get the machine object whose name matches the parameter string.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The machine name. |
Returns:
- Type
- HtbMachine | null
(inner) getMachineIdFromName(name) → {number|null}
Get the ID of the machine whose name matches the parameter string.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The machine name. |
Returns:
- Type
- number | null
(inner) getMdLinksForUids(memberIds) → {Array.<string>|"[Invalid ID]"}
Returns a set of markdown-formatted username links for a given list of HTB ids.
Parameters:
Name | Type | Description |
---|---|---|
memberIds |
Array.<number> | An array of HTB UIDs |
Returns:
- Type
- Array.<string> | "[Invalid ID]"
(inner) getMemberByName(name) → {TeamMember|null}
Get the member object whose name matches the parameter string.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The member name. |
Returns:
- Type
- TeamMember | null
(inner) getMemberTeamRankById(id) → {number|"Unknown"}
Get the current rank of a team member by ID.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | The member ID. |
Returns:
- Type
- number | "Unknown"
(inner) getNewReleaseName() → {string|null}
Returns the name of either an upcoming release (if announced) or the latest published box.
Returns:
- Type
- string | null
(inner) getOsImage(osName) → {string}
Returns the appropriate OS thumbnail for a specified OS name.
Parameters:
Name | Type | Description |
---|---|---|
osName |
string |
Returns:
- Type
- string
(inner) getOwnersByChallengeName(challengeName) → {Array.<HtbOwn>|null}
Returns a list of HtbOwn objects representing the members who have owned the specified challenge.
Parameters:
Name | Type | Description |
---|---|---|
challengeName |
string | Name of the challenge. |
Returns:
- Type
- Array.<HtbOwn> | null
(inner) getOwnersByMachineId(machineId) → {Array.<HtbOwn>|null}
Returns a list of HtbOwn objects representing the members who have rooted the machine with the specified ID.
Parameters:
Name | Type | Description |
---|---|---|
machineId |
number | Name of the challenge. |
Returns:
- Type
- Array.<HtbOwn> | null
(inner) halfMoon(num)
Calculates and returns the sub-integral symbol, used in 'ratingString' function
Parameters:
Name | Type | Description |
---|---|---|
num |
number | the sub-integral value, between 0 - 1. |
(inner) ignoreMember(uid)
Moves a member to the 'ignored' set, meaning that their data will not be updated or shared by the bot until the user undoes this (see unignoreMember()).
Parameters:
Name | Type | Description |
---|---|---|
uid |
number |
(async, inner) importDbBackup() → {Promise}
Imports globals from the cloud backup (Objects stored as raw, singular JSON columns in DB)
Returns:
- Type
- Promise
(inner) importExistingData()
A local file-based method for restoring local backups, useful for early testing without a database instance.
(inner) isAdmin(author)
Returns whether the provided Discord user has admin privileges.
Parameters:
Name | Type | Description |
---|---|---|
author |
Discord.User |
(inner) isEmpty(obj) → {boolean}
Returns true if the object has any properties (is not empty), else returns false.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object |
Returns:
- Type
- boolean
(inner) maybe(probability)
Returns either true or false based on the provided probabilty value (a number between 0-1, where 1 => 100% true and 0 => 100% false).
Parameters:
Name | Type | Description |
---|---|---|
probability |
number |
Returns:
boolean
(inner) mdItemizeList(arr) → {Array.<string>}
Returns a Discord Markdown formatted list of member rankings.
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<string> | A list of hyperlinked member names sorted by rank (descending) where index 0 is the highest ranking member. |
Returns:
- Type
- Array.<string>
(inner) nth(n)
Returns the appropriate ordinal suffix (does NOT concatenate) for a given number.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | The number to get the ordinal suffix for. |
(inner) numS(str)
Formats a given number in Unicode bold characters, for emphasis.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The number to style in bold text. |
(inner) ratingString(rating)
Converts a numeric rating (0.0 - 5.0) to a Unicode moon rating expression (e.g. '2.5' => 🌕🌕🌗🌑🌑)
Parameters:
Name | Type | Description |
---|---|---|
rating |
number | The rating, a positive number from 0 - 5. |
(inner) realMax(a1, a2)
Returns the larger of the two objects, or -- alternatively -- the more real of the two (if one is falsey). Returns 0 if both are falsey.
Parameters:
Name | Type | Description |
---|---|---|
a1 |
Object | |
a2 |
Object |
(inner) timeSince(date)
Returns a fuzzy time estimate for a given date, relative to the present, that some date occurred (e.g. "4 months ago").
Parameters:
Name | Type | Description |
---|---|---|
date |
Date |
(inner) tryDiscordifyUid(uid) → {string|"[Invalid ID]"}
Returns a pretty-printable version of the Discord username and / or HTB username for a given HTB UID, in hyperlinked Discord markdown.
Parameters:
Name | Type | Description |
---|---|---|
uid |
number |
Returns:
- Type
- string | "[Invalid ID]"
(async, inner) understand(message)
Send a query to the dialogflow agent, and return the query result.
Parameters:
Name | Type | Description |
---|---|---|
message |
Object | A Discord Message object. |
(inner) unignoreMember(uid) → {string|false}
Moves a member out of the 'ignored' set, meaning that their data will now be updated and shared by the bot unless the user requests otherwise again (see ignoreMember()).
Parameters:
Name | Type | Description |
---|---|---|
uid |
number |
Returns:
- Type
- string | false
(async, inner) updateCache(fields)
Updates the cloud backup, with options for selective update.
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array.<string> | The specific data types / buffers specified for the update operation, e.g. ["MACHINES","TEAM_MEMBERS"] |
(inner) updateMachineStats() → {Object}
Calculates the total machine count and the subcounts of active, retired and unreleased machines.
Returns:
- Type
- Object
(async, inner) updateTeamStats()
Updates the top team member tally. Should be done after every achievement update (or Pusher own receipt)
(async, inner) wait(ms)
Promise-based sleep function (blocks only the caller (async) function)
Parameters:
Name | Type | Description |
---|---|---|
ms |
number | The time in milliseconds to sleep. |