Skip to content
Entity Info messageType

$messageType

The function $messageType returns the type of the triggering message as an integer. Type 0 corresponds to a normal user message, while other types correspond to Discord system messages.

Syntax

$messageType[(unused;unused)]

Parameters

Up to two arguments are accepted but ignored: the function never queries another message.

Return Value

Type Description
string The text of the message.type context variable supplied by the host, or 0 if the host supplied none. For message events the host supplies the numeric Discord message type.

Common Types

Type Meaning
0 Normal message (DEFAULT)
1 Member added to group DM (RECIPIENT_ADD)
2 Member removed from group DM (RECIPIENT_REMOVE)
3 Voice call message (CALL)
4 Channel name changed (CHANNEL_NAME_CHANGE)
5 Channel icon changed (CHANNEL_ICON_CHANGE)
6 Pinned message notification (CHANNEL_PINNED_MESSAGE)
7 New member joined (GUILD_MEMBER_JOIN)
8 Server boost (USER_PREMIUM_GUILD_SUBSCRIPTION)
9 Boost level 1 reached (GUILD_TIER_1)
10 Boost level 2 reached (GUILD_TIER_2)
11 Boost level 3 reached (GUILD_TIER_3)

Examples

Display the type

$sendMessage[Message type: $messageType]

Ignore system messages

$if[$messageType!=0]
  $stop
$endif
$sendMessage[User message processed.]

React to new joins

$if[$messageType==7]
  $sendMessage[Welcome $username!]
$endif

Notes

  • The Discord library used by the bot also defines 12 (channel follow add), 18 (thread created), 19 (reply), 20 (chat input command), 21 (thread starter message), 23 (context menu command) and others. In particular a reply to a message has type 19, so $messageType!=0 also excludes replies.
  • Returns an integer, not a descriptive string.

Try it

Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.