From 28cb36b5d56c562a45ef042b60cde30db26f6587 Mon Sep 17 00:00:00 2001 From: eniamza <65225917+Eniamza@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:59:43 +0600 Subject: [PATCH 1/2] Fix : Use RegEx instead of space character in split --- src/bot.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index e232669..46d0e8b 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -23,11 +23,11 @@ bot.on('message', msg => { //check if message is a command if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) { console.log(`treating ${msg.content} from ${msg.author} as command`); - let cmdTxt = msg.content.split(' ')[0].substring(botConfig.prefix.length); + let cmdTxt = msg.content.split(/ +/)[0].substring(botConfig.prefix.length); let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space if (msg.mentions.has(bot.user)) { try { - cmdTxt = msg.content.split(' ')[1]; + cmdTxt = msg.content.split(/ +/)[1]; suffix = msg.content.substring(bot.user.toString().length + cmdTxt.length + botConfig.prefix.length + 1); } catch (e) { //no command From a2596f0e931d15f7162048f56b7721c16c9be2d0 Mon Sep 17 00:00:00 2001 From: eniamza <65225917+Eniamza@users.noreply.github.com> Date: Sat, 20 Mar 2021 18:02:36 +0600 Subject: [PATCH 2/2] Fix : RegEx based split in tipbot.ts --- src/modules/tipbot.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/tipbot.ts b/src/modules/tipbot.ts index ac57b0a..0e17545 100644 --- a/src/modules/tipbot.ts +++ b/src/modules/tipbot.ts @@ -35,7 +35,7 @@ exports.tip = { let tipper = msg.author.id, words = msg.content .trim() - .split(' ') + .split(/ +/) .filter(function(n) { return n !== ''; }), @@ -68,7 +68,7 @@ exports.multitip = { let tipper = msg.author.id.replace('!', ''), words = msg.content .trim() - .split(' ') + .split(/ +/) .filter(function(n) { return n !== ''; }), @@ -93,7 +93,7 @@ exports.roletip = { let tipper = msg.author.id.replace('!', ''), words = msg.content .trim() - .split(' ') + .split(/ +/) .filter(function(n) { return n !== ''; }),