Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Args as array #27

Closed
quinnvaughn opened this issue Oct 27, 2020 · 5 comments
Closed

Args as array #27

quinnvaughn opened this issue Oct 27, 2020 · 5 comments
Labels
v4 Issue related to v4 (@Command)

Comments

@quinnvaughn
Copy link

Is there an easy way to just get the args as one array? Adding an actual :args only gets the first or however many, but I'm looking for an indeterminant amount of inputs (well up to 5).

@dbrxnds
Copy link
Contributor

dbrxnds commented Nov 4, 2020

Do you have an example of how you think this would work?

My first thought would assume something like this:

// Message: -command May the force be with you
const args = message.args

args[0] = may
args[1] = the
args[2] = force
...

But this still has many questionable issues with it.

@quinnvaughn
Copy link
Author

quinnvaughn commented Nov 4, 2020

I would think you'd specify in the string and it would check for that.

Something like

@Command("create :name :type\array")

Wouldn't have to be exactly that, but just some wording it would parse for to let it be known that it's an array (the type arg in this example).

I'm not sure if in that case, it would require it to be enclosed by brackets in the command or if it just could only be the last argument. You might be able to specify the escape character.

@quinnvaughn
Copy link
Author

quinnvaughn commented Nov 4, 2020

Right now what I'm doing is taking multiple inputs by splitting the command after the command text, and then regexing it by strings enclosed in double-quotes, but I think this library probably could do that automatically for us.

Basically like this:

!prefix submit "this is one" "this is two"

@AndyClausen
Copy link
Contributor

I agree that when something is surrounded by quotes, it should be parsed as a single arg. However, I don't think parsing multiple args as an array is realistic. Maybe edit the issue to only be about quoted args?

@AndyClausen
Copy link
Contributor

This should be fixed in the slash commands version (5.x) 🙂

@owengombas owengombas added the v4 Issue related to v4 (@Command) label Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v4 Issue related to v4 (@Command)
Projects
None yet
Development

No branches or pull requests

4 participants