[AB-xxx] removing all message command implementations of lesser used message commands

This commit is contained in:
Sheldan
2025-02-16 00:46:49 +01:00
parent 29fd453117
commit a8c2dfe15a
84 changed files with 181 additions and 1489 deletions

View File

@@ -6,15 +6,12 @@ import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
import dev.sheldan.abstracto.core.command.config.HelpInfo;
import dev.sheldan.abstracto.core.command.config.Parameter;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.models.template.display.EmoteDisplay;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.abstracto.utility.config.UtilityFeatureDefinition;
import dev.sheldan.abstracto.utility.config.UtilitySlashCommandNames;
import dev.sheldan.abstracto.utility.model.ServerInfoModel;
@@ -35,23 +32,12 @@ public class ServerInfo extends AbstractConditionableCommand {
public static final String SERVERINFO_RESPONSE_TEMPLATE_KEY = "serverinfo_response";
private static final String SERVER_INFO_COMMAND = "serverInfo";
@Autowired
private ChannelService channelService;
@Autowired
private TemplateService templateService;
@Autowired
private InteractionService interactionService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
log.info("Displaying serverinfo for server {}", commandContext.getGuild().getId());
return FutureUtils.toSingleFutureGeneric(
channelService.sendMessageToSendToChannel(getMessageToSend(commandContext.getGuild()), commandContext.getChannel()))
.thenApply(aVoid -> CommandResult.fromIgnored());
}
@Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
return interactionService.replyMessageToSend(getMessageToSend(event.getGuild()), event)
@@ -103,6 +89,7 @@ public class ServerInfo extends AbstractConditionableCommand {
.slashCommandConfig(slashCommandConfig)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.causesReaction(false)

View File

@@ -5,14 +5,10 @@ import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand
import dev.sheldan.abstracto.core.command.config.*;
import dev.sheldan.abstracto.core.command.handler.parameter.CombinedParameter;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.exception.EntityGuildMismatchException;
import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.abstracto.utility.config.UtilityFeatureDefinition;
import dev.sheldan.abstracto.utility.config.UtilitySlashCommandNames;
import dev.sheldan.abstracto.utility.model.ShowAvatarModel;
@@ -41,9 +37,6 @@ public class ShowAvatar extends AbstractConditionableCommand {
private static final String MEMBER_PARAMETER = "member";
private static final String SHOW_AVATAR_COMMAND = "showAvatar";
@Autowired
private ChannelService channelService;
@Autowired
private SlashCommandParameterService slashCommandParameterService;
@@ -53,23 +46,6 @@ public class ShowAvatar extends AbstractConditionableCommand {
@Value("${abstracto.feature.avatar.imagesize}")
private Integer imageSize;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
Member memberToShow = parameters.size() == 1 ? (Member) parameters.get(0) : commandContext.getUserInitiatedContext().getMember();
if(!memberToShow.getGuild().equals(commandContext.getGuild())) {
throw new EntityGuildMismatchException();
}
ShowAvatarModel model = ShowAvatarModel
.builder()
.avatarUrl(memberToShow.getEffectiveAvatar().getUrl(imageSize))
.build();
log.info("Showing avatar for member {} towards user {} in channel {} in server {}.",
memberToShow.getId(), commandContext.getAuthor().getId(), commandContext.getChannel().getId(), commandContext.getGuild().getId());
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_AVATAR_RESPONSE_TEMPLATE, model, commandContext.getChannel()))
.thenApply(aVoid -> CommandResult.fromIgnored());
}
@Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
String avatarUrl;
@@ -135,6 +111,7 @@ public class ShowAvatar extends AbstractConditionableCommand {
.slashCommandConfig(slashCommandConfig)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.causesReaction(false)

View File

@@ -7,9 +7,7 @@ import dev.sheldan.abstracto.core.command.config.HelpInfo;
import dev.sheldan.abstracto.core.command.config.Parameter;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.abstracto.utility.config.UtilityFeatureDefinition;
@@ -32,12 +30,6 @@ public class ShowEmote extends AbstractConditionableCommand {
@Autowired
private ChannelService channelService;
@Autowired
private InteractionService interactionService;
@Autowired
private SlashCommandParameterService slashCommandParameterService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();

View File

@@ -5,7 +5,6 @@ import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand
import dev.sheldan.abstracto.core.command.config.*;
import dev.sheldan.abstracto.core.command.handler.parameter.CombinedParameter;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
@@ -13,10 +12,8 @@ import dev.sheldan.abstracto.core.exception.EntityGuildMismatchException;
import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.models.template.display.MemberNameDisplay;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.MemberService;
import dev.sheldan.abstracto.core.utils.ContextUtils;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import dev.sheldan.abstracto.utility.config.UtilityFeatureDefinition;
import dev.sheldan.abstracto.utility.config.UtilitySlashCommandNames;
import dev.sheldan.abstracto.utility.model.UserInfoModel;
@@ -25,7 +22,6 @@ import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
@@ -45,8 +41,6 @@ public class UserInfo extends AbstractConditionableCommand {
public static final String USER_INFO_COMMAND = "userInfo";
public static final String MEMBER_PARAMETER = "member";
public static final String USER_INFO_RESPONSE = "userInfo_response";
@Autowired
private ChannelService channelService;
@Autowired
private MemberService memberService;
@@ -60,35 +54,6 @@ public class UserInfo extends AbstractConditionableCommand {
@Autowired
private InteractionService interactionService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
Member memberToShow = parameters.size() == 1 ? (Member) parameters.get(0) : commandContext.getAuthor();
if(!memberToShow.getGuild().equals(commandContext.getGuild())) {
throw new EntityGuildMismatchException();
}
UserInfoModel model = UserInfoModel
.builder()
.build();
if(!memberToShow.hasTimeJoined()) {
log.info("Force reloading member {} in guild {} for user info.", memberToShow.getId(), memberToShow.getGuild().getId());
return memberService.forceReloadMember(memberToShow).thenCompose(member -> {
fillUserInfoModel(model, member, false);
return self.sendResponse(commandContext.getChannel(), model)
.thenApply(aVoid -> CommandResult.fromIgnored());
});
} else {
fillUserInfoModel(model, memberToShow, false);
return self.sendResponse(commandContext.getChannel(), model)
.thenApply(aVoid -> CommandResult.fromIgnored());
}
}
@Transactional
public CompletableFuture<Void> sendResponse(MessageChannel channel, UserInfoModel model) {
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(USER_INFO_RESPONSE, model, channel));
}
@Transactional
public CompletableFuture<InteractionHook> sendResponse(IReplyCallback callback, UserInfoModel model) {
return interactionService.replyEmbed(USER_INFO_RESPONSE, model, callback);
@@ -204,6 +169,7 @@ public class UserInfo extends AbstractConditionableCommand {
.slashCommandConfig(slashCommandConfig)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.causesReaction(false)