diff --git a/Discord/pom.xml b/Discord/pom.xml
index 59e048be..ccf459a3 100644
--- a/Discord/pom.xml
+++ b/Discord/pom.xml
@@ -25,7 +25,7 @@
net.dv8tion
JDA
- 4.2.0_208
+ 5.0.0-beta.17
me.fixeddev
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/DiscordAuthorizer.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/DiscordAuthorizer.java
index f359eb77..ec5c0f98 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/DiscordAuthorizer.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/DiscordAuthorizer.java
@@ -3,9 +3,9 @@
import me.fixeddev.commandflow.Authorizer;
import me.fixeddev.commandflow.Namespace;
import net.dv8tion.jda.api.Permission;
-import net.dv8tion.jda.api.entities.GuildChannel;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
public class DiscordAuthorizer implements Authorizer {
@@ -22,7 +22,7 @@ public boolean isAuthorized(Namespace namespace, String permission) {
return true;
}
- GuildChannel channel = message.getTextChannel();
+ GuildChannel channel = message.getGuildChannel();
Permission permissionValue;
try {
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/MessageListener.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/MessageListener.java
index 3c67bec0..96f44d2d 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/MessageListener.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/MessageListener.java
@@ -11,9 +11,10 @@
import me.fixeddev.commandflow.exception.NoPermissionsException;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
-import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
+import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.kyori.adventure.text.Component;
@@ -28,11 +29,16 @@ public MessageListener(CommandManager commandManager, String commandPrefix) {
}
@Override
- public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
+ public void onMessageReceived(MessageReceivedEvent event) {
+
+ if(!(event.getChannel() instanceof TextChannel)){
+ return;
+ }
+
Member member = event.getMember();
User user = event.getAuthor();
Message message = event.getMessage();
- TextChannel channel = event.getChannel();
+ TextChannel channel = event.getChannel().asTextChannel();
String rawMessage = event.getMessage().getContentRaw();
@@ -42,7 +48,11 @@ public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
rawMessage = rawMessage.substring(commandPrefix.length());
- String label = rawMessage.substring(0, rawMessage.indexOf(" "));
+ String label = rawMessage;
+
+ if(label.indexOf(" ") > 0){
+ label = rawMessage.substring(0, rawMessage.indexOf(" "));
+ }
Namespace namespace = Namespace.create();
@@ -53,7 +63,7 @@ public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
namespace.setObject(String.class, "label", label);
try {
- commandManager.execute(namespace, rawMessage.substring(commandPrefix.length()));
+ commandManager.execute(namespace, rawMessage);
} catch (CommandException e) {
CommandException exceptionToSend = e;
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/factory/DiscordModule.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/factory/DiscordModule.java
index 32a7012c..531564cd 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/factory/DiscordModule.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/factory/DiscordModule.java
@@ -5,8 +5,8 @@
import me.fixeddev.commandflow.discord.annotation.Sender;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
+import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
public class DiscordModule extends AbstractModule {
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/MemberPart.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/MemberPart.java
index e15a104b..27360bf3 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/MemberPart.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/MemberPart.java
@@ -32,7 +32,7 @@ public String getName() {
@Override
public List extends Member> parseValue(CommandContext context, ArgumentStack stack, CommandPart parent) throws ArgumentParseException {
Message message = context.getObject(Message.class, DiscordCommandManager.MESSAGE_NAMESPACE);
- Guild guild = message.getTextChannel().getGuild();
+ Guild guild = message.getGuild();
String target = stack.next();
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/TextChannelPart.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/TextChannelPart.java
index bdb096d5..d0448d95 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/TextChannelPart.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/TextChannelPart.java
@@ -8,7 +8,7 @@
import me.fixeddev.commandflow.part.CommandPart;
import me.fixeddev.commandflow.stack.ArgumentStack;
import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.TextChannel;
+import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.kyori.adventure.text.Component;
import java.util.Collections;
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/UserPart.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/UserPart.java
index 0b7f84cb..c7f65eec 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/part/UserPart.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/part/UserPart.java
@@ -26,7 +26,7 @@ public UserPart(String name) {
@Override
public List extends User> parseValue(CommandContext context, ArgumentStack stack, CommandPart parent) throws ArgumentParseException {
Message message = context.getObject(Message.class, DiscordCommandManager.MESSAGE_NAMESPACE);
- Guild guild = message.getTextChannel().getGuild();
+ Guild guild = message.getGuild();
String target = stack.next();
diff --git a/Discord/src/main/java/me/fixeddev/commandflow/discord/utils/ArgumentsUtils.java b/Discord/src/main/java/me/fixeddev/commandflow/discord/utils/ArgumentsUtils.java
index 47a0f0d5..160d6e4e 100644
--- a/Discord/src/main/java/me/fixeddev/commandflow/discord/utils/ArgumentsUtils.java
+++ b/Discord/src/main/java/me/fixeddev/commandflow/discord/utils/ArgumentsUtils.java
@@ -36,7 +36,7 @@ public static boolean isRoleMention(String argument) {
private static boolean isMention(String argument, String mentionTypeIdentifier) {
return argument.startsWith("<" + mentionTypeIdentifier) && argument.endsWith(">")
- && argument.length() == (20 + mentionTypeIdentifier.length());
+ && argument.length() >= (20 + mentionTypeIdentifier.length());
}
}