0x1DEA / Bingo

Discord bot that gives users a Bingo role on command. Then generates a gif of their pfp being crushed by a tombstone
MIT License
2 stars 1 forks source link

Nicknames do not support spaces #7

Open satyrnidae opened 5 years ago

satyrnidae commented 5 years ago

Currently args are split on spaces. This means that the user cannot specify a nickname unless it is all one word, or uses spacers like underlines or other non-letter characters. Proposal: a new tokenization function is introduced that will allow the user to specify a multiple word nickname by enclosing the corresponding argument between quotes.

0x1DEA commented 5 years ago

In the latest commit, nick names are the final argument and do support spaces because of rest parameters. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters However, this means the arguments before it must be defined. Keeping this open because I would eventually like to add this in the way you suggested.

AnthonyLenglet commented 5 years ago

wouldn't it be possible to use yargs for the command? this could help (would also get rid of the specific order)

0x1DEA commented 5 years ago

wouldn't it be possible to use yargs for the command? this could help (would also get rid of the specific order)

@AnthonyLenglet How would that work? Can you give an example?

Sent with GitHawk

AnthonyLenglet commented 5 years ago

yargs is for commands sent via the cmd, so I don't know if it works for any strings, but I'm assuming it would (guessing its just a matter of sending a string to a function and getting an object back)

!bingo -p @see --name="See Beyond" --time=10

would return

{
    "person": "see<discordId>",
    "name": "See Beyond",
    "tomb": "Default",
    "time": 10
}
0x1DEA commented 5 years ago

Seems a bit to long. Would something like !bingo @user (this one will always be first and is always mandatory) -t 1m (this could be optional and have a default value) -n Nickname (this too) -s default (And this) work? Because if so then I can make those changes

Sent with GitHawk

0x1DEA commented 5 years ago

yargs is for commands sent via the cmd, so I don't know if it works for any strings, but I'm assuming it would (guessing its just a matter of sending a string to a function and getting an object back) ...

@AnthonyLenglet it seems https://www.npmjs.com/package/yargs-parser could be what we’re looking for

Sent with GitHawk