Comments (3)
Providing args as a list of strings, which would be the current args but split by spaces
It's one line to put String[] splitArgs = args.split("\\s+");
into your command, and we don't want to do this all the time, as that's a large overhead for a niche thing.
An optional minimum and maximum amount of required arguments for commands that require them (for example, a command could require one or two arguments, replying with feedback when not enough or too many arguments are provided)
I can see merit in this. However, you could just write your own class that extends Command
that does this.
Support for flags, enabling things like
-c
for compact output for mobile users
While flags are easy to understand for programmers/developers, the majority of users (from my experience developing bots used by hundreds of thousands of servers) don't understand flags, so I don't think we'd want this to be the default behavior of jda-utils. Additionally, if you want custom arguments parsing (like flags), I'm sure there are libraries out there that you could use that take in a string (from CommandEvent#getArgs()
) and will do the parsing for you.
Overall, I'm not sure what benefit there would be to adding this suggestion in, as you can already make a class that extends Command
and plug in whatever arguments-parsing library or custom code that you want.
public abstract class SplitArgsCommand extends Command
{
protected int numArgs = 0; // 0 for no limit to number of args
protected String split = "\\s+";
@Override
public void execute(CommandEvent event)
{
String[] args = numArgs == 0 ? event.getArgs().split(split) : event.getArgs().split(split, numArgs);
if(numArgs != 0 && args.length < numArgs)
{
event.replyError("Too few arguments provided. Expected " + numArgs + " arguments!");
return;
}
doCommand(event, args);
}
abstract void doCommand(CommandEvent event, String[] args);
}
from jda-utilities.
My aim is to reduce boilerplate code that I see returning in almost every command I write. Extending the Command
class would do just that.
I looked through some other projects and noticed a few that could benefit from this. It's up to you whether you want to extend your project with this functionality. If you don't I'll happily use your suggested approach and maybe even send you a pull request down the line.
from jda-utilities.
Closing this for being stale.
from jda-utilities.
Related Issues (20)
- Wrong Boolean Logic
- help command doesn't show any commands HOT 6
- Cannot get all members of the guild HOT 2
- When using Emotes ButtonMenu does not respond to reactions HOT 2
- Fix imports to new version JDA HOT 4
- Doesn't work at all. HOT 10
- [Bug] Latest version JAR still uses net.dv8tion.jda.core instead of net.dv8tion.jda.api. HOT 7
- Paginator reaction buttons don't work. HOT 1
- [Feature] Support for >2 prefixes + mention prefixes HOT 5
- JDA Refactoring
- No documentation on writing tests
- Migrate to something else than Bintray HOT 7
- Command just doesnt Work HOT 1
- Commands dont Work HOT 9
- ButtonMenu.Builder.build().display() does not work HOT 1
- Please update the JDA Version to 4.3.0 HOT 1
- Move to Maven Central HOT 5
- feature proposal
- [Proposal] new featrue HOT 3
- replit Code Probleme net.dv8tion.jda HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jda-utilities.