Skip to content
Math & Text randomRoleID

$randomRoleID[]

The $randomRoleID[] function returns the Discord ID of a random role of a server.

Syntax

$randomRoleID[(guildID)]

Parameters

Parameter Required Description
guildID No ID of the server to pick from. Omitted or empty: the current server.

Return Value

  • The Discord ID (snowflake) of a random role, as a string.
  • Returns an empty string if the server has no role.
  • Throws Invalid guild ID. if guildID is not empty and is not a positive number.

Behavior

  • All roles returned by Discord for the server are candidates, so @everyone can be picked.
  • Each role has the same chance of being picked.

Examples

Get a random role ID

Random role ID: $randomRoleID

Mention a random role

Random role: <@&$randomRoleID>

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.