discordjs / builders

A collection of builders that you can use when creating your bot.
Apache License 2.0
97 stars 37 forks source link

Builder for listing items in a list (for `and` and `or`) #31

Closed mahyarmirrashed closed 3 years ago

mahyarmirrashed commented 3 years ago

Is your feature request related to a problem? Please describe. No, this feature request is not related to any problem with the library at the moment.

Describe the ideal solution There are frequently times in my code where I would like to present a dynamic list of strings to a user. Sometimes, this list is separated by commas due to its length. A builder would be useful here to perform the tedious formatting for me.

[] => ''
['alpha'] => 'alpha'
['alpha', 'beta'] => 'alpha or beta'
['alpha', 'beta', 'gamma'] => 'alpha, beta, or gamma'

There should be an option to select whether the option should be with and or with or. Additionally, there should be a boolean for the Oxford comma no-believers.

Describe alternatives you've considered The obvious other option would be to construct my own builder but it might be better to include it in this library as a common function for other developers out there.

Additional context Please ask specific questions relating to this request as necessary. Nothing else to add! :)

kyranet commented 3 years ago

Just use Intl.ListFormat, achieves the exact same thing you want and in top of it, also supports multiple languages.