Skip to content

Commit 3713022

Browse files
committed
2 parents bc2cf24 + 4fa785f commit 3713022

1 file changed

Lines changed: 46 additions & 19 deletions

File tree

src/app/v5/guides/metadata/page.mdx

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Metadata allows you to store viewer specific data for use in Firebot.
44

55
You can use metadata by using the **Set User Metadata** and **Remove User Metadata** effects, found in the “Select New Effect” box when adding a new effect. They’re listed under the “ALL” and “Scripting” tabs. Metadata works by storing data (basically text) associated with a specific viewer's username.
66

7-
Using Metadata you can tailor interactive experiences to individual viewers like tracking stats, preferences, or progress within a game or loyalty system. It works similarly to [Custom Variables](/v5\guides\custom-variables\page.mdx), but custom variables are not associated with a single viewer, and unless you have changed the settings do not persist when you close Firebot, meaning that when you close Firebot all data is deleted. Metadata on the other hand is stored for each user persistently and can be used across Firebot sessions.
7+
Using Metadata you can tailor interactive experiences to individual viewers like tracking stats, preferences, or progress within a game or loyalty system. It works similarly to [Custom Variables](../custom-variables/page.mdx), but custom variables are not associated with a single viewer, and unless you have changed the settings do not persist when you close Firebot, meaning that when you close Firebot all data is deleted. Metadata on the other hand is stored for each user persistently and can be used across Firebot sessions.
88

99
## **Configuring Metadata Effects**
1010

1111
### **Username**
1212

13-
Specify the username for whom you want to configure or modify the metadata. This should generally be the `$user` variable to affect the user triggering the event.
13+
Specify the username for who you want to configure or modify the metadata. This should generally be the `$user` variable to affect the user triggering the event.
1414

1515
### **Metadata Key**
1616

@@ -22,36 +22,45 @@ This is the actual value you want to store under the specified Metadata Key. Thi
2222

2323
### **Advanced (Optional)**
2424

25-
You can click on the blue "Advanced" text to open up this section, which enables you to directly access or modify specific parts of complex data structures, such as arrays or objects, associated with the Metadata key. This is designed for advanced users already familiar with property paths.
26-
Most users can skip this section.
25+
You can click on the blue "Advanced" text to open the **Property Path** section. This enables you to directly access or modify specific parts of complex data structures, such as arrays or objects, already saved under the Metadata Key.
2726

28-
This is used for accessing or modifying specific parts of complex data structures like arrays or objects. Most users can skip this section, but here’s a quick overview:
27+
**Note:** If the metadata key does not already contain an object or array, entering a Property Path will do nothing.
28+
29+
When creating a Property Path, use **dot notation** to define which specific property or index you want to update:
2930

3031
- **Array Example:** `["apple", "banana", "cherry"]`
31-
Access "banana" with `$$myArray[1]`.
32+
To target "banana", the Property Path is: `1`
3233

3334
- **Object Example:** `{"fruit":"apple", "color":"red"}`
34-
Access "apple" with `$$myObject[fruit]`.
35-
36-
- **Array of Objects Example:**
37-
`[{"fruit":"apple"}, {"fruit":"banana"}]`
38-
Access "apple" with `$$myArray[0, fruit]`.
35+
To target "apple", the Property Path is: `fruit`
3936

40-
You can use the Property Path field to update a specific part of the variable without overwriting the entire structure.
37+
- **Array of Objects Example:** `[{"fruit":"apple"}, {"fruit":"banana"}]`
38+
To target "apple" in the first object, the Property Path is: `0.fruit`
4139

4240
<Note type="info">
43-
**Example**: To change the color of a fruit from red to yellow in `{"fruit":"apple", "color":"red"}`, set `Variable Name` to your object’s name, `Variable Data` to `yellow`, and `Property Path` to `color`.
41+
**Example**: To change the color of a fruit from red to yellow within an existing metadata object `{"fruit":"apple", "color":"red"}`:
42+
43+
* **Metadata Key:** (The name of your metadata key)
44+
* **Data:** `yellow`
45+
* **Property Path:** `color`
4446
</Note>
4547

4648
## **Accessing and Using Metadata**
4749

4850
Metadata is accessed using the `$userMetadata` replace variable.
4951

50-
* `$userMetadata[key]`
51-
* `$userMetadata[key, propertyPath]`
52+
* `$userMetadata[username, metadataKey]`
53+
Get the metadata associated with the user.
54+
55+
**Other examples**
56+
* `$userMetadata[username, metadataKey, defaultValue]`
57+
Provide a default value if one doesn't exist for the user.
58+
59+
* `$userMetadata[username, metadataKey, null, propertyPath]`
60+
Provide a property path (using dot notation) or array index as a second argument.
5261

5362
<Note type="info">
54-
**Example:** Once you have used a `Set User Metadata` effect to set the user data for one of your viewers you can use `$userMetadata[key]` to display a viewer's favorite color, if for example you saved the metadata as "favouriteColor" you would set `Key` to `favoriteColor`, and use `$userMetadata[favoriteColor]` in a chat message or overlay effect.
63+
**Example:** Once you have used a `Set User Metadata` effect to set the user data for one of your viewers you can use `$userMetadata[$user, metadataKey]` to display a viewer's favorite color, if for example you saved the metadata as "favoriteColor" you would set `metadataKey` to `favoriteColor`, and use `$userMetadata[$user, favoriteColor]` in a chat message or overlay effect.
5564
</Note>
5665

5766
## Example: Tracking Viewer Stats
@@ -63,7 +72,7 @@ Metadata is accessed using the `$userMetadata` replace variable.
6372

6473
* `Username`: `$user` (This ensures the metadata is stored for the user who triggered the command/reward)
6574
* `Metadata Key`: `checkInCount`
66-
* `Data`: `$numberMath[$userMetadata[checkInCount] + 1]`
75+
* `Data`: `$math[$userMetadata[$username, checkInCount] + 1]`
6776

6877
Every time this event is triggered, the user's `checkInCount` will increase by one.
6978
3. **Display the Stat:** In a chat message or overlay effect, use the following:
@@ -72,6 +81,24 @@ Metadata is accessed using the `$userMetadata` replace variable.
7281

7382
This will display the number of times the user has triggered the command or reward.
7483

75-
## Viewing and Managing Metadata
84+
## **Removing User Metadata**
85+
86+
If you need to clear data for a specific user (for example, resetting a viewer's stats or clearing a specific preference), you can use the **Remove User Metadata** effect.
87+
88+
### **Configuring the Effect**
89+
90+
### **Username**
91+
92+
Specify the username of the viewer whose metadata you want to remove. Use `$user` to affect the user currently triggering the command or event.
93+
94+
### **Metadata Key**
95+
96+
Enter the specific **Key** of the metadata you wish to delete.
97+
98+
<Note type="warning">
99+
**Note:** This effect completely removes the entry associated with the specified key from the user's database profile. If you stored a complex object or array under this key, the entire structure will be deleted.
100+
</Note>
101+
102+
## Viewing and Managing Metadata
76103

77-
You can view and manage metadata stored for a user by going to the "VIEWERS" tab in Firebot, selecting a viewer and looking at the "METADATA" table available there. You can see what metadata has been stored on the viewer, what the keys are to that data, and the data itself. You can also edit or delete metadata directly from this table.
104+
You can view and manage metadata stored for a user by going to the "VIEWERS" tab in Firebot, selecting a viewer and looking at the "METADATA" table available there. You can see what metadata has been stored on the viewer, what the keys are to that data, and the data itself. You can also edit or delete metadata directly from this table.

0 commit comments

Comments
 (0)