Autocomplete
There are multiple ways of using $autoCompleteRespond
. You can either use JSON or the simple aoi.js way.
Usage
The $autoCompleteRespond
can be used in two ways:
- Simple Way: Here’s how you can use it in a simple way:
$autoCompleteRespond[OptionName;OptionReply;...]
- JSON Way: If you prefer JSON, you can use it like this:
$autoCompleteRespond[[{ "name" : "Option Name One", "value" : "Option Reply 1" }, { "name" : "Option Name Two", "value" : "Option Reply 2" }]]
Creating a Slash Command with Autocomplete
Here’s how you can create a global application command named “example” with an option that uses autocomplete:
1client.command({2 name: "createApplicationCommand",3 code: `4 $createApplicationCommand[global;example;Awesome example interaction command with auto-complete!;true;true;slash;[{5 "name": "option",6 "description": "First option!",7 "required": false,8 "type": 3,9 "autocomplete": true10}]]`11});
Responding Based on Autocomplete Selection
If autoComplete equals true
, it will respond with the given response:
1client.command({2 name: "example",3 prototype: "slash",4 $if: "old",5 code: `6 $if[$isAutocomplete==true]7 $autoCompleteRespond[First option;You selected the first option, therefore I'm responding with this!;Second option;You selected the first second, therefore I'm responding with this!]8 $else9 $interactionReply[$slashOption[option]]10 $endif11 `12});
Creating a Slash Command with Multiple Options
Here’s how you can create a global application command named “example” with multiple options:
1client.command({2 name: "createApplicationCommand",3 code: `4 $createApplicationCommand[global;example;Awesome example interaction command with auto-complete!;true;true;slash;[{5 "name": "option",6 "description": "First option with autocomplete.",7 "required": false,8 "type": 3,9 "autocomplete": true10 }, {11 "name": "anotheroption",12 "description": "Another option.",13 "required": false,14 "type": 315}]]`16});
Responding with JSON Based on Autocomplete Selection
If autoComplete equals true
, it will respond with the given JSON response:
1module.exports = [2 {3 name: "example",4 prototype: "slash",5 $if: "old",6 code: `7 $if[$isAutocomplete==true]8 $autoCompleteRespond[[{9 "name" : "First Option",10 "value" : "You selected the first option, therefore I\'m responding with this!"11 }, {12 "name" : "Second Option",13 "value" : "You selected the second option, therefore I\'m responding with this!"14 }]]15 $else16 $interactionReply[You selected: $slashOption[option]!]17 $endif18 `19 }20];