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[Command 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 What do you want me to say? I love BDFD I love BDFD

$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 What do you want me to say? I love BDFD I love BDFD

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