Skip to content
Variables args

$args[]

$args is the primary mechanism for accessing user-provided input in text commands. Arguments are the words that follow the command name, separated by whitespace.

Syntax

bdfd
$args / $args[index] / $args[index;option]

Indexing

Arguments are 0-indexed: the first word after the command name is at index 0. If the user types !command hello world:

  • $args[0] → "hello"
  • $args[1] → "world"
  • $args (without index) → "hello world"

Requesting an index beyond the available arguments returns an empty string — no error is raised.

Slash Command Fallback

When used in hybrid commands (supporting both text and slash invocation), $args[index;option] provides a graceful fallback:

  1. If a text argument exists at the given index, it is returned.
  2. If no text argument exists, the slash command option named option is returned instead.
  3. If neither exists, an empty string is returned.

This allows the same command code to handthe both invocation methods seamlessly.

Comparison with Other Functions

Function Purpose
$args / $args[index] Access individual arguments
$argCount Count how many arguments were provided
$argsCheck Validate argument count and block if insufficient

Examples

Read Command Arguments with Embed

$title[Command Arguments Inspector]
$description[Total args: **$argsCount**\nFirst arg: `$args[1]`\nAll args: `$args`]
$color[#5865F2]
$sendMessage[]