Code Monkey home page Code Monkey logo

jdcf's Introduction

license issues support version

JDCF

A command framework for the famous discord api for java - JDA

Installation

Using maven:

<repositories>
    <repository>
        <id>ivan</id>
        <url>https://repo.mrivanplays.com/repository/ivan/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.mrivanplays</groupId>
        <artifactId>JDCF</artifactId>
        <version>VERSION</version> <!-- Replace VERSION with latest version -->
        <scope>compile</scope>  
    </dependency>
</dependencies>

Using gradle:

repositories {
    maven {
        url 'https://repo.mrivanplays.com/repository/ivan'
    }
}

dependencies {
    implementation group: 'com.mrivanplays', name: 'JDCF', version: 'VERSION' // Replace VERSION with latest version
}

Usage

Example command:

import com.mrivanplays.jdcf.Command;
import com.mrivanplays.jdcf.CommandExecutionContext;
import com.mrivanplays.jdcf.args.CommandArguments;
import com.mrivanplays.jdcf.args.FailReason;
import com.mrivanplays.jdcf.data.CommandAliases;
import com.mrivanplays.jdcf.data.CommandDescription;
import com.mrivanplays.jdcf.data.CommandUsage;
import net.dv8tion.jda.api.Permission;
import org.jetbrains.annotations.NotNull;

// the usage and description aren't necessary if you don't enable
// the help command.
@CommandDescription("My command runs on command")
@CommandUsage("mycommandname <something>")
@CommandAliases("commandname|mcn|cn")
public class MyCommand extends Command {

    @Override
    public boolean execute(@NotNull CommandExecutionContext context, @NotNull CommandArguments args) {
        args.nextString()
            .ifPresent(argument -> context.getChannel().sendMessage(argument).queue())
            .orElse(failReason -> {
                if (failReason == FailReason.ARGUMENT_NOT_TYPED) {
                    context.getChannel().sendMessage("Specify something.").queue();
                }
            });
        return true;
    }
}

Example command manager initialization (without overriding the default settings) and command registration

public static void main(String[] args) {
    JDA jda = // assuming you have set a jda instance
    CommandManager commandManager = new CommandManager(jda);
    commandManager.registerCommand(new MyCommand());
}

I think you can figure out the other things yourself. For any questions you can ask me on Discord showed up.

Sponsors

Thanks to JetBrains I am able to use their products on this project. Thank you JetBrains <3

jdcf's People

Contributors

johnnyjayjay avatar mrivanplays avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.