I'm building a bot that will take commands through Discord Channels like "!COMMAND Some Thing With Spaces In The Name <@123412341234>"
I need a regex expression that, while using javascript, will allow me to get the following:
const args = ["COMMAND", "Some Thing With Spaces In The Name", "<@123412341234>"];
OR, in the absence of the user mention at the end:
const args = ["COMMAND", "Some Thing With Spaces In The Name"];
I've tried using (\S+)\s(.+)(\s<@\d+>)?
but what I get looks like:
const args = ["COMMAND", "Some Thing With Spaces In The Name <@123412341234>"];
I need the mention separate. What I'm most interested in is the COMMAND and the argument after it without the mention. Which could be in the command or not. I know I can get the mention by doing message.mentions.users.first()
. That's not really what I'm after.
Any help would be greatly appreciated. Thank you.