You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/v5/guides/metadata/page.mdx
+46-19Lines changed: 46 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ Metadata allows you to store viewer specific data for use in Firebot.
4
4
5
5
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.
6
6
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.
8
8
9
9
## **Configuring Metadata Effects**
10
10
11
11
### **Username**
12
12
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.
14
14
15
15
### **Metadata Key**
16
16
@@ -22,36 +22,45 @@ This is the actual value you want to store under the specified Metadata Key. Thi
22
22
23
23
### **Advanced (Optional)**
24
24
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.
27
26
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:
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`
41
39
42
40
<Notetype="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`
44
46
</Note>
45
47
46
48
## **Accessing and Using Metadata**
47
49
48
50
Metadata is accessed using the `$userMetadata` replace variable.
Provide a property path (using dot notation) or array index as a second argument.
52
61
53
62
<Notetype="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.
55
64
</Note>
56
65
57
66
## Example: Tracking Viewer Stats
@@ -63,7 +72,7 @@ Metadata is accessed using the `$userMetadata` replace variable.
63
72
64
73
*`Username`: `$user` (This ensures the metadata is stored for the user who triggered the command/reward)
Every time this event is triggered, the user's `checkInCount` will increase by one.
69
78
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.
72
81
73
82
This will display the number of times the user has triggered the command or reward.
74
83
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
+
<Notetype="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
76
103
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