Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
koply committed Dec 16, 2020
2 parents ac38667 + d35ca6a commit 33ca536
Showing 1 changed file with 106 additions and 10 deletions.
116 changes: 106 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@
[![jitpack-version](https://jitpack.io/v/MusaBrt/KCommando.svg)](https://jitpack.io/#MusaBrt/KCommando)
![LICENSE](https://img.shields.io/github/license/MusaBrt/KCommando?style=flat)

Annotation based command handler framework for JDA & Javacord.
Annotation-based multifunctional command handler framework for JDA & Javacord.

## Usage For JDA
## Features
1. [Integrations](#kcommando-integrations)
2. [JDA Section](#integration-usage-for-jda)
3. [Javacord Section](#javacord-section)
4. [Command Features](#command-features)
- [Possible Handle Methods](#possible-handle-methods)
- [Command Callbacks](#command-callbacks) *(onFalse, ownerOnly, guildOnly, privateOnly, cooldown)*
5. [Cool Features](#cool-features)
- [Custom Prefixes](#how-to-use-custom-prefixes)
- [Blacklist User](#blacklist-user)
- [Blacklist Member](#blacklist-member)
- [Blacklist Channel](#blacklist-channel)
- [Callback For Blacklisted Usage](#callback-for-blacklisted-usages)
6. [Install](#how-to-install)
- [Maven](#with-maven)
- [Gradle](#with-gradle)
7. [Example Repositories](#example-repositories)

# KCommando Integrations

### Integration Usage For JDA
```java
public class Main extends JDAIntegration {

Expand Down Expand Up @@ -60,7 +80,9 @@ _Optionally you can use final class and final handle method for decrease init ti

Aliases field is can be an array: `aliases = {"ping", "pingu"}`

## Usage For Javacord
## Javacord Section

### Integration Usage For Javacord
```java
public class Main extends JavacordIntegration {

Expand Down Expand Up @@ -98,24 +120,95 @@ public class BasicCommand extends JavacordCommand {
}
```

# Command Features

## Possible Handle Methods

You can use just one in your command class. Parameters cannot be empty. You don't need to null check.

```java
boolean handle(<EventFromApiWrapper> e) // CommandType.EVENT -> 0x01
boolean handle(<EventFromApiWrapper> e, String[] args) // CommandType.ARGNEVENT -> 0x02
boolean handle(<EventFromApiWrapper> e, String[] args, String prefix) // CommandType.PREFIXED -> 0x03
boolean handle(<Event> e) // CommandType.EVENT -> 0x01
boolean handle(<Event> e, String[] args) // CommandType.ARGNEVENT -> 0x02
boolean handle(<Event> e, String[] args, String prefix) // CommandType.PREFIXED -> 0x03
```

## Command Callbacks
**Note:** All lines must be inside the constructor of your command.

#### On False Callback: This callback is run when the command returns false.
```java
getInfo().setOnFalseCallback( (JRunnable) e -> e.getMessage().addReaction("") );
```

#### Owner Only Callback: This callback is run when the command for the bot owner is used by a normal user.
```java
getInfo().setOwnerOnlyCallback( (JRunnable) e -> e.getMessage().addReaction("") );
```

#### Guild Only Callback: This callback is run when the command for guild in the private message is used.
```java
getInfo().setGuildOnlyCallback( (JRunnable) e -> e.getMessage().addReaction("") );
```

#### Private Only Callback: This callback is run when the command for private conversations in the guild is used.
```java
getInfo().setPrivateOnlyCallback( (JRunnable) e -> e.getMessage().addReaction("") );
```

#### Cooldown Callback: This callback is run when the command declined due to cooldown.
```java
getInfo().setCooldownCallback( (JRunnable) e -> e.getMessage().addReaction("") );
```

# Cool Features

## How To Use Custom Prefixes

You can add custom prefixes for guilds.

```java
Integration#addCustomPrefix(long guildID, String prefix) // adds a prefix for the selected guild.
Integration#removeCustomPrefix(long guildID, String prefix) // removes a prefix for the selected guild. This method is safe to use.
Integration#disableCustomPrefix(long guildID) // disables all custom prefixes for selected guild.
```

If a guild has a custom prefix, the normal prefix will be unavailable on that guild but will be able to use more than one prefixes at the same time. You can remove and disable custom prefixes for the single guild.



## How To Use Blacklist

I prefer to use a static instance of a subclass of Integration. You can see tests of jda and javacord integrations.

### Blacklist User
```java
Integration#getBlacklistedUsers().add(long userID) // blocks selected user from all commands in the bot.
Integration#getBlacklistedUsers().remove(long userID) // unblocks selected user.
```

### Blacklist Member
```java
Integration#getBlacklistedMembers() // returns all blacklisted members with guilds. (guildID, the set of the blacklisted members)
Integration#getBlacklistedMembers(long guildID) // returns all blacklisted members in the selected guild.
```

### Blacklist Channel
```java
Integration#getBlacklistedChannels() // returns all blacklisted channels with guilds. (guildID, the set of the blacklisted channels)
Integration#getBlacklistedChannels(long guildID) // returns all blacklisted channels in the selected guild.
```

### Callback For Blacklisted Usages

When a command declined due to a blacklist, runs this callback.
```java
Integration#setBlacklistCallback( (JRunnable) e -> e.getMessage().addReaction("") )
```

## How To Install

To always use the latest version, you can write '-SNAPSHOT' in the version field. This use is not recommended.

### Example Repositories
| [Rae Discord Bot](https://github.com/MusaBrt/Rae)

### With Maven:
```xml
<repository>
Expand Down Expand Up @@ -155,6 +248,9 @@ dependencies {
}
```

**Please change 'JITPACK-VERSION' fields to latest release version.**
**Please change 'JITPACK-VERSION' fields to the latest release version.**

Github packages are ignored. Please use jitpack repositories.

## Example Repositories
| [Rae Discord Bot](https://github.com/MusaBrt/Rae)

0 comments on commit 33ca536

Please sign in to comment.