Added an action to execute code triggers

This commit is contained in:
2024-01-30 14:30:49 -05:00
parent 9fafe2b318
commit 5afe40b56a
2 changed files with 43 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ export default function (self) {
id: 'actionArgs', id: 'actionArgs',
type: 'textinput', type: 'textinput',
label: 'Action Arguments', label: 'Action Arguments',
default: 0, default: '',
}, },
], ],
callback: async (event) => { callback: async (event) => {
@@ -84,5 +84,43 @@ export default function (self) {
await self.client.testCredits() await self.client.testCredits()
}, },
}, },
runTrigger: {
name: 'Run Code Trigger',
options: [
{
id: 'trigger',
type: 'dropdown',
label: 'Trigger',
default: '',
choices: self.triggers.triggers.map((value) => ({ label: value.name, ...value })),
},
],
callback: async (event) => {
console.log('Run Trigger!', event.options.action)
await self.client.executeCodeTrigger(event.options.trigger)
},
},
runTriggerAdvanced: {
name: 'Run Code Trigger Advanced',
options: [
{
id: 'trigger',
type: 'dropdown',
label: 'Trigger',
default: '',
choices: self.triggers.triggers.map((value) => ({ label: value.name, ...value })),
},
{
id: 'triggerArgs',
type: 'textinput',
label: 'Trigger Arguments',
default: '',
},
],
callback: async (event) => {
console.log('Run Trigger!', event.options.action)
await self.client.executeCodeTrigger(event.options.trigger, event.options.triggerArgs)
},
},
}) })
} }

View File

@@ -15,6 +15,7 @@ class ModuleInstance extends InstanceBase {
this.config = {} this.config = {}
this.credits = {} this.credits = {}
this.actions = [] this.actions = []
this.triggers = []
this.activeViewers = 0 this.activeViewers = 0
this.dataArray = [] this.dataArray = []
} }
@@ -55,6 +56,9 @@ class ModuleInstance extends InstanceBase {
await this.client.getActions().then((value) => { await this.client.getActions().then((value) => {
this.actions = value this.actions = value
}) })
await this.client.getCodeTriggers().then((value) => {
this.triggers = value
})
await this.client.getActiveViewers().then((value) => { await this.client.getActiveViewers().then((value) => {
this.activeViewers = value.count this.activeViewers = value.count
}) })