Skip to content

Latest commit

 

History

History
156 lines (92 loc) · 3.39 KB

File metadata and controls

156 lines (92 loc) · 3.39 KB

Bot / structs/ModuleUtil / ModuleUtil

Class: ModuleUtil

structs/ModuleUtil.ModuleUtil

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ModuleUtil(module)

Initializes a new ModuleUtil instance.

Parameters

Name Type Description
module Module The module that owns this util.

Defined in

src/structs/ModuleUtil.ts:17

Properties

module

Readonly module: Module

A reference to the module that owns this util.

Defined in

src/structs/ModuleUtil.ts:10

Methods

join

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.

Parameters

Name Type Description
array unknown[] The array to convert to a string.
word string The word to separate the last item with.

Returns

string

Example

util.join(['a', 'b', 'c'], 'and');
// => a, b and c

util.join(['a'], 'or');
// => a

Defined in

src/structs/ModuleUtil.ts:81


where

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.

Parameters

Name Type Description
interaction BaseInteraction<CacheType> The interaction to look at.

Returns

string

A string representing where the interaction was sent from.

Example

util.where(interaction);
// => DMs

util.where(interaction);
// => My Server#general [1234567890]

Defined in

src/structs/ModuleUtil.ts:49


who

who(interaction): string

Generates a string representing who sent the provided interaction.

Parameters

Name Type Description
interaction BaseInteraction<CacheType> The interaction to look at.

Returns

string

A string representing who sent the interaction.

Defined in

src/structs/ModuleUtil.ts:27