Math & Text
randomCategoryID
$randomCategoryID
The $randomCategoryID function returns the ID of a randomly selected category channel of a server.
Syntax
$randomCategoryID[(guildID)]
Parameters
| Parameter | Required | Description |
|---|---|---|
guildID |
No | ID of the server to pick from. Omitted or empty: the current server. |
Return Value
- Type: String (Discord snowflake).
- Returns an empty string if the server has no category.
- Throws
Invalid guild ID.ifguildIDis not empty and is not a positive number.
Behavior
- Only channels of type
categoryare candidates; text and voice channels are ignored. - Each category has the same chance of being picked, and the result can change on each call.
- It needs the Discord channel service of the running bot; the channel list is fetched from Discord.
Examples
Show a random category ID
Random category ID: $randomCategoryID
Handle a server without categories
$var[cat;$randomCategoryID]
$if[$var[cat]==]
No categories found.
$else
Category ID: $var[cat]
$endif
Notes
- Use
$randomChannelIDto pick among all channels of the server.
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.