From e40671a52496540fda0a6822d932c3ecc3975b23 Mon Sep 17 00:00:00 2001 From: Histmy Date: Mon, 7 Dec 2020 12:47:48 +0100 Subject: [PATCH] Perhaps better way of splitting message --- app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 527b535..acb240a 100644 --- a/app.js +++ b/app.js @@ -60,10 +60,9 @@ client.on('ready', () => console.log('A jedeš!')); client.on('message', mes => { if (process.env.IGNORE_MESS) return; - if (mes.content.toLowerCase().startsWith(prefix)) { - const [...args] = mes.content.toLowerCase().split(' ').slice(1); - const komand = args[0]; - const celArgs = args.slice(1).join(' '); + const [mes_prefix, komand, ...args] = mes.content.toLowerCase().split(' '); + if (mes_prefix === prefix) { + const celArgs = args.join(' '); let corict; let vojs; switch (komand) {