Saving Data with Meta
Meta is a new system in ItsMyBot that allows you to save custom data for later use. This makes the scripting system even more powerful. For example, you can easily create a counting channel with it.
Each meta need to be created in the scripting/metas
folder in the bot's directory. It's support subfolders, so you can organize your metas as you want. You can put multiple metas in each .yml file.
Meta Structure
In each files, you can define multiple metas. Each meta is a YAML file that contains the following structure:
key: #string, the name of the meta, used to retrieve it later.
type: #string, the type of the meta, can be `number`, `string`, `boolean` or `list`
mode: #string, the mode of the meta, can be `global`, `user`, `channel` or `message`
default: #string, the default value of the meta, used if the meta is not set.
Dictionary of Meta Properties
- Name
key
- Type
- string
- Description
The key is the name of the meta. It can be anything you want, but it should be unique to avoid conflicts with other metas.
- Name
type
- Type
- string
- Description
The type of the meta. Can be
number
,string
,boolean
orlist
. This is used to determine how the data will be stored and how it can be used.
- Name
mode
- Type
- string
- Description
The mode of the meta. Can be
global
,user
,channel
ormessage
. This is used to determine where the data will be stored. The global mode is used to store data that is shared across all users and channels. The user mode is used to store data that is specific to a user. The channel mode is used to store data that is specific to a channel.
- Name
scope
- Type
- string
- Description
The scope of the meta. It is the ID of the user or channel used to retrieve the stored information. This is only used for
user
andchannel
modes.
- Name
value
- Type
- any
- Description
The value is the data that you want to store. It can be anything you want.
How to use Meta
To use meta, you need to define them in the scripting/metas
folder as shown above. Once defined, you can use them in your scripts, custom commands, and embeds.
You can use meta in your scripts, custom commands, embeds, and more.
- You can find the meta actions in the actions section.
- Meta also have their own placeholders, that you can found in the placeholders section.
- You can also use commands to interact with meta data. You can find the commands in the commands section.
Examples
actions: # This script will create a counting channel.
- triggers: messageCreate
conditions:
- id: inChannel
args:
value: 'counting-channel' # The channel where the counting will take place.
- id: '!isBot' # The message must not be sent by a bot.
- expression: '%content% == %meta_counting%+1' # The message must be the next number in the sequence.
not-met-actions: # If the message is not the next number in the sequence, send a reply.
- id: reply
args:
components:
- type: text-display
content: "You need to send the next number in the sequence: %math_{meta_counting}+1%"
actions:
- id: deleteMessage # Delete the reply after 10 seconds.
args:
delay: 10
- id: deleteMessage # Delete the original message.
actions:
- id: metaAdd # Add the number to the meta data.
args:
key: 'counting'
value: '1' # The value to add to the meta data.