diff --git a/instance.js b/instance.js index 3c0f9be..ef5050e 100644 --- a/instance.js +++ b/instance.js @@ -8,12 +8,15 @@ class InstancePlugin extends BaseInstancePlugin { onControllerConnectionEvent(event) { if (event === 'connect') { - for (let [action, content] of this.messageQueue) {this.instance.sendTo('controller', new InstanceActionEvent(this.instance.name, action, content))}; + for (const [action, content] of this.messageQueue) {try {this.instance.sendTo('controller', new InstanceActionEvent(this.instance.name, action, content))} catch (err) {this.messageQueue.push([output.action, output.message])}} this.messageQueue = []; } } - async onOutput(output) {if (output.type == 'action') {if (this.host.connector.connected) {this.instance.sendTo('controller', new InstanceActionEvent(this.instance.name, output.action, output.message));} else {this.messageQueue.push([output.action, output.message]);}}} + async onOutput(output) { + if (output.type !== 'action') return; + if (this.host.connector.connected) {this.instance.sendTo('controller', new InstanceActionEvent(this.instance.name, output.action, output.message))} else {this.messageQueue.push([output.action, output.message])} + } } module.exports = {InstancePlugin};