Utility class containing handy static methods that can be used anywhere
- Source:
Properties
.baseCommandNames: BaseCommandName[]
Tangible representation of all base command names
- 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 |
|
Object to assign to |
path |
|
Nested path to follow within the object |
value |
|
Value to assign within the object |
- Source:
(static) .emitDeprecationWarning(target: any, message: string) → void
Emit a deprecation warning message for the given target
Parameters:
Name | Type | Description |
---|---|---|
target |
|
Deprecation target |
message |
|
Deprecation message |
- Source:
(static) .escape(input: string) → string
Returns the given string with special characters escaped
Parameters:
Name | Type | Description |
---|---|---|
input |
|
String to escape |
- Source:
(static) .flattenArray(array: any[]) → any[]
Flatten an array that may contain nested arrays
Parameters:
Name | Type | Description |
---|---|---|
array |
|
- Source:
(static) .getNestedValue(obj: any, path: string[]) → any
Fetches a nested value from within an object via the provided path
Parameters:
Name | Type | Description |
---|---|---|
obj |
|
Object to search |
path |
|
Nested path to follow within the object |
- Source:
(static) .normalize(text: string) → string
Returns the given string lowercased with any non alphanumeric chars removed
Parameters:
Name | Type | Description |
---|---|---|
text |
|
Text to normalize |
- Source:
(static) .now() → 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 |
|
Text to pad |
length |
|
Length to pad to |
- Source:
(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 |
|
Input string to parse args from |
|
command |
|
<optional> |
Command object, used to determine the args separator.
If none is given, |
- Source:
(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 |
|
Argument list string |
- Source:
(static) .removeNestedValue(obj: any, path: string[]) → void
Remove a value from within an object along a nested path
Parameters:
Name | Type | Description |
---|---|---|
obj |
|
Object to remove from |
path |
|
Nested path to follow within the object |
- Source:
(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 to check |
- Source: