azzerial / slash-commands Goto Github PK
View Code? Open in Web Editor NEWAn open source utility library for JDA to simplify the use of Discord Slash Commands
License: Apache License 2.0
An open source utility library for JDA to simplify the use of Discord Slash Commands
License: Apache License 2.0
Ensure that the JDA status is READY
before building the SlashClient
. (Otherwise, the guilds wouldn't load)
The SlashMenu
abstract class is a variation of the JDA-Utilities/Menu.java abstract class.
This would be the base frame for template menus such as page menus, slideshows, validators, ...
Implement the JDA component SelectionMenu
(Discord's select menus
). As for the SlashButton
, the object should have the Slash prefix (so SlashSelectionMenu
).
Note: Need to wait for JDA to release the feature first.
Create the @Option.Bind
annotation that can be placed before a method parameter (of a @Slash.Handler
) and that binds the option to the parameter. This allows the option to be passed as typed parameter to shortcut the traditional JDA way of getting the options.
Note: In case the options cannot be mapped to the parameter type, the method would not be called.
Note: In case an option is a union type (as for the
MENTIONABLE
), it would be possible to create multiple@Slash.Handler
methods with different parameter types for the option. The api would then call the most appropriate method.
Note: A default value (for non-required options only) should be added to the
@Option.Bind
.
For a simple kick command, the current way of writing it
@Slash.Handler()
public void kick(SlashCommandEvent event) {
final User user = Objects.requireNonNull(event.getOption("user")).getAsUser();
final String reason = Objects.requireNonNull(event.getOption("reason")).getAsString();
...
}
would become
@Slash.Handler()
public void kick(SlashCommandEvent event, @Option.Bind("user") User user, @Option.Bind("reason") String reason) {
...
}
The lambda callback should be added to the SlashButton
class such as SlashButton#style(String label, Consumer<ButtonClickEvent> lambda)
.
SlashButton.primary("Refresh", event -> { ... });
Note: In order to make the lambda callbacks persistent, a pre-processing would be interesting. We would first create a registry/cache for all the callbacks (map index to callback).
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.