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

Callbacks 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

Callback

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 Is '19' odd number? yes Your answer is correct! !example Is '19' odd number? no Your answer is incorrect! !example Is '19' odd number? cancel Command cancelled!

Read more

For more information about the functions used can be found in If Statements Guide.

With numeric filter

Trigger: $awaitedCommand[odd;<numeric>]

$nomention
You have provided a number: $message
!example Provide a number! 52 You have provided a number: 52

$awaitedCommandError

Callback

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 Provide a number! azbc Invalid number!

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
!say What do you want me to say? Hello everyone! Hello everyone!

Warning

Use $allowUserMentions[] and $allowRoleMentions[] to disable role, @here and @everyone mentions!

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 '21' 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
!odd Is '21' odd number? yes Your answer is correct! !odd Is '21' odd number? no Your answer is incorrect! !odd Is '21' odd number? cancel Command cancelled!

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
!number Provide a number! 28 You have provided a number: 28