Skip to content

A simple Javacord extension to create slash commands with built-in input validation, argument conversion, concatenation and autocompletion.

License

Notifications You must be signed in to change notification settings

S3nS3IW00/JCommands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JCommands Maven Central

With this Javacord extension you can create Slash Commands on your Discord server within 1 minute with built-in

  • input validating,
StringArgument<Integer> stringArgument = new StringArgument<>("number", "A number", Integer.class);  
stringArgument.getArgumentValidator().when(RegexPredicate.notValidFor("\\d+")).thenRespond(event -> {  
    event.getResponder().respondNow()  
        .setContent("The input is not a number!")  
        .respond();  
});  
  • value converting,
stringArgument.convertResult(value -> Integer.parseInt(value));  
  • autocompleting and
StringArgument<String> searchArgument = new StringArgument<>("search", "Start typing", String.class);  
SearchAutocomplete searchAutocomplete = new SearchAutocomplete(SearchAutocomplete.SearchType.CONTAINS, Arrays.asList(  
    "just some words like hello world"  
    .split(" ")  
))  
.ignoreCase();  
searchArgument.addAutocomplete(searchAutocomplete);  
  • concatenating
command.addConcatenator(new StringConcatenator<>(" ", String.class), stringArgument, searchArgument);  

There are so many useful pre-written argument types that can be used while creating a command.

Example command

This command is created just with about 50 lines of code including the response and error handling. It has a validated argument with regex, an argument that has two different values that the user can choose from, a number argument that has a range validation, a normal user mention argument, a normal channel mention argument and an optional attachment argument with size and extension validation.

Example

You can find the full code here that runs a bot with the example command above.

Wiki

You can find all the information about how to use JCommands on the Wiki page.

Dependencies

This is a Javacord extension. Javacord is a Discord bot framework and it so much easier to create bots with it.

Usage

Replace {VERSION} with one of the released versions from 6.0.0 (the latest recommended)

Maven

<dependency>  
    <groupId>io.github.s3ns3iw00</groupId>  
    <artifactId>jcommands</artifactId>  
    <version>{VERSION}</version>  
</dependency>  

Gradle

dependencies {  
    implementation 'io.github.s3ns3iw00.jcommands:{VERSION}'  
}  

Contact

If you found a bug, or you just want a new feature in the next version, don't hesitate to report it on the issues page or feel free to open a pull request. You can contact me through discord: senseydev

About

A simple Javacord extension to create slash commands with built-in input validation, argument conversion, concatenation and autocompletion.

Topics

Resources

License

Stars

Watchers

Forks

Languages