Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from BtoBastian/development
Browse files Browse the repository at this point in the history
Merge development branch
  • Loading branch information
Bastian authored Nov 8, 2017
2 parents 9109039 + 029bba9 commit 6b9c189
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sdcf4j <a href="#"><img src="https://img.shields.io/badge/Version-1.0.6-brightgreen.svg" alt="Latest version"></a> <a href="http://ci.ketrwu.de/job/sdcf4j/job/master/javadoc/"><img src="https://img.shields.io/badge/JavaDoc-latest-yellow.svg" alt="Latest JavaDocs"></a> <a href="https://github.com/BtoBastian/sdcf4j/wiki"><img src="https://img.shields.io/badge/Wiki-Home-red.svg" alt="Latest JavaDocs"></a>
# sdcf4j <a href="#"><img src="https://img.shields.io/badge/Version-1.0.7-brightgreen.svg" alt="Latest version"></a> <a href="http://ci.ketrwu.de/job/sdcf4j/job/master/javadoc/"><img src="https://img.shields.io/badge/JavaDoc-latest-yellow.svg" alt="Latest JavaDocs"></a> <a href="https://github.com/BtoBastian/sdcf4j/wiki"><img src="https://img.shields.io/badge/Wiki-Home-red.svg" alt="Latest JavaDocs"></a>

Sdcf4j is a **s**imple **D**iscord **c**ommand **f**ramework **for** **J**ava, supporting [Javacord](https://github.com/BtoBastian/Javacord), [JDA](https://github.com/DV8FromTheWorld/JDA) and [Discord4J](https://github.com/austinv11/Discord4J). It helps you creating commands within seconds in a clean and simple way.

Expand All @@ -21,14 +21,14 @@ public String onPingCommand() {
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j-core</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
<!-- The module for your prefered lib-->
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<!-- Possible artifact ids: sdcf4j-javacord, sdcf4j-jda3, sdcf4j-discord4j -->
<artifactId>sdcf4j-javacord</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
```

Expand Down Expand Up @@ -77,16 +77,10 @@ public String onCommand() {

// DiscordAPI and Message as parameter (Javacord)
@Command(aliases = {"!ping"}, description = "Pong!")
public String onCommand(DiscordAPI api, Message message) {
public String onCommand(DiscordApi api, Message message) {
return "Pong!";
}

// only Message as parameter without return type (Javacord and JDA)
@Command(aliases = {"!ping"}, description = "Pong!")
public void onCommand(Message message) {
message.reply("Pong!");
}

// no private messages and async (Javacord and JDA)
@Command(aliases = {"!channelInfo", "!ci"}, description = "Pong!", async = true, privateMessages = false)
public String onCommand(Channel channel) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j</artifactId>
<packaging>pom</packaging>
<version>1.0.6</version>
<version>1.0.7</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion sdcf4j-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions sdcf4j-discord4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>com.github.austinv11</groupId>
<artifactId>Discord4j</artifactId>
<version>2.9.1</version>
<version>2.9.2</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions sdcf4j-javacord/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>de.btobastian</groupId>
<artifactId>Javacord</artifactId>
<version>6dd48cb</version>
<version>eaa7951</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.btobastian.javacord.entities.User;
import de.btobastian.javacord.entities.channels.*;
import de.btobastian.javacord.entities.message.Message;
import de.btobastian.javacord.entities.message.MessageAuthor;
import de.btobastian.javacord.utils.logging.LoggerUtil;
import de.btobastian.sdcf4j.Command;
import de.btobastian.sdcf4j.CommandHandler;
Expand Down Expand Up @@ -79,7 +80,7 @@ public boolean hasPermission(User user, String permission) {
* @param message The received message.
*/
private void handleMessageCreate(DiscordApi api, final Message message) {
if (message.getAuthor().map(User::isYourself).orElse(false)) {
if (message.getUserAuthor().map(User::isYourself).orElse(false)) {
return;
}
String[] splitMessage = message.getContent().split(" ");
Expand Down Expand Up @@ -108,7 +109,7 @@ private void handleMessageCreate(DiscordApi api, final Message message) {
if (!message.getPrivateChannel().isPresent() && !commandAnnotation.channelMessages()) {
return;
}
if (!hasPermission(message.getAuthor().map(User::getId).map(String::valueOf).orElse("-1"), commandAnnotation.requiredPermissions())) {
if (!hasPermission(message.getUserAuthor().map(User::getId).map(String::valueOf).orElse("-1"), commandAnnotation.requiredPermissions())) {
if (Sdcf4jMessage.MISSING_PERMISSIONS.getMessage() != null) {
message.getChannel().sendMessage(Sdcf4jMessage.MISSING_PERMISSIONS.getMessage());
}
Expand Down Expand Up @@ -193,8 +194,10 @@ private Object[] getParameters(String[] splitMessage, SimpleCommand command, Mes
} else if (type == TextChannel.class) {
parameters[i] = message.getChannel().asTextChannel().orElse(null);
} else if (type == User.class) {
parameters[i] = message.getAuthor().orElse(null);
}else if (type == Server.class) {
parameters[i] = message.getUserAuthor().orElse(null);
} else if (type == MessageAuthor.class) {
parameters[i] = message.getAuthor();
} else if (type == Server.class) {
parameters[i] = message.getServerTextChannel().map(ServerTextChannel::getServer).orElse(null);
} else if (type == Object[].class) {
parameters[i] = getObjectsFromString(api, args);
Expand Down
4 changes: 2 additions & 2 deletions sdcf4j-jda3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdcf4j</artifactId>
<groupId>de.btobastian.sdcf4j</groupId>
<version>1.0.6</version>
<version>1.0.7</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.3.1_290</version>
<version>3.3.1_303</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ private Object[] getParameters(String[] splitMessage, SimpleCommand command, Mes
parameters[i] = event.getMessage();
} else if (type == User.class) {
parameters[i] = event.getAuthor();
} else if (type == Member.class) {
parameters[i] = event.getMember();
} else if (type == TextChannel.class) {
parameters[i] = event.getTextChannel();
} else if (type == PrivateChannel.class) {
Expand Down

0 comments on commit 6b9c189

Please sign in to comment.