Entity Info
categoryID
$categoryID
The $categoryID function looks up a category by its name and returns its ID. To get the category of a channel, use $channelCategoryID instead.
Syntax
$categoryID[categoryName]
Parameters
| Parameter | Description |
|---|---|
categoryName |
Required. The exact name of the category (case-sensitive comparison). An empty name raises the error Channel name is required. |
Return value
| Type | Description |
|---|---|
snowflake (string) |
The ID of the category with that name, or an empty string if no category has this name. |
Examples
Get the ID of a category by its name
$sendMessage[Category ID: $categoryID[Information]]
Check that a category exists
$if[$categoryID[Information]!=]
$sendMessage[The category exists.]
$else
$sendMessage[Category not found.]
$endif
List channels of a category
$sendMessage[Channels: $categoryChannels[$categoryID[Information];, ]]
Notes
$categoryIDis not an alias of$channelCategoryID: it takes a category name, not a channel ID.- Only categories are searched; a channel with the same name is ignored.
- To get the category of a channel, use
$channelCategoryID(or$parentID).
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.