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) .emitDeprecationWarning(target: any, message: string) → void

Emit a deprecation warning message for the given target

Parameters:
Name Type Description
target
any

Deprecation target

message
string

Deprecation message

Source:
Returns:
void

(static) .escape(input: string) → string

Returns the given string with special characters escaped

Parameters:
Name Type Description
input
string

String to escape

Source:
Returns:
string

(static) .flattenArray(array: any[]) → any[]

Flatten an array that may contain nested arrays

Parameters:
Name Type Description
array
any[]
Source:
Returns:
any[]

(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) .parseArgs(input: string, command?: Command) → string[]

Split args from the input by the given Command's argument separator

Parameters:
Name Type Attributes Description
input
string

Input string to parse args from

command
Command
<optional>

Command object, used to determine the args separator. If none is given, ' ' will be used as the separator

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' }
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) → Promise<Tuple<boolean, Command | null, string, (string|null)>>

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 everything it manages to determine up to the point of failure

Parameters:
Name Type Description
message
Message

Message to check

Source:
Returns:
Promise<Tuple<boolean, Command | null, string, (string|null)>>