diff --git a/README.md b/README.md index ee5c496..230408a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# sdcf4j Latest version Latest JavaDocs Latest JavaDocs +# sdcf4j Latest version Latest JavaDocs Latest JavaDocs 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. @@ -21,14 +21,14 @@ public String onPingCommand() { de.btobastian.sdcf4j sdcf4j-core - 1.0.6 + 1.0.7 de.btobastian.sdcf4j sdcf4j-javacord - 1.0.6 + 1.0.7 ``` @@ -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) { diff --git a/pom.xml b/pom.xml index 99e5527..aa5095e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ de.btobastian.sdcf4j sdcf4j pom - 1.0.6 + 1.0.7 UTF-8 diff --git a/sdcf4j-core/pom.xml b/sdcf4j-core/pom.xml index 5ff7571..a45a46d 100644 --- a/sdcf4j-core/pom.xml +++ b/sdcf4j-core/pom.xml @@ -5,7 +5,7 @@ sdcf4j de.btobastian.sdcf4j - 1.0.6 + 1.0.7 jar 4.0.0 diff --git a/sdcf4j-discord4j/pom.xml b/sdcf4j-discord4j/pom.xml index 76f6690..87bbbde 100644 --- a/sdcf4j-discord4j/pom.xml +++ b/sdcf4j-discord4j/pom.xml @@ -5,7 +5,7 @@ sdcf4j de.btobastian.sdcf4j - 1.0.6 + 1.0.7 jar 4.0.0 @@ -45,7 +45,7 @@ com.github.austinv11 Discord4j - 2.9.1 + 2.9.2 diff --git a/sdcf4j-javacord/pom.xml b/sdcf4j-javacord/pom.xml index de7491c..0798d6f 100644 --- a/sdcf4j-javacord/pom.xml +++ b/sdcf4j-javacord/pom.xml @@ -5,7 +5,7 @@ sdcf4j de.btobastian.sdcf4j - 1.0.6 + 1.0.7 jar 4.0.0 @@ -44,7 +44,7 @@ de.btobastian Javacord - 6dd48cb + eaa7951 diff --git a/sdcf4j-javacord/src/main/java/de/btobastian/sdcf4j/handler/JavacordHandler.java b/sdcf4j-javacord/src/main/java/de/btobastian/sdcf4j/handler/JavacordHandler.java index cc45cb1..ec36d24 100644 --- a/sdcf4j-javacord/src/main/java/de/btobastian/sdcf4j/handler/JavacordHandler.java +++ b/sdcf4j-javacord/src/main/java/de/btobastian/sdcf4j/handler/JavacordHandler.java @@ -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; @@ -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(" "); @@ -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()); } @@ -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); diff --git a/sdcf4j-jda3/pom.xml b/sdcf4j-jda3/pom.xml index e317894..30be86e 100644 --- a/sdcf4j-jda3/pom.xml +++ b/sdcf4j-jda3/pom.xml @@ -5,7 +5,7 @@ sdcf4j de.btobastian.sdcf4j - 1.0.6 + 1.0.7 jar 4.0.0 @@ -46,7 +46,7 @@ net.dv8tion JDA - 3.3.1_290 + 3.3.1_303 diff --git a/sdcf4j-jda3/src/main/java/de/btobastian/sdcf4j/handler/JDA3Handler.java b/sdcf4j-jda3/src/main/java/de/btobastian/sdcf4j/handler/JDA3Handler.java index 30a4aed..fd52074 100644 --- a/sdcf4j-jda3/src/main/java/de/btobastian/sdcf4j/handler/JDA3Handler.java +++ b/sdcf4j-jda3/src/main/java/de/btobastian/sdcf4j/handler/JDA3Handler.java @@ -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) {