HarutoHiroki / Discord.js-Bot

An Open Source version of Cryptonix X and a basic frame for any discord.js bot
MIT License
91 stars 60 forks source link

Use regex instead of a string #23

Closed mchccn closed 3 years ago

mchccn commented 3 years ago

With this regex, you can parse arguments correctly. If I did !help arg arg arg it would've given me over 10 arguments, not 3. I have used \s+ as the regex to match all whitespace between arguments, and I have also used .shift() for more concise code.

HarutoHiroki commented 3 years ago

I don't quite see how that command would give you over 10 arguments (example here: https://i.is-really.fun/180221_EiDfB.png ). I also used https://regexr.com/ to test out your regex but it only matches the first whitespace, not all the spaces between the arguments. Maybe a little mistake somewhere?

HarutoHiroki commented 3 years ago

I see it now GitHub ignores all the spaces in between those args I see. In which case I agree that using a regex is better but still your regex still only registers the first space according to https://regexr.com/

HarutoHiroki commented 3 years ago

nvm the test is flawed I tested locally it works :))