[AB-8] upgrading to new JDA alpha version 19

cleaning up imports
This commit is contained in:
Sheldan
2022-09-18 15:51:49 +02:00
parent 102209aaca
commit 4e1f9e0018
216 changed files with 682 additions and 704 deletions

View File

@@ -24,7 +24,7 @@ import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementS
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
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 org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +37,7 @@ import java.util.concurrent.CompletableFuture;
/**
* This command is used to create a thread with a member directly. If a thread already exists, this will post a link to
* the {@link net.dv8tion.jda.api.entities.MessageChannel}
* the {@link net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel}
*/
@Component
@Slf4j

View File

@@ -12,6 +12,8 @@ import dev.sheldan.abstracto.modmail.model.database.ModMailThread;
import dev.sheldan.abstracto.modmail.model.template.ModmailLoggingThreadMessages;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@@ -28,9 +28,7 @@ import dev.sheldan.abstracto.modmail.exception.ModMailThreadChannelNotFound;
import dev.sheldan.abstracto.modmail.exception.ModMailThreadNotFoundException;
import dev.sheldan.abstracto.modmail.model.ClosingContext;
import dev.sheldan.abstracto.modmail.model.dto.ServiceChoicesPayload;
import dev.sheldan.abstracto.modmail.model.template.ServerChoices;
import dev.sheldan.abstracto.modmail.model.database.*;
import dev.sheldan.abstracto.modmail.model.template.ServerChoice;
import dev.sheldan.abstracto.modmail.model.template.*;
import dev.sheldan.abstracto.modmail.service.management.ModMailMessageManagementService;
import dev.sheldan.abstracto.modmail.service.management.ModMailRoleManagementService;
@@ -41,6 +39,9 @@ import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.interactions.InteractionHook;
import org.apache.commons.lang3.RandomStringUtils;
@@ -64,7 +65,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
*/
public static final String MODMAIL_CLOSING_MESSAGE_TEXT = "modMailClosingText";
/**
* The config key to use for the ID of the category to create {@link MessageChannel} in
* The config key to use for the ID of the category to create {@link GuildMessageChannel} in
*/
public static final String MODMAIL_CATEGORY = "modmailCategory";
public static final String TEXT_CHANNEL_NAME_TEMPLATE_KEY = "modMail_channel_name";
@@ -467,14 +468,14 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
* This message takes a received {@link Message} from a user, renders it to a new message to send and sends it to
* the appropriate {@link ModMailThread} channel, the returned promise only returns if the message was dealt with on the user
* side.
* @param textChannel The {@link GuildMessageChannel} in which the {@link ModMailThread} is being handled
* @param messageChannel The {@link GuildMessageChannel} in which the {@link ModMailThread} is being handled
* @param modMailThreadId The id of the modmail thread to which the received {@link Message} is a reply to, can be null, if it is null, its the initial message
* @param messageFromUser The received message from the user
* @param member The {@link Member} instance from the user the thread is about. It is used as author
* @param modMailThreadExists Whether or not the modmail thread already exists and is persisted.
* @return A {@link CompletableFuture} which resolves when the post processing of the message is completed (adding read notification, and storing messageIDs)
*/
public CompletableFuture<Message> sendUserReply(GuildMessageChannel textChannel, Long modMailThreadId, Message messageFromUser, Member member, boolean modMailThreadExists) {
public CompletableFuture<Message> sendUserReply(GuildMessageChannel messageChannel, Long modMailThreadId, Message messageFromUser, Member member, boolean modMailThreadExists) {
List<CompletableFuture<Member>> subscriberMemberFutures = new ArrayList<>();
if(modMailThreadExists) {
ModMailThread modMailThread = modMailThreadManagementService.getById(modMailThreadId);
@@ -520,17 +521,17 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
.remainingAttachments(otherAttachments)
.subscribers(subscribers)
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate("modmail_user_message", modMailUserReplyModel, textChannel.getGuild().getIdLong());
List<CompletableFuture<Message>> completableFutures = channelService.sendMessageToSendToChannel(messageToSend, textChannel);
MessageToSend messageToSend = templateService.renderEmbedTemplate("modmail_user_message", modMailUserReplyModel, messageChannel.getGuild().getIdLong());
List<CompletableFuture<Message>> completableFutures = channelService.sendMessageToSendToChannel(messageToSend, messageChannel);
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0]))
.thenCompose(aVoid -> {
log.debug("Adding read reaction to initial message for mod mail thread in channel {}.", textChannel.getGuild().getId());
return reactionService.addReactionToMessageAsync("readReaction", textChannel.getGuild().getIdLong(), messageFromUser);
log.debug("Adding read reaction to initial message for mod mail thread in channel {}.", messageChannel.getGuild().getId());
return reactionService.addReactionToMessageAsync("readReaction", messageChannel.getGuild().getIdLong(), messageFromUser);
})
.thenApply(aVoid -> {
Message createdMessage = completableFutures.get(0).join();
if(modMailThreadExists) {
self.postProcessSendMessages(textChannel, createdMessage, messageFromUser);
self.postProcessSendMessages(messageChannel, createdMessage, messageFromUser);
}
return messageFuture.complete(createdMessage);
}).exceptionally(throwable1 -> {

View File

@@ -16,10 +16,9 @@ import dev.sheldan.abstracto.modmail.service.ModMailThreadServiceBean;
import dev.sheldan.abstracto.modmail.validator.ModMailFeatureValidator;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Category;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.entities.channel.concrete.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@@ -9,8 +9,8 @@ import dev.sheldan.abstracto.core.service.GuildService;
import dev.sheldan.abstracto.modmail.model.template.ModMailCategoryValidationErrorModel;
import dev.sheldan.abstracto.modmail.service.ModMailThreadServiceBean;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Category;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.channel.concrete.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;