appellation / handles Goto Github PK
View Code? Open in Web Editor NEWA simple Discord command handler.
Home Page: https://handles.topkek.pw
License: MIT License
A simple Discord command handler.
Home Page: https://handles.topkek.pw
License: MIT License
All complaints/enhancements to arguments that was changed in v3, which we've been discussing on Discord for some time now. ๐
Optional arguments
Creation of optional arguments has it's issues since providing the Prompt
is redundant.
Example:
yield new Argument('My prompt', 'My rePrompt').setOptional() // Prompt not needed.
Since the Prompt
is only given if there's a must for the argument there is no need to pass it. The only reason to pass it is to have the ability to set the rePrompt
which might be needed in case the optional argument fails.
On top of that which is a minor detail: setOptional()
is is defaulted to true but you have the ability to set it to false, I don't see why you would need to set it to false if your argument isn't optional? Simply don't use the method. (Unless you would like to disable the optional part on the fly without having to delete a line of code.)
Named arguments
More detail on issue: #4
Named arguments can provide cleaner code, let's say you have a roll
command and you have the input of min
and max
.
let min = command.args[0]
let max = command.args[1]
Creating variables to use in our command makes it easier to find out what you're working with, also you won't have to repeat the whole command.args[index]
over and over. This will especially repeat itself in more complex commands if needed.
Having the ability to track down your arguments the following way:
command.args.min
command.args.max
Would not only make it easier to repeat and cleaner to look at, it will also make error messages easier to work with if you do not decide to create variables for each argument.
Usage of command.body
The command.body
gives the entire body of the command without the prefix & command name. This comes in handy if you're working with arguments that are in multiple words. For instance if you have a translation command and you wish to translate a sentence.
However, new Argument()
treats every word as it's own argument. Creation of the argument is only needed to let the user know that there is indeed an argument needed. (Prompt/rePrompt
) But you do not make use of the command.args
when you write the actual execution of the command.
It seems that you jump a bit back and forth depending on when you're using a single worded argument & a multiple worded "argument". Could be moved together somehow.
Creation of argument suffix
Just a friendly reminder to remember that there should be an ability to set the argument suffix without having to instantiate the argument class and manually setting the suffix property BEFORE yielding it.
Consider making arguments named so they can use an object rather than an array.
Should probably use more comprehensive linting.
There should exist functionality for middleware to be run globally before all commands.
The argument processor doesn't correctly interpret args provided to commands that are not cased correctly. This probably is because the command doesn't get trimmed off correctly when it's not lower case.
The argument resolver gets called even if the matched content is empty. This is undesirable and should automatically result in a prompt if the argument is required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.