Skip to content
Math & Text randomString

$randomString[]

The $randomString[] function generates a random alphanumeric character string of a given length.

Syntax

$randomString[length]

Parameters

Parameter Description
length Required. An integer from 1 to 10 (surrounding spaces are ignored). Anything else (0, 11, a decimal, text, empty) raises the error “Random string length must be an integer from 1 to 10.”.

Return Value

A string of exactly length random alphanumeric characters (exactly one argument is accepted), containing:

  • Lowercase letters (a-z)
  • Uppercase letters (A-Z)
  • Digits (0-9)

Examples

Generate a random identifier

$title[Your session ID]
$description[ID: `$randomString[8]`]
$footer[Keep this identifier]

Verification code

Your verification code is: **$randomString[6]**

Longest string

$randomString[10]

Use cases

  • Short random codes or labels (maximum length 10). Two calls can return the same string: uniqueness is not guaranteed.

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.