Math & Text
isSlash
$isSlash
The function $isSlash checks if the current command was triggered via a slash command (application command) rather than a classic prefix command.
Syntax
$isSlash
Parameters
None.
Return Value
- Type: Boolean
"true"if the command context is flagged as a slash (application command) interaction."false"otherwise, including when the flag is absent.
Behavior
- Allows adapting behavior based on the invocation mode.
- It reads the
interaction.isSlashvalue of the execution context: the result istrueonly when that value is exactlytrue. - No parameters:
$isSlash[...]with an argument is refused (“Invalid argument count”).
Examples
Adaptive Response
$if[$isSlash==true]
$ephemeral
$sendMessage[✅ Action completed successfully!]
$else
$sendMessage[✅ Action completed successfully!]
$endif
Diagnostic Log
$if[$isSlash==true]
$log[Command /$commandName executed by $userName]
$else
$log[Command $commandTrigger executed by $userName]
$endif
Info Message
$if[$isSlash==true]
$var[type;Slash]
$else
$var[type;Prefix]
$endif
$title[ℹ️ Command Information]
$description[
**Name:** $commandName
**Type:** $var[type]
**Folder:** $commandFolder
]
$color[#5865F2]
Hybrid Command
$c[This command works in prefix and slash mode]
$if[$isSlash==true]
$var[args;((opts.input))]
$else
$var[args;$message[1]]
$endif
$c[Common processing]
You provided: $var[args]
Related functions
- $ephemeral — make an interaction response visible only to the command caller
- Execution model — understand implicit slash replies and option variables
Notes
$isSlashtakes no parameters.- To get the precise command type, use
$commandType. $isSlashis evaluated in the context of the currently executing command.- Slash options are available as
((opts.name))variables;$message[name]also reads a slash option by name when the command is a slash command.
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.