Util

Utility class containing handy static methods that can be used anywhere

Source:

Properties

.baseCommandNames: BaseCommandName[]

Tangible representation of all base command names

Type:
BaseCommandName[]
Source:

Methods

(static) .assignNestedValue(obj: any, path: string[], value: any) → void

Assigns the given value along the given nested path within the provided initial object

Parameters:
Name Type Description
obj
any

Object to assign to

path
string[]

Nested path to follow within the object

value
any

Value to assign within the object

Source:
Returns:
void

(static) .getNestedValue(obj: any, path: string[]) → any

Fetches a nested value from within an object via the provided path

Parameters:
Name Type Description
obj
any

Object to search

path
string[]

Nested path to follow within the object

Source:
Returns:
any

(static) .normalize(text: string) → string

Returns the given string lowercased with any non alphanumeric chars removed

Parameters:
Name Type Description
text
string

Text to normalize

Source:
Returns:
string

(static) .now() → number

Implementation of performance-now

Source:
Returns:
number

(static) .padRight(text: string, length: number) → string

Pads the right side of a string with spaces to the given length

Parameters:
Name Type Description
text
string

Text to pad

length
number

Length to pad to

Source:
Returns:
string

(static) .parseArgTypes(input: string) → object

Converts a TypeScript-style argument list into a valid args data object for resolve and expect. This can help if the object syntax for resolving/expecting Command arguments is too awkward or cluttered, or if a simpler syntax is overall preferred.

Args marked with ? (for example: arg?: String) are declared as optional and will be converted to '[arg]': 'String' at runtime. Normal args will convert to '<arg>': 'String'

Example:

`user: User, height: ['short', 'tall'], ...desc?: String`
// becomes:
{ '<user>': 'User', '<height>': ['short', 'tall'], '[...desc]': 'String' }

When specifying argument types for resolve, use String when you know you will be later giving a string literal array to expect for the corresponding arg

Parameters:
Name Type Description
input
string

Argument list string

Source:
Returns:
object

(static) .removeNestedValue(obj: any, path: string[]) → void

Remove a value from within an object along a nested path

Parameters:
Name Type Description
obj
any

Object to remove from

path
string[]

Nested path to follow within the object

Source:
Returns:
void

(static) .wasCommandCalled(message: Message)Tuple<boolean, Command, string, string>

Return whether or not a command was called in the given message, the called command, the prefix used to call the command, and the name or alias of the command used to call it.

Returns [false, null, null, null] if no command was called

Parameters:
Name Type Description
message
Message

Message to check

Source:
Returns:
Tuple<boolean, Command, string, string>