Awaited Commands

Awaited commands are a special type of command where the bot waits for the user's response.

Content

Functions Used > Supported Filters > $awaitFunc[] > $awaitedCommand[] > $awaitedCommandError[] > Creating an awaited command

Functions Used

Supported Filters

  • <numeric>: Accepts only number input.
  • <word1/word2/...>: Accepts only specified words provided inside <>. Use / as a separator for multiple words.

$awaitFunc

Used to initiate an awaited command.

Syntax

$awaitFunc[name;(user ID;channel ID)]

Parameters

  • command name (Type: String || Flag: Required): The name used inside $awaitedCommand[] and $awaitedCommandError[] callbacks.
  • user ID (Type: Snowflake || Flag: Vacantable): The user the awaited command will trigger for. Uses command author, if user ID is not given.
  • channel ID (Type: Snowflake || Flag: Optional): The channel where the command will be awaited. Uses current channel, if channel ID is not given.

Example

$nomention
What do you want me to say?
$awaitFunc[say]

example

$awaitedCommand

Triggered when an awaited command gets responded to.

$awaitedCommand[] is a callback, which means it's used in the command trigger (not the code). The command is only run when an awaited command gets responded to.

Syntax

$awaitedCommand[name;(filter)]

Parameters

  • name (Type: String || Flag: Required): The name used in $awaitFunc[] function.
  • filter (Type: String || Flag: Emptiable): Used to limit user input (Supported filters). If no filter is provided, it accepts any input.

Example

Without filter

Trigger: $awaitedCommand[say;]

$nomention
$message

example

With choose filter

Trigger: $awaitedCommand[odd;<yes/no/cancel>]

$nomention
$if[$message==yes]
   Your answer is correct!
$elseif[$message==no]
   Your answer is incorrect!
$elseif[$message==cancel]
   Command cancelled!
$endif

example

With numeric filter

Trigger: $awaitedCommand[odd;<numeric>]

$nomention
You have provided a number: $message

example

$awaitedCommandError

Triggered when an awaited command doesn't match with provided filter.

$awaitedCommandError[] is a callback, which means it's used in the command trigger (not the code). The command is only run when an awaited command doesn't match with provided filter.

Syntax

$awaitedCommandError[name]

Parameters

  • name (Type: String || Flag: Required): The name used in $awaitFunc[] function.

Example

Trigger: $awaitedCommandError[number]

$nomention
Invalid number!

example

Creating an awaited command

Without filter

  1. Create two commands with !say and $awaitedCommand[say;] triggers.
  2. Paste the following code:

Code for the !say command:

$nomention
What do you want me to say?
$awaitFunc[say]

Code for the command with the $awaitedCommand[say;] trigger:

$nomention
$message
  1. Execute command !say

example

With choose filter

  1. Create two commands with !odd and $awaitedCommand[odd;<yes/no/cancel>] triggers.
  2. Paste the following code:

Code for the !odd command:

$nomention
Is '19' an odd number?
$awaitFunc[odd]

Code for the command with the $awaitedCommand[odd;<yes/no/cancel>] trigger:

$nomention
$if[$message==yes]
   Your answer is correct!
$elseif[$message==no]
   Your answer is incorrect!
$elseif[$message==cancel]
   Command cancelled!
$endif
  1. Execute command !odd

example

With numeric filter

  1. Create two commands with !number and $awaitedCommand[number;<numeric>] triggers.
  2. Paste the following code:

Code for the !number command:

$nomention
Provide a number!
$awaitFunc[number]

Code for the command with the $awaitedCommand[number;<numeric>] trigger:

$nomention
You have provided a number: $message
  1. Execute command !number

example