Introduction
Learn about scripting in ItsMyBot, a powerful feature that allows you to create custom scripts to automate tasks, respond to events, and extend the bot's functionalities.
Scripting in ItsMyBot allows you to create custom scripts that can automate tasks, respond to events, and extend the bot's functionalities. Scripts are written in YAML format and can include actions, triggers, conditions, and target.
You can browse the Scripts Library to discover reusable snippets shared in the repo. If you’ve created one and want to share it, join the Discord and mention me!
Configuring an Action / Script
The configuration of an action is done in the actions section of the script. Each action has its own set of arguments, triggers, conditions, and target. The action is executed when the trigger is fired and the conditions are met.
You can have actions in scripts, custom commands, and more.
Example Action Config
actions:
- id: sendMessage
args:
components:
- type: text-display
content: "Hello there !"
chance: 0.25 # 25% chance to send the message
triggers: everyHour
target:
channel: "935421560355946596" # Channel ID or name
conditions:
- id: memberCountAbove
args:
amount: 100 # Number of members in the serverThe above example will send a message "Hello there !" every hour in the channel with ID 935421560355946596 if the server has more than 100 members. The message will only be sent with a 25% chance.
Understanding the Sections
Prop
Type
Optional Arguments
Every actions have optional arguments that can be used to modify the behavior of the action. These arguments are not required, but can be useful in certain situations.
Prop
Type
Action Chain
You can chain multiple actions together by using the actions property. This allows you to execute multiple actions in a single script. The actions are executed in the order they are defined.
With the action chain, multiple actions can be impacted by the same trigger. With the targets & conditions that apply to all actions in the chain.
actions:
- triggers: messageCreate
actions:
- id: reply
args:
components:
- type: text-display
content: "This is a reply to your message."
- id: addReaction
args:
value: "✅"
conditions:
- id: inChannel
args:
value: "935421560355946596" # Channel ID or name