@lumiastream/lumia-types 2.8.1 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ ---
2
+ sidebar_position: 3
3
+ title: Custom actions
4
+ description: Custom Actions allow you to tap into how Lumia Stream calls actions from the inside
5
+ ---
6
+
7
+ `Custom Actions` allow you to tap into how Lumia Stream calls actions from the inside.
8
+ `Custom Actions` are mainly meant for things that we haven't added as a `Helper function` yet. For instance, actions for Spotify, Twitch, Streamer.Bot etc are all actions that we do not have a have helper functions for. This is where an action will step in.
9
+
10
+ You can use actions by just passing in one object, or an array of objects.
11
+ If you pass in an array of actions then any action that can be awaited will be wait until the promise has been resolved.
12
+
13
+ This documentation for every action we use in Lumia can get extremely broad, so we will give examples for different actions, but if you get stuck please visit our [**Discord**](https://discord.gg/R8rCaKb) to ask us any questions.
14
+
15
+ Let's get started:
16
+
17
+ ### Generic Action
18
+
19
+ `actions([ { base: "lumia", type: "tts", value: { message: "Hello" }, variables: {} } ]);`:
20
+
21
+ #### Before we begin, let's dissect this.
22
+
23
+ `base`: will be the base of actions that can be used with Custom Code. The different bases are:
24
+ `delay, lumia, overlay, api, websocket, commandRunner, inputEvent, obs, slobs, twitch, twitter, streamerbot, midi, osc, artnet, mqtt, serial, broadlink, spotify, vlc, voicemod`
25
+
26
+ `type`: Every base has different action types. For instance, the base `lumia` has: `chatbot, tts, setStreamMode, toggleStreamMode` and much more.
27
+ To find the list of types that each base has below. Check in the side bar to quickly get to the base you're interested in.
28
+
29
+ `value`: can sometimes be an object and sometimes a string, it all depends on the `base` and `type`
30
+
31
+ `variables`: allows you to send in different variables for each action. But do note that the variables that are already on the command/alert will also be spread on to this variables object. Variables are not required
32
+
33
+ There are more fields that are sometimes used in actions. We will try to list out as many common examples down below along with the schema for them
34
+
35
+ #### More documentation coming soon
@@ -0,0 +1,40 @@
1
+ ---
2
+ sidebar_position: 1
3
+ title: Create counter
4
+ ---
5
+
6
+ You can set up a manual counter so that you can trigger multiple things based on the counter value
7
+
8
+ e.g. the code below will trigger a command named **'money-12'** when the **counter = 12**
9
+
10
+ ```js
11
+ async function() {
12
+
13
+ // You can get your variable's value that you just set here
14
+ let redeemCount = await getVariable('redeemCount');
15
+
16
+ if (!redeemCount) {
17
+ // If variable does not exist it will create it
18
+ redeemCount = await setVariable({ name: 'redeemCount', value: 10 });
19
+ }
20
+
21
+ redeemCount++;
22
+ await setVariable({ name: 'redeemCount', value: redeemCount });
23
+
24
+ if (redeemCount === 12) {
25
+ // call the command named money-12
26
+ callCommand({ name: 'money-12' });
27
+ // show a popup message in the Lumia stream app with '{{username}} is the 12th redeemer' inside
28
+ showToast({ message: '{{username}} is the 12th redeemer' });
29
+ }
30
+
31
+ // always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
32
+ done();
33
+ }
34
+ ```
35
+
36
+ :::tip
37
+
38
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
39
+
40
+ :::
@@ -0,0 +1,36 @@
1
+ ---
2
+ sidebar_position: 6
3
+ title: Global Store (Persistent Storage)
4
+ ---
5
+
6
+ # Storing data for Custom Code
7
+
8
+ We expose a global store that you can use with your custom code to store any data type that you need to and it will be persisted. This is useful to store things like arrays and objects without needing to store them in variables.
9
+
10
+ There are 4 different functions that you can use with the Store:
11
+
12
+ ```md
13
+ - getStore()
14
+ - getStoreItem(name: string)
15
+ - setStore({ name: string; value: any })
16
+ - resetStore()
17
+ ```
18
+
19
+ ```js
20
+ async function() {
21
+ let tempUsers = await getStoreItem('users');
22
+ if (!tempUsers) {
23
+ tempUsers = [];
24
+ }
25
+ tempUsers.push("{{username}}");
26
+ await setStore({ name: 'users', value: tempUsers });
27
+ showToast({ message: tempUsers.length, time: 10000 });
28
+ done();
29
+ }
30
+ ```
31
+
32
+ :::tip
33
+
34
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
35
+
36
+ :::
@@ -0,0 +1,38 @@
1
+ ---
2
+ sidebar_position: 2
3
+ title: Random Twitch Clip
4
+ ---
5
+
6
+ # Randomly getting the latest Twitch Clip from a user
7
+
8
+ You can call requests from integrations that we support that have an access token. You can also pass in variable values when calling other commands/alerts to pass in extra data that you may need in that command.
9
+
10
+ ```js
11
+ async function() {
12
+ try {
13
+ const twitchToken = await getToken('twitch');
14
+ const twitchClientId = await getClientId('twitch');
15
+
16
+ // userId is a variable that comes from chat commands. This will get the clips of the user who's chatting
17
+ const clipsRes = await fetch('https://api.twitch.tv/helix/clips?broadcaster_id={{userId}}', {
18
+ headers: {
19
+ Authorization: `Bearer ${twitchToken}`,
20
+ 'Client-ID': twitchClientId
21
+ }
22
+ });
23
+ const clips = (await clipsRes.json())?.data;
24
+ const randomClip = clips[Math.floor(Math.random() * clips.length)];
25
+ chatbot({ message: `${randomClip.title}: ${randomClip.url}` });
26
+ } catch (err) {
27
+ showToast({ message: 'error: ' + err.message });
28
+ }
29
+
30
+ done({ variables: { user_clip_title: randomClip.title, user_clip: randomClip.url } });
31
+ }
32
+ ```
33
+
34
+ :::tip
35
+
36
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
37
+
38
+ :::
@@ -0,0 +1,29 @@
1
+ ---
2
+ sidebar_position: 3
3
+ title: Roll dice
4
+ ---
5
+
6
+ # Roll a dice with Text To Speech
7
+
8
+ You can use Javascript to randomly pick a number and if it lands on your chosen number the user will get a special Text To Speech shoutout
9
+
10
+ ```js
11
+ async function() {
12
+ const diceRoll = Math.ceil(Math.random()*6);
13
+
14
+ if (diceRoll === 3) {
15
+ tts({ message: "Congratulations {{username}}! You rolled a 3", voice: "default", volume: 100 })
16
+ // you can switch between all the tts option that we support
17
+ // tts({ message: "Congratulations {{username}}! You rolled a 3", voice: "Brian", volume: 100 })
18
+ }
19
+
20
+ // always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
21
+ done();
22
+ }
23
+ ```
24
+
25
+ :::tip
26
+
27
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
28
+
29
+ :::
@@ -0,0 +1,41 @@
1
+ ---
2
+ sidebar_position: 4
3
+ title: Different Chatbot message for user levels
4
+ ---
5
+
6
+ # Different Chatbot message for user levels
7
+
8
+ You can check the different userlevels for the person chatting and do different things based on their user level.
9
+ In this example we'll be sending different chatbot messages based on the users level.
10
+
11
+ ```js
12
+ async function() {
13
+ // {{userLevelsRaw}} returns an object with the various user levels on it. Since we want the original object here we're using getVariable instead of using template variables
14
+ const userLevels = await getVariable('userLevelsRaw');
15
+
16
+ if (!userLevels) {
17
+ chatbot({ message: `Thanks for lurking in my stream {{username}}. You triggered {{command}}!` });
18
+ } else if (userLevels.isSelf) {
19
+ chatbot({ message: "Don't worry it's just me triggering a command named !{{command}}" });
20
+ } else if (userLevels.subscriber || userLevels.tier3 || userLevels.tier2 || userLevels.tier1) {
21
+ chatbot({ message: "Wow, you're a subscriber? Thanks for triggering {{command}}. Have a nice day!" });
22
+ } else if (userLevels.mod) {
23
+ chatbot({ message: 'Thank you for being a wonderful mod. My mod {{username}} triggered {{command}}!' });
24
+ } else if (userLevels.vip) {
25
+ chatbot({ message: 'VIPS raise the roof! {{username}}, the real VIP, triggered {{command}}!' });
26
+ } else if (userLevels.follower) {
27
+ chatbot({ message: `Thanks for being a loyal follower {{username}}. You triggered {{command}}!` });
28
+ } else {
29
+ chatbot({ message: `Thanks for lurking in my stream {{username}}. You triggered {{command}}!` });
30
+ }
31
+
32
+ // always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
33
+ done();
34
+ }
35
+ ```
36
+
37
+ :::tip
38
+
39
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
40
+
41
+ :::
@@ -0,0 +1,30 @@
1
+ ---
2
+ sidebar_position: 5
3
+ title: Track subscribers
4
+ ---
5
+
6
+ # Read/Write to a file to keep track of subscribers
7
+
8
+ You can read from a file and get values from it as well as write to a file.
9
+ This can be very useful if other apps are reading and writing to a text file. An example of this is OBS text sources
10
+
11
+ ```js
12
+ async function() {
13
+ // You have the ability to overwrite the whole file by setting append to false, or appending to the file in case you would like to keep a log of things
14
+ await writeFile({ path: 'C: \\Users\\Lumia\\Desktop\\lastSubscriber.txt', message: '{{username}}\n', append: true });
15
+
16
+ // You can get your variable's value that you just set here
17
+ const lastSubscribers = await readFile('C:\\Users\\Lumia\\Desktop\\lastSubscriber.txt');
18
+
19
+ showToast({ message: 'The last subscribers were: ' + lastSubscribers });
20
+
21
+ // always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
22
+ done();
23
+ }
24
+ ```
25
+
26
+ :::tip
27
+
28
+ **code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
29
+
30
+ :::
@@ -0,0 +1,29 @@
1
+ # Lumia Stream Custom Code GPT Instructions
2
+
3
+ Use this with the Custom Code docs:
4
+ - `what-is-custom-javascript.md`
5
+ - `important-notes.md`
6
+ - `helper-functions.md`
7
+ - `custom-actions.md`
8
+ - `examples/*.md`
9
+
10
+ ## Required Output Rules
11
+
12
+ 1. Always generate JavaScript (not TypeScript).
13
+ 2. Prefer returning a full Lumia Custom Code wrapper:
14
+
15
+ ```js
16
+ async function() {
17
+ // logic
18
+
19
+ // Make sure you call done() to avoid memory leaks
20
+ done();
21
+ }
22
+ ```
23
+
24
+ 3. Always call `done()` exactly once before finishing the function, unless the user explicitly asks for a partial snippet.
25
+ 4. Do not output markdown fences or prose when the caller expects code-only output.
26
+ 5. Use helper functions documented in `helper-functions.md` instead of inventing undocumented APIs.
27
+ 6. Keep examples compatible with Lumia variable syntax (e.g. `{{username}}`).
28
+ 7. When accessing numeric variables, parse values safely before math/comparisons.
29
+ 8. If a capability is not documented, state that clearly and provide a safe alternative.