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) .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) .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 |
|
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) → 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 to check |
- Source: