BotUtil
Contains general utility methods
Static Member Summary
Static Public Members | ||
public static get |
|
Static Method Summary
Static Public Methods | ||
public static |
disambiguation(items: Object[], label: string, property: string): string Build a disambiguation list - useful for telling a user to be more specific when finding partial matches from a command |
|
public static |
escapeMarkdown(text: string): string Escapes Markdown in the string |
|
public static |
Convert spaces to non-breaking spaces |
|
public static |
Paginate an array of items |
|
public static |
search(items: Object[], searchString: string, options: SearchOptions): Object[] Search for matches in a list of items |
|
public static |
Splits a string using specified characters into multiple strings of a maximum length |
|
public static |
usage(client: Client, settings: SettingStorage, config: BotConfig, command: string, guild: Guild | string, onlyMention: boolean): string Build a command usage string |
Constructor Summary
Public Constructor | ||
public |
constructor(client: Client, settings: SettingStorage, config: BotConfig) |
Member Summary
Public Members | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
Method Summary
Public Methods | ||
public |
disambiguation(items: Object[], label: string, property: string): string Build a disambiguation list - useful for telling a user to be more specific when finding partial matches from a command |
|
public |
escapeMarkdown(text: string): string Escapes Markdown in the string |
|
public |
Convert spaces to non-breaking spaces |
|
public |
Paginate an array of items |
|
public |
search(items: Object[], searchString: string, options: SearchOptions): Object[] Search for matches in a list of items |
|
public |
Splits a string using specified characters into multiple strings of a maximum length |
|
public |
Build a command usage string |
Static Public Members
Static Public Methods
public static disambiguation(items: Object[], label: string, property: string): string source
Build a disambiguation list - useful for telling a user to be more specific when finding partial matches from a command
public static escapeMarkdown(text: string): string source
Escapes Markdown in the string
Params:
Name | Type | Attribute | Description |
text | string | The text to escape |
public static nbsp(text: string): string source
Convert spaces to non-breaking spaces
Params:
Name | Type | Attribute | Description |
text | string | The text to convert |
See:
public static paginate(items: Object[], page: number, pageLength: number): Object source
Paginate an array of items
Return:
Object | The resulting paginated object |
See:
public static search(items: Object[], searchString: string, options: SearchOptions): Object[] source
Search for matches in a list of items
Params:
Name | Type | Attribute | Description |
items | Object[] | An array of items to search in |
|
searchString | string | The string to search for |
|
options | SearchOptions | An options object |
See:
public static split(text: string, maxLength: number, splitOn: string, prepend: string, append: string): string[] source
Splits a string using specified characters into multiple strings of a maximum length
Params:
Name | Type | Attribute | Description |
text | string | The string to split |
|
maxLength | number |
|
The maximum length of each split string |
splitOn | string |
|
The characters to split the string with |
prepend | string |
|
String to prepend to every split message |
append | string |
|
String to append to every split message |
See:
public static usage(client: Client, settings: SettingStorage, config: BotConfig, command: string, guild: Guild | string, onlyMention: boolean): string source
Build a command usage string
Params:
Name | Type | Attribute | Description |
client | Client | The client to use |
|
settings | SettingStorage | The setting storage to use |
|
config | BotConfig | The bot config to use |
|
command | string | The short command string (ex. "roll d20") |
|
guild | Guild | string |
|
The guild or guild ID to use the prefix of |
onlyMention | boolean |
|
Whether or not the usage string should only show the mention form |
See:
Public Constructors
public constructor(client: Client, settings: SettingStorage, config: BotConfig) source
Params:
Name | Type | Attribute | Description |
client | Client | The client to use |
|
settings | SettingStorage | The setting storage to use |
|
config | BotConfig | The bot config to use |
Public Members
public settings: SettingStorage source
Public Methods
public disambiguation(items: Object[], label: string, property: string): string source
Build a disambiguation list - useful for telling a user to be more specific when finding partial matches from a command
public escapeMarkdown(text: string): string source
Escapes Markdown in the string
Params:
Name | Type | Attribute | Description |
text | string | The text to escape |
public nbsp(text: string): string source
Convert spaces to non-breaking spaces
Params:
Name | Type | Attribute | Description |
text | string | The text to convert |
See:
public paginate(items: Object[], page: number, pageLength: number): Object source
Paginate an array of items
Return:
Object | The resulting paginated object |
See:
public search(items: Object[], searchString: string, options: SearchOptions): Object[] source
Search for matches in a list of items
Params:
Name | Type | Attribute | Description |
items | Object[] | An array of items to search in |
|
searchString | string | The string to search for |
|
options | SearchOptions | An options object |
See:
public split(text: string, maxLength: number, splitOn: string, prepend: string, append: string): string[] source
Splits a string using specified characters into multiple strings of a maximum length
Params:
Name | Type | Attribute | Description |
text | string | The string to split |
|
maxLength | number |
|
The maximum length of each split string |
splitOn | string |
|
The characters to split the string with |
prepend | string |
|
String to prepend to every split message |
append | string |
|
String to append to every split message |