From 5afe40b56af02ba411a79f21cdb1f73efaa2fa1b Mon Sep 17 00:00:00 2001 From: RavenX8 <7156279+RavenX8@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:30:49 -0500 Subject: [PATCH] Added an action to execute code triggers --- actions.js | 40 +++++++++++++++++++++++++++++++++++++++- main.js | 4 ++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/actions.js b/actions.js index 09bc6d4..a7ef8c7 100644 --- a/actions.js +++ b/actions.js @@ -30,7 +30,7 @@ export default function (self) { id: 'actionArgs', type: 'textinput', label: 'Action Arguments', - default: 0, + default: '', }, ], callback: async (event) => { @@ -84,5 +84,43 @@ export default function (self) { 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) + }, + }, }) } diff --git a/main.js b/main.js index 4575505..16632d1 100644 --- a/main.js +++ b/main.js @@ -15,6 +15,7 @@ class ModuleInstance extends InstanceBase { this.config = {} this.credits = {} this.actions = [] + this.triggers = [] this.activeViewers = 0 this.dataArray = [] } @@ -55,6 +56,9 @@ class ModuleInstance extends InstanceBase { await this.client.getActions().then((value) => { this.actions = value }) + await this.client.getCodeTriggers().then((value) => { + this.triggers = value + }) await this.client.getActiveViewers().then((value) => { this.activeViewers = value.count })