Entity Info
channelType
$channelType
The $channelType function returns the type of a Discord channel. Possible types include text, voice, category, announcement, thread, stage, forum, media, and dm.
Syntax
$channelType[channelID]
Parameters
| Parameter | Description |
|---|---|
channelID |
Required. The ID of the target channel. Use $channelID for the current channel. An invalid ID raises Invalid channel ID. and an unknown channel raises Channel not found. |
Return value
| Type | Description |
|---|---|
string |
The type of the channel. Possible values: text, voice, category, announcement, thread, stage, forum, media, dm (private and group DMs), unknown. |
Examples
Display the type of the channel
$sendMessage[This channel is of type: **$channelType[$channelID]**]
Check if voice channel
$if[$channelType[$channelID]==voice]
$sendMessage[You are in a voice channel.]
$else
$sendMessage[You are not in a voice channel.]
$endif
Check if category
$if[$channelType[$channelID]==category]
$sendMessage[This command cannot be used on a category.]
$stop
$endif
Notes
- Channel types are returned in lowercase.
- Useful for conditioning the behavior of a command based on the channel type.
- Channels of type
dmdo not have a parent category. - Announcement channels (formerly “news”) are returned as
announcement.
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.