ChatMessage

Methods

# contains(text, caseSensitiveopt) → {boolean}

Returns whether the given text was found in the message.

Parameters:
Name Type Attributes Default Description
text string

The text to check for.

caseSensitive boolean <optional>
false

Determines if the check should be case-sensitive.

Since:
  • 1.0.0
Returns:
Type
boolean

# containsRegex(regex) → {boolean}

Returns whether the given regular expression matches the text of the message.

Parameters:
Name Type Description
regex RegExp

The regular expression to check for. Can either be an instance of RexExp or in literal notation.

Since:
  • 1.0.0
Returns:
Type
boolean

# getBitsBadge() → {number}

Returns the current bits badge level, if the user chose to display it.

This is not an accurate total amount and will only be upgraded on reached bit milestones.

Since:
  • 1.0.0
Returns:
Type
number

# getCommand(withArgsopt) → {Object|string|null}

Returns either the used commands name as string, or null if no command was used. If you set the withArgs parameter to true, the result will be an object containing command and passed arguments instead.

Parameters:
Name Type Attributes Default Description
withArgs boolean <optional>
false
Since:
  • 1.0.0
Returns:
Type
Object | string | null

# getDisplayColor() → {string}

Returns either the users displayColor or generates a new random hex-color string if no color was set.

Since:
  • 1.0.0
Returns:
Type
string

# getGiftsBadge() → {number}

Returns the current sub-gifts badge level, if the user chose to display it.

This is not an accurate total amount and will only be upgraded on reached sub-gift milestones.

Since:
  • 1.0.0
Returns:
Type
number

# getMonthsSubscribed() → {number}

Returns the total amount of months the user has been subscribed to the channel.

Since:
  • 1.0.0
Returns:
Type
number

# getRoles() → {Object}

This is the initial function to construct the roles object internally. Use the roles property in your code instead.

Returns an object with a boolean value for every role.

Since:
  • 1.0.0
Returns:
Type
Object

# getStats() → {Object}

This is the initial function to construct the stats object internally. Use the stats property in your code instead.

Returns the stats object for the message. Can be used to filter out spam or special chars.

Percentages range from 0 (0%) to 1 (100%). So 50% would be noted as 0.5.

Since:
  • 1.0.0
Returns:
Type
Object

# getTierBadge() → {number}

Returns the users current subscription-tier as number. (1 = tier 1, 2 = tier 2, 3 = tier 3, 0 = no sub)

Prime subs still count as tier 1 and non-subs return 0

Since:
  • 1.0.0
Returns:
Type
number

# getWordList() → {Array.<string>}

Returns an array with each word of the message as an element.

Since:
  • 1.0.0
Returns:
Type
Array.<string>

# hasPrimeBadge() → {boolean}

Returns whether the user has a prime badge.

Since:
  • 1.0.0
Returns:
Type
boolean

# hasRole(role) → {boolean}

Returns whether the user has the given role or not. This function also allows for some aliases in the role names.

Parameters:
Name Type Description
role string
Since:
  • 1.0.0
Returns:
Type
boolean

# hasTurboBadge() → {boolean}

Returns whether the user has a turbo badge.

Since:
  • 1.0.0
Returns:
Type
boolean

# hasUserId(id) → {boolean}

Returns whether the messages sender matches the given userID.

Parameters:
Name Type Description
id string

The userID to check for.

Since:
  • 1.0.0
Returns:
Type
boolean

# hasUsername(name) → {boolean}

Returns whether the messages author matches the given username. This check is case-insensitive.

Parameters:
Name Type Description
name string

The username to check for.

Since:
  • 1.0.0
Returns:
Type
boolean

# isAction() → {boolean}

Returns whether the message is an user action. E.g. /me

Since:
  • 1.0.0
Returns:
Type
boolean

# isBroadcaster() → {boolean}

Returns whether the user has the broadcaster role.

Since:
  • 1.0.0
Returns:
Type
boolean

# isCommand(cmdNameopt) → {boolean}

Returns whether the message is a command.

You can also check for specific commands using the cmdName parameter.

Parameters:
Name Type Attributes Default Description
cmdName string <optional>
""

The command name to check for

Since:
  • 1.0.0
Returns:
Type
boolean

# isCustomReward() → {boolean}

Returns whether the message is a custom channel-points reward.

Since:
  • 1.0.0
Returns:
Type
boolean

# isModerator() → {boolean}

Returns whether the user has the moderator role.

Since:
  • 1.0.0
Returns:
Type
boolean

# isStaff() → {boolean}

Returns whether the user has the staff role.

Since:
  • 1.0.0
Returns:
Type
boolean

# isSubscriber() → {boolean}

Returns whether the user has the subscriber role.

Since:
  • 1.0.0
Returns:
Type
boolean

# isVIP() → {boolean}

Returns whether the user has the VIP role.

Since:
  • 1.0.0
Returns:
Type
boolean

# usernameContains(text, caseSensitiveopt) → {boolean}

Returns whether the messages sender contains the given text.

Parameters:
Name Type Attributes Default Description
text string

The text to check for.

caseSensitive boolean <optional>
false

Determines if the check should be case-sensitive.

Since:
  • 1.0.0
Returns:
Type
boolean

# usernameContainsRegex(regex) → {boolean}

Returns whether the messages sender matches the given regular expression.

Parameters:
Name Type Description
regex RegExp

The regular expression to check for. Can either be an instance of RexExp or in literal notation.

Since:
  • 1.0.0
Returns:
Type
boolean

# usernameOnList(list) → {boolean}

Returns whether the username is on a given list.

This check is case-insensitive.

Parameters:
Name Type Description
list Array.<string>

An array of names to look up the username in.

Since:
  • 1.0.0
Returns:
Type
boolean