[AB-53] adding economy related commands

adding runtime exception to root command handling
adding simple custom command module
disabling slash command for show emote the utility is not given (the bot cannot show any emotes from servers its not in)
fixing post target setup not allowing threads
fixing post targets not supporting threads
fixing interactions not considering the actual amount of embeds
fixing some cases for events which are not in a guild
This commit is contained in:
Sheldan
2022-07-21 00:43:04 +02:00
parent 68cae74819
commit 9954515db0
81 changed files with 3717 additions and 108 deletions

View File

@@ -0,0 +1,10 @@
package dev.sheldan.abstracto.core.command;
import dev.sheldan.abstracto.core.Prioritized;
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
import net.dv8tion.jda.api.entities.Message;
public interface CommandAlternative extends Prioritized {
boolean matches(UnParsedCommandParameter parameter);
void execute(UnParsedCommandParameter parameter, Message message);
}

View File

@@ -26,6 +26,7 @@ public class UnParsedCommandParameter {
}
while (m.find()) {
if(!skippedCommand) {
this.commandName = m.group();
skippedCommand = true;
continue;
}
@@ -49,4 +50,5 @@ public class UnParsedCommandParameter {
.build()));
}
private List<UnparsedCommandParameterPiece> parameters;
private String commandName;
}

View File

@@ -10,7 +10,7 @@ import java.util.List;
import java.util.Optional;
public interface CommandRegistry {
Command findCommandByParameters(String name, UnParsedCommandParameter context, Long serverId);
Optional<Command> findCommandByParameters(String name, UnParsedCommandParameter context, Long serverId);
Command findCommandViaName(String message);
List<Command> getAllCommands();
List<Command> getAllCommandsFromModule(ModuleDefinition module);

View File

@@ -13,6 +13,10 @@ public class MessageReceivedModel implements FeatureAwareListenerModel {
private Message message;
@Override
public Long getServerId() {
return message.getGuild().getIdLong();
if(message.isFromGuild()) {
return message.getGuild().getIdLong();
} else {
return null;
}
}
}

View File

@@ -32,4 +32,13 @@ public class MemberDisplay {
.userId(aUserInAServer.getUserReference().getId())
.build();
}
public static MemberDisplay fromIds(Long serverId, Long userId) {
return MemberDisplay
.builder()
.memberMention(MemberUtils.getUserAsMention(userId))
.serverId(serverId)
.userId(userId)
.build();
}
}