Custom Commands
Learn how to create custom commands in ItsMyBot to extend the bot's functionalities and perform various actions based on user input.
With ItsMyBot and the scripting system, you can create custom commands to extend the bot's functionalities. These commands can be used to perform various actions, such as sending messages, managing roles, and more.
Each custom command need to be created in the scripting/custom-commands folder in the bot's directory. It supports subfolders, so you can organize your commands as you want. Each command is a .yml file that contains the command's configuration. You can disable a command by adding an underscore at the beginning of the file name, for example: _my-command.yml.
Command Structure
A custom command is a YAML file that contains the following structure:
Prop
Type
name: give-role
description: "Give a role to a user."
options:
- name: user # Option name
type: "user" # Option type
description: "The user to give the role to"
required: true # Option required
- name: role
type: "role"
description: "Select a role to add to the user"
required: true
actions:
- actions:
- id: addRole
args:
value: "%option_role_id%"
- id: reply
args:
delay: 3
components:
- type: text-display
content: "Role %option_role_mention% added to %option_user_mention%"
target:
member: "%option_user_id%" # Transform the main member to the user selected in the option.Options types
Options are the parameters that can be passed to a command when it is executed. They can be used to customize the behavior of the command. Each option has a type, a name, a description, and can have additional properties depending on its type.
Each option give you the following variables to use in the actions:
[[option_<option-name>]]: The value of the option.[[option_<option-name>_is_provided]]: A boolean that indicates if the option was provided or not.
If the option have choices, it will also provide the following variable:
[[option_<option-name>_choice_name]]: The name of the choice selected
String
string
A string option is a text input that can be used to provide a value for the command.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: string
required: true
choices:
- name: choice1
value: value1
- name: choice2
value: value2
- name: option2
description: This is the second option.
type: string
required: false
max-length: 100
min-length: 1Number
integer/number
An integer option is a numeric input that can be used to provide a value for the command.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: integer # or number
required: true
choices:
- name: choice1
value: 1
- name: choice2
value: 2
min-value: 0
max-value: 100
- name: option2
description: This is the second option.
type: integer # or number
required: falseBoolean
boolean
A boolean option is a checkbox that can be used to provide a value for the command.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: boolean
required: trueUser
user
A user option is a user mention that can be used to provide a value for the command.
- Add the user variables with the prefix
[[option_<option-name>_]]in the actions. Example:[[option_user_mention]]to get the mention of the user selected.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: user
required: trueChannel
channel
A channel option is a channel mention that can be used to provide a value for the command.
- Add the channel variables with the prefix
[[option_<option-name>_]]in the actions. Example:[[option_option1_mention]]to get the mention of the channel selected.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: channel
required: true
channel-type: GuildText Role
role
A role option is a role mention that can be used to provide a value for the command.
- Add the role variables with the prefix
[[option_<option-name>_]]in the actions. Example:[[option_option1_mention]]to get the mention of the role selected.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: role
required: trueMentionable
mentionable
A mentionable option is a mentionable entity (user or role) that can be used to provide a value for the command.
- Add the user variables or role variables with the prefix
[[option_<option-name>_]]in the actions. Example:[[option_option1_mention]]to get the mention of the selected mentionable.
Prop
Type
name: my-command
description: This is a custom command.
options:
- name: option1
description: This is the first option.
type: mentionable
required: trueActions
Actions are the core of the custom commands. They define what the command will do when it is executed. You can use any action available in the actions section.
Target
Learn about the Target system in ItsMyBot, a powerful feature that allows you to change the context of actions, such as the member, channel, message, role, user, or guild that the action is executed on.
Meta
Learn about the Meta system in ItsMyBot, a powerful feature that allows you to save custom data for later use in your scripts, commands, and embeds.