Skip to content
Moderation threadMessageCount

$threadMessageCount

The function $threadMessageCount returns the total number of messages in a thread.

Syntax

$threadMessageCount

Parameters

This function takes no argument: it applies to the current channel, which must be a thread.

Return Value

  • Type: Integer
  • The message count Discord reports for the thread.
  • Raises an error (Channel is not a thread.) if the current channel is not a thread.

Behavior

  • The thread is the current channel (channel.id); the value is read from Discord at call time.

Examples

Thread Statistics

$title[Thread Statistics]
$description[
**Messages:** $threadMessageCount
**Members:** $threadUserCount
]
$color[#5865F2]
$sendMessage[Statistics of this thread]

Activity Check

$var[msgCount;$threadMessageCount]
$if[$var[msgCount]<=1]
  $sendMessage[This thread seems inactive. Feel free to ask your questions!]
$endif

Auto Archiving

$var[msgCount;$threadMessageCount]
$if[$var[msgCount]>=100]
  $editThread[$channelID;!unchanged;yes]
  $sendMessage[Thread archived automatically (100 messages reached).]
$endif

Notes

  • Useful for statistics and automatic thread management.
  • To get the number of members, use $threadUserCount[].

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.