From 8a3f399b1fe734833d58fe5d11005d23cc71d0e8 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Mon, 9 Nov 2020 01:53:07 -0500 Subject: [PATCH] it works! pog --- cmd/lights.js | 2 +- lights/light_parser.js | 5 ++++- lights/request.js | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/lights.js b/cmd/lights.js index d3a3d80..7cf5bea 100644 --- a/cmd/lights.js +++ b/cmd/lights.js @@ -28,7 +28,7 @@ class LightsParser extends Command { req( instructions.filter((i) => i.valid), (response) => { - msg.channel.createMessage(`${response.statusCode}`); + msg.channel.createMessage(`${response}`); }, (error) => { msg.channel.createMessage(`error.`); diff --git a/lights/light_parser.js b/lights/light_parser.js index 543a333..2ef8e6d 100644 --- a/lights/light_parser.js +++ b/lights/light_parser.js @@ -109,7 +109,10 @@ function parseSingleInstruction(str = '') { item.errors = 'Not enough arguments.'; return item; } - inst_args = parsed_args[1].split(',').map((s) => (available_targets[s] ? s : parseInt(s.trim()))); + inst_args = parsed_args[1] + .split(',') + .map((s) => s.trim()) + .map((s) => (available_targets[s] ? s : parseInt(s))); if (!inst_args.length) { item.errors = 'No valid args.'; } diff --git a/lights/request.js b/lights/request.js index dd47d90..ac05297 100644 --- a/lights/request.js +++ b/lights/request.js @@ -24,5 +24,11 @@ export default function req(data, callback, errorCallback) { client.write(string_data); } client.destroy(); + callback('success.'); + }); + + client.on('error', (e) => { + client.destroy(); + errorCallback(e); }); }