MSFTserver / TipBot

Crypto coin TipBot for discord
MIT License
40 stars 117 forks source link

parser is too whitespace sensitive #7

Closed Zedsquared closed 6 years ago

Zedsquared commented 6 years ago

Use of string.split(" ")[x] to reference parts of the message leads to the commands being sensitive to the number of spaces between parameters which is difficult to spot on screen. So, using . as space here for clarity: "!tip..@username..5" fails as the username is parsed as a space. better to use regex as shown here: https://blog.abelotech.com/posts/split-string-into-tokens-javascript/

MSFTserver commented 6 years ago

i just tried it and it works fine...

Sent from my Galaxy Note5 using FastHub

Zedsquared commented 6 years ago

My apologies, I think I have the wrong project, there is definitely a tip bot on discord exhibiting this behavior and I thought ( after a too brief scan of code ) that line 162 of bot.js was the cause. If msg.content already arrives tokenised with single spaces between words then that line ( and others like it such as 19 ... 24 in dogeTipper.js ) won't be a problem but if it's the raw text that the user typed then it may bite on occasion.

MSFTserver commented 6 years ago

well for the member it jsut grabs msg.mentions.first() and whatever the next word is the amount o think it skips spaces and null values so no matter how many spaces the second value in the array should be the number