Bot / structs/ModuleUtil / ModuleUtil
structs/ModuleUtil.ModuleUtil
• new ModuleUtil(module)
Initializes a new ModuleUtil instance.
| Name | Type | Description |
|---|---|---|
module |
Module |
The module that owns this util. |
• Readonly module: Module
A reference to the module that owns this util.
▸ join(array, word): string
Converts the provided array into a string, with the last item separated by the specified word.
If we want to convert an array to a string, we use the join method,
however, this will join all items in the array with the specified
separator. It isn't possible to separate the last item with a different
separator using the built-in join method.
This method will convert the array to a string, with the last item separated by the specified word to simplify the process of converting an array to a string.
| Name | Type | Description |
|---|---|---|
array |
unknown[] |
The array to convert to a string. |
word |
string |
The word to separate the last item with. |
string
Example
util.join(['a', 'b', 'c'], 'and');
// => a, b and c
util.join(['a'], 'or');
// => a▸ where(interaction): string
Generates a string representing where the provided interaction was sent.
Command interactions can occur either within a guild or the client's DMs, this method generates a string to represent where the provided interaction was sent.
| Name | Type | Description |
|---|---|---|
interaction |
BaseInteraction<CacheType> |
The interaction to look at. |
string
A string representing where the interaction was sent from.
Example
util.where(interaction);
// => DMs
util.where(interaction);
// => My Server#general [1234567890]▸ who(interaction): string
Generates a string representing who sent the provided interaction.
| Name | Type | Description |
|---|---|---|
interaction |
BaseInteraction<CacheType> |
The interaction to look at. |
string
A string representing who sent the interaction.