-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next Version PR #14
Next Version PR #14
Conversation
🎉 True Hybrid Command SupportThis version of Velen now officially supports TRUE Hybrid command which means you can now use a single handler for both slash commands and message commands. An example of which is: VelenCommand.ofHybrid("dtest", "This is a dtest command.", velen, (event, responder, user, args) -> {
if(args.length() > 0 && args.get(0).asString().isPresent()) {
responder.setContent("Hello " + args.get(0).asString().get()).respond();
} else {
responder.setContent("Hello World!").respond();
}
}, SlashCommandOption.create(SlashCommandOptionType.STRING, "name", "Your name.", false)) .attach();
|
🎁 Subcommand support!Velen now supports subcommands with the newest commit, to access a subcommand, all you have to do is get the option then run it through
An example of fetching a subcommand would be: (event, responder, user, args) -> {
if(args.length() > 0 && args.get(0).asSubcommand().length() > 0
&& args.get(0).asSubcommand().get(0).asString().isPresent()) {
responder.setContent("Hello " + args.get(0).asSubcommand().get(0).asString().get()).respond();
}
} |
💘 A more automated slash command updater.Velen now offers a new integrated module which allows you to automatically update slash commands in a more automated way, this module checks for any differences between slash commands (global ones) to the tiniest bit like options, names or descriptions then updates them accordingly. There are two different modes to this:
📦 How to use?To use this module, all you have to do is create a new Velen velen = ...
DiscordApi api = ...
new SlashCommandChecker(api, SlashCommandCheckerMode.NORMAL).run(velen); The method 💭 Is this blocking?Despite being a Other than that, after the initial |
This reverts commit 6155412.
📝 Interaction Support for PaginateThis version of Velen now supports interactions for Pagination Helper, please note that this change has introduced a major breaking change for any code that uses new PaginateSimpleEvent<String> {
...
} And here is how it looks in this new version: new PaginateSimpleEvent<MessageBuilder, MessageCreateEvent, String> {
...
} new PaginateSimpleEvent<InteractionOriginalResponseUpdater, InteractionCreateEvent, String> {
...
} Your IDE should assist you into fixing this breaking change, don't worry. 💭 Why the sudden breaking change?The sudden breaking change was to introduce this new interaction support while also reducing code duplication as much as possible, otherwise, you would be expecting at least a very fat package for this framework. You can find all the changes here. |
😭 Another Breaking ChangeThere is another breaking change to Velen which involves the slash event but don't worry, you can quickly fix this through Old: void onEvent(SlashCommandInteraction event, User user, VelenArguments args,
List<SlashCommandInteractionOption> options, InteractionImmediateResponseBuilder firstResponder); New: void onEvent(SlashCommandCreateEvent originalEvent, SlashCommandInteraction event, User user, VelenArguments args,
List<SlashCommandInteractionOption> options, InteractionImmediateResponseBuilder firstResponder); |
…hCommandCreateEvent` to `onEvent` for `VelenSlashEvent`
🌃 Named Options is now supported!Velen now supports named options, or otherwise named as routed options, which as the name implies works similar to a web framework's router which allows message commands and hybrid commands to be named and be conditioned from the get-go. This is by far one of the better changes of Velen but it is also breaking for message commands which can be fixed easily. 📦 Syntax and FormatsTo first understand how this all works, we have to look in depth of the syntax for the formats:
You can only place one regex pattern checker and option limiter inside a option (you can have both though), with a full example of a format utilizing all looking like this:
The format above tells Velen that the command should have 4 arguments, the first argument will be named as The beauty of this entire thing is, you can have multiple formats and Velen will still accurately grab the correct option name but ensure that the name of the options are unique in each format otherwise Velen will pick up only the first case. An instance with multiple formats is:
If your command has all those formats, Velen will still be able to fetch the correct option name, so don't worry. 😄 💯 Adding formats to your commands and syntaxThis is the required method to have this entire thing working, you have to add a format to your command during building using the VelenCommand.of("test", "A test command.", velen, (event, message, user, args1, options) -> {
String name = options.withName("name").orElse("Unknown Person");
if (options.withName("condition").isPresent()) {
message.reply("Good"+options.withName("condition").get()+", " + name);
} else {
message.reply("Hello " + name);
}
}).addFormats("test :[name]")
.addFormats("test :[name] :[condition::(morning,night)]")
.attach(); The example above will reply with Hybrid commands also work the same but with extra steps on getting the value of the option since Slash Commands supports several types like 😱 Breaking ChangeThe breaking change this time is that - void onEvent(MessageCreateEvent event, Message message, User user, String[] args); + void onEvent(MessageCreateEvent event, Message message, User user, String[] args, VelenRoutedOptions options); |
🏢 Of(type) syntax for arguments.The of-type syntax for message options or arguments is another key-feature of Velen which allows bots using both hybrid and message commands to be able to fetch the right type of argument or option for their commands. For example, if you want to fetch a user, all you have to do is add You can only add one
|
🥇 An entirely new way of command initializationAll this time, we were stuck with thinking about how to initialize commands, should we keep doing the ordinary way which is to initialize commands via method builders or should we go with annotations? Those two have been the stale way of initializing Discord commands amongst Javacord frameworks, and truthfully, I find both ugly to look at. And so, I went ahead and brainstormed before coming up with In-depth explanation will come later, please note that it supports subcommand, subcommand groups, choices and options all together and can translate everything automatically to message commands
You can read more about the examples here like how the handlers are setup and etc: https://github.com/ShindouMihou/Velen/tree/development/examples/hybrid |
…d allow `withName` on `VelenRoutedOptions` to fetch multiple values.
🪙 hasMany and getWithManyVelen's new argument system now supports fetching of multiple values with the same name for message commands, take for instance, the You can see this on the newer examples of hybrid commands on the new system. |
This is a heads-up for the next version of Velen which follows Javacord 3.4.0, to use this, please move to the Snapshot repository of Javacord:
To use this PR, please use Jitpack to build the PR. Also to note, the snapshot repository of Javacord and the version numbering will be changed once the next version of Javacord is officially out.