mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-12 19:18:42 +00:00
[AB-8] upgrading to new JDA alpha version 19
cleaning up imports
This commit is contained in:
@@ -35,6 +35,9 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
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.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -408,9 +411,9 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
.filter(TextChannel.class::isInstance)
|
||||
.map(TextChannel.class::cast)
|
||||
.iterator();
|
||||
Iterator<Emote> emoteIterator = message
|
||||
Iterator<CustomEmoji> emoteIterator = message
|
||||
.getMentions()
|
||||
.getEmotesBag()
|
||||
.getCustomEmojisBag()
|
||||
.iterator();
|
||||
Iterator<Member> memberIterator = message
|
||||
.getMentions()
|
||||
|
||||
@@ -11,7 +11,7 @@ import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import dev.sheldan.abstracto.core.command.handler.provided.EmoteParameterHandler
|
||||
import dev.sheldan.abstracto.core.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class AEmoteParameterHandlerImpl implements AEmoteParameterHandler {
|
||||
@Override
|
||||
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
|
||||
Parameter cloned = commandService.cloneParameter(param);
|
||||
cloned.setType(Emote.class);
|
||||
Emote emote = (Emote) emoteParameterHandler.handle(input, iterators, cloned, context, command);
|
||||
cloned.setType(CustomEmoji.class);
|
||||
CustomEmoji emote = (CustomEmoji) emoteParameterHandler.handle(input, iterators, cloned, context, command);
|
||||
if(emote != null) {
|
||||
return emoteService.getFakeEmoteFromEmote(emote);
|
||||
} else {
|
||||
|
||||
@@ -6,8 +6,8 @@ import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.ParameterPieceType;
|
||||
import dev.sheldan.abstracto.core.command.execution.UnparsedCommandParameterPiece;
|
||||
import dev.sheldan.abstracto.core.command.handler.provided.EmoteParameterHandler;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -18,19 +18,19 @@ public class EmoteParameterHandlerImpl implements EmoteParameterHandler {
|
||||
|
||||
@Override
|
||||
public boolean handles(Class clazz, UnparsedCommandParameterPiece value) {
|
||||
return clazz.equals(Emote.class) && value.getType().equals(ParameterPieceType.STRING);
|
||||
return clazz.equals(CustomEmoji.class) && value.getType().equals(ParameterPieceType.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
|
||||
String inputString = ((String) input.getValue()).trim();
|
||||
Matcher matcher = Message.MentionType.EMOTE.getPattern().matcher(inputString);
|
||||
Matcher matcher = Message.MentionType.EMOJI.getPattern().matcher(inputString);
|
||||
if(matcher.matches() && iterators.getEmoteIterator().hasNext()) {
|
||||
return iterators.getEmoteIterator().next();
|
||||
} else {
|
||||
if(StringUtils.isNumeric(inputString)) {
|
||||
long emoteId = Long.parseLong(inputString);
|
||||
return context.getGuild().getEmoteById(emoteId);
|
||||
return context.getGuild().getEmojiById(emoteId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import dev.sheldan.abstracto.core.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.models.FullEmote;
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -36,8 +36,8 @@ public class FullEmoteParameterHandlerImpl implements FullEmoteParameterHandler
|
||||
@Override
|
||||
public Object handle(UnparsedCommandParameterPiece input, CommandParameterIterators iterators, Parameter param, Message context, Command command) {
|
||||
Parameter cloned = commandService.cloneParameter(param);
|
||||
cloned.setType(Emote.class);
|
||||
Emote emote = (Emote) emoteParameterHandler.handle(input, iterators, cloned, context, command);
|
||||
cloned.setType(CustomEmoji.class);
|
||||
CustomEmoji emote = (CustomEmoji) emoteParameterHandler.handle(input, iterators, cloned, context, command);
|
||||
AEmote aEmote;
|
||||
if(emote != null) {
|
||||
aEmote = emoteService.getFakeEmoteFromEmote(emote);
|
||||
|
||||
@@ -8,7 +8,7 @@ import dev.sheldan.abstracto.core.command.execution.ParameterPieceType;
|
||||
import dev.sheldan.abstracto.core.command.execution.UnparsedCommandParameterPiece;
|
||||
import dev.sheldan.abstracto.core.command.handler.provided.TextChannelParameterHandler;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import dev.sheldan.abstracto.core.command.execution.ParameterPieceType;
|
||||
import dev.sheldan.abstracto.core.command.execution.UnparsedCommandParameterPiece;
|
||||
import dev.sheldan.abstracto.core.command.handler.provided.VoiceChannelParameterHandler;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
import dev.sheldan.abstracto.core.models.GuildChannelMember;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.ReactionService;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -4,7 +4,6 @@ import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.model.exception.GenericExceptionModel;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
import dev.sheldan.abstracto.core.models.FullUser;
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
@@ -16,8 +15,8 @@ import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -14,8 +14,8 @@ import dev.sheldan.abstracto.core.exception.EntityGuildMismatchException;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
import dev.sheldan.abstracto.core.service.ChannelGroupService;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -28,6 +28,9 @@ import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
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.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -17,7 +17,7 @@ import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.service.ChannelGroupService;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -3,9 +3,9 @@ package dev.sheldan.abstracto.core.interaction;
|
||||
import dev.sheldan.abstracto.core.interaction.button.ButtonConfigModel;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.MessageService;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
@@ -15,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,7 +42,7 @@ public class ComponentServiceBean implements ComponentService {
|
||||
return channelService.retrieveMessageInChannel(textChannel, messageId).thenCompose(message -> {
|
||||
Button button = Button.of(style, buttonId, description);
|
||||
if(emoteMarkdown != null) {
|
||||
button = button.withEmoji(Emoji.fromMarkdown(emoteMarkdown));
|
||||
button = button.withEmoji(Emoji.fromFormatted(emoteMarkdown));
|
||||
}
|
||||
List<ActionRow> actionRows;
|
||||
if(message.getActionRows().isEmpty()) {
|
||||
|
||||
@@ -18,10 +18,11 @@ import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageUpdateAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageCreateAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.WebhookMessageEditAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
|
||||
import net.dv8tion.jda.api.utils.AttachmentOption;
|
||||
import net.dv8tion.jda.api.utils.FileUpload;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -31,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.sheldan.abstracto.core.config.MetricConstants.DISCORD_API_INTERACTION_METRIC;
|
||||
import static dev.sheldan.abstracto.core.config.MetricConstants.INTERACTION_TYPE;
|
||||
@@ -64,33 +66,33 @@ public class InteractionServiceBean implements InteractionService {
|
||||
@Override
|
||||
public List<CompletableFuture<Message>> sendMessageToInteraction(MessageToSend messageToSend, InteractionHook interactionHook) {
|
||||
List<CompletableFuture<Message>> futures = new ArrayList<>();
|
||||
List<WebhookMessageAction<Message>> allMessageActions = new ArrayList<>();
|
||||
List<WebhookMessageCreateAction<Message>> allMessageActions = new ArrayList<>();
|
||||
int iterations = Math.min(messageToSend.getMessages().size(), messageToSend.getEmbeds().size());
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
String text = messageToSend.getMessages().get(i);
|
||||
MessageEmbed embed = messageToSend.getEmbeds().get(i);
|
||||
WebhookMessageAction<Message> messageAction = interactionHook.sendMessage(text).addEmbeds(embed);
|
||||
WebhookMessageCreateAction<Message> messageAction = interactionHook.sendMessage(text).addEmbeds(embed);
|
||||
allMessageActions.add(messageAction);
|
||||
}
|
||||
// one of these loops will get additional iterations, if the number is different, not both
|
||||
for (int i = iterations; i < messageToSend.getMessages().size(); i++) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
String text = messageToSend.getMessages().get(i);
|
||||
WebhookMessageAction<Message> messageAction = interactionHook.sendMessage(text);
|
||||
WebhookMessageCreateAction<Message> messageAction = interactionHook.sendMessage(text);
|
||||
allMessageActions.add(messageAction);
|
||||
}
|
||||
for (int i = iterations; i < messageToSend.getEmbeds().size(); i++) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
MessageEmbed embed = messageToSend.getEmbeds().get(i);
|
||||
WebhookMessageAction<Message> messageAction = interactionHook.sendMessageEmbeds(embed);
|
||||
WebhookMessageCreateAction<Message> messageAction = interactionHook.sendMessageEmbeds(embed);
|
||||
allMessageActions.add(messageAction);
|
||||
}
|
||||
|
||||
List<ActionRow> actionRows = messageToSend.getActionRows();
|
||||
if(!actionRows.isEmpty()) {
|
||||
AServer server = serverManagementService.loadServer(interactionHook.getInteraction().getGuild());
|
||||
allMessageActions.set(0, allMessageActions.get(0).addActionRows(actionRows));
|
||||
allMessageActions.set(0, allMessageActions.get(0).addComponents(actionRows));
|
||||
actionRows.forEach(components -> components.forEach(component -> {
|
||||
if(component instanceof ActionComponent) {
|
||||
String id = ((ActionComponent)component).getId();
|
||||
@@ -111,24 +113,21 @@ public class InteractionServiceBean implements InteractionService {
|
||||
}
|
||||
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
.getAttachedFiles()
|
||||
.stream()
|
||||
.map(AttachedFile::convertToFileUpload)
|
||||
.collect(Collectors.toList());
|
||||
if(!allMessageActions.isEmpty()) {
|
||||
// in case there has not been a message, we need to increment it
|
||||
messageToSend.getAttachedFiles().forEach(attachedFile ->
|
||||
allMessageActions.set(0, allMessageActions.get(0).addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]))));
|
||||
allMessageActions.set(0, allMessageActions.get(0).setFiles(attachedFiles));
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
List<AttachedFile> attachedFiles = messageToSend.getAttachedFiles();
|
||||
AttachedFile firstFile = attachedFiles.get(0);
|
||||
allMessageActions.add(interactionHook.sendFile(firstFile.getFile(), firstFile.getFileName(), firstFile.getOptions().toArray(new AttachmentOption[0])));
|
||||
attachedFiles
|
||||
.stream()
|
||||
.skip(1)
|
||||
.forEach(attachedFile -> allMessageActions
|
||||
.add(interactionHook.sendFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]))));
|
||||
allMessageActions.add(interactionHook.sendFiles(attachedFiles));
|
||||
}
|
||||
}
|
||||
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(interactionHook.getInteraction().getMessageChannel(), messageToSend);
|
||||
allMessageActions.forEach(messageAction -> futures.add(messageAction.allowedMentions(allowedMentions).setEphemeral(messageToSend.getEphemeral()).submit()));
|
||||
allMessageActions.forEach(messageAction -> futures.add(messageAction.setAllowedMentions(allowedMentions).setEphemeral(messageToSend.getEphemeral()).submit()));
|
||||
return futures;
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
public CompletableFuture<InteractionHook> replyString(String text, IReplyCallback callback) {
|
||||
return callback
|
||||
.reply(text)
|
||||
.allowedMentions(allowedMentionService.getAllowedMentionTypesForServer(callback.getGuild().getIdLong()))
|
||||
.setAllowedMentions(allowedMentionService.getAllowedMentionTypesForServer(callback.getGuild().getIdLong()))
|
||||
.submit();
|
||||
}
|
||||
|
||||
@@ -171,7 +170,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
interactionHook.setEphemeral(true);
|
||||
}
|
||||
|
||||
WebhookMessageUpdateAction<Message> action = null;
|
||||
WebhookMessageEditAction<Message> action = null;
|
||||
if(messageToSend.getMessages() != null && !messageToSend.getMessages().isEmpty()) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
action = interactionHook.editOriginal(messageToSend.getMessages().get(0));
|
||||
@@ -186,31 +185,17 @@ public class InteractionServiceBean implements InteractionService {
|
||||
}
|
||||
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
.getAttachedFiles()
|
||||
.stream()
|
||||
.map(AttachedFile::convertToFileUpload)
|
||||
.collect(Collectors.toList());
|
||||
if(action != null) {
|
||||
List<AttachedFile> attachedFiles = messageToSend.getAttachedFiles();
|
||||
AttachedFile firstFile = attachedFiles.get(0);
|
||||
action = action.addFile(firstFile.getFile(), firstFile.getFileName(), firstFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
boolean first = true;
|
||||
for (AttachedFile attachedFile : attachedFiles) {
|
||||
if (first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
action = action.addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
}
|
||||
action.setFiles(attachedFiles);
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
List<AttachedFile> attachedFiles = messageToSend.getAttachedFiles();
|
||||
AttachedFile firstFile = attachedFiles.get(0);
|
||||
action = interactionHook.editOriginal(firstFile.getFile(), firstFile.getFileName(), firstFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
boolean first = true;
|
||||
for (AttachedFile attachedFile : attachedFiles) {
|
||||
if (first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
action = action.addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
}
|
||||
MessageEditData messageEditData = MessageEditData.fromFiles(attachedFiles);
|
||||
action = interactionHook.editOriginal(messageEditData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +206,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
if(action == null) {
|
||||
action = interactionHook.editOriginal(".");
|
||||
}
|
||||
action = action.setActionRows(actionRows);
|
||||
action = action.setComponents(actionRows);
|
||||
AServer server = serverManagementService.loadServer(serverId);
|
||||
actionRows.forEach(components -> components.forEach(component -> {
|
||||
if(component instanceof ActionComponent) {
|
||||
@@ -257,31 +242,16 @@ public class InteractionServiceBean implements InteractionService {
|
||||
}
|
||||
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
.getAttachedFiles()
|
||||
.stream()
|
||||
.map(AttachedFile::convertToFileUpload)
|
||||
.collect(Collectors.toList());
|
||||
if(action != null) {
|
||||
List<AttachedFile> attachedFiles = messageToSend.getAttachedFiles();
|
||||
AttachedFile firstFile = attachedFiles.get(0);
|
||||
action = action.addFile(firstFile.getFile(), firstFile.getFileName(), firstFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
boolean first = true;
|
||||
for (AttachedFile attachedFile : attachedFiles) {
|
||||
if (first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
action = action.addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
}
|
||||
action.setFiles(attachedFiles);
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
List<AttachedFile> attachedFiles = messageToSend.getAttachedFiles();
|
||||
AttachedFile firstFile = attachedFiles.get(0);
|
||||
action = callback.replyFile(firstFile.getFile(), firstFile.getFileName(), firstFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
boolean first = true;
|
||||
for (AttachedFile attachedFile : attachedFiles) {
|
||||
if (first) {
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
action = action.addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]));
|
||||
}
|
||||
action = callback.replyFiles(attachedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +262,7 @@ public class InteractionServiceBean implements InteractionService {
|
||||
if(action == null) {
|
||||
action = callback.reply(".");
|
||||
}
|
||||
action = action.addActionRows(actionRows);
|
||||
action = action.setComponents(actionRows);
|
||||
AServer server = serverManagementService.loadServer(serverId);
|
||||
actionRows.forEach(components -> components.forEach(component -> {
|
||||
if(component instanceof ActionComponent) {
|
||||
|
||||
@@ -4,8 +4,8 @@ import dev.sheldan.abstracto.core.interaction.slash.parameter.provider.SlashComm
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.service.EmoteService;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -58,7 +58,7 @@ public class SlashCommandParameterServiceBean implements SlashCommandParameterSe
|
||||
} else if(actualOptionType == OptionType.MENTIONABLE) {
|
||||
return slashParameterType.cast(event.getOption(name).getAsMentionable());
|
||||
} else if(actualOptionType == OptionType.CHANNEL) {
|
||||
return slashParameterType.cast(event.getOption(name).getAsGuildChannel());
|
||||
return slashParameterType.cast(event.getOption(name).getAsChannel());
|
||||
} else if(actualOptionType == OptionType.USER) {
|
||||
if(parameterType.equals(User.class) && slashParameterType.equals(User.class)) {
|
||||
return slashParameterType.cast(event.getOption(name).getAsUser());
|
||||
@@ -104,7 +104,7 @@ public class SlashCommandParameterServiceBean implements SlashCommandParameterSe
|
||||
} else if(actualOptionType == OptionType.MENTIONABLE) {
|
||||
return slashParameterType.isInstance(event.getOption(name).getAsMentionable());
|
||||
} else if(actualOptionType == OptionType.CHANNEL) {
|
||||
return slashParameterType.isInstance(event.getOption(name).getAsGuildChannel());
|
||||
return slashParameterType.isInstance(event.getOption(name).getAsChannel());
|
||||
} else if(actualOptionType == OptionType.USER) {
|
||||
if (parameterType.equals(User.class) && slashParameterType.equals(User.class)) {
|
||||
return slashParameterType.isInstance(event.getOption(name).getAsUser());
|
||||
@@ -146,9 +146,9 @@ public class SlashCommandParameterServiceBean implements SlashCommandParameterSe
|
||||
public Emoji loadEmoteFromString(String input, SlashCommandInteractionEvent event) {
|
||||
if(StringUtils.isNumeric(input)) {
|
||||
long emoteId = Long.parseLong(input);
|
||||
return Emoji.fromEmote(event.getGuild().getEmoteById(emoteId));
|
||||
return event.getGuild().getEmojiById(emoteId);
|
||||
}
|
||||
return Emoji.fromMarkdown(input);
|
||||
return Emoji.fromFormatted(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.sheldan.abstracto.core.interaction.slash.parameter.provider.provided
|
||||
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandOptionTypeMapping;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.provider.SlashCommandParameterProvider;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class EmoteSlashCommandParameterProvider implements SlashCommandParameter
|
||||
public SlashCommandOptionTypeMapping getOptionMapping() {
|
||||
return SlashCommandOptionTypeMapping
|
||||
.builder()
|
||||
.type(Emote.class)
|
||||
.type(CustomEmoji.class)
|
||||
.optionTypes(Arrays.asList(OptionType.STRING))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.sheldan.abstracto.core.interaction.slash.parameter.provider.provided
|
||||
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandOptionTypeMapping;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.provider.SlashCommandParameterProvider;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.sheldan.abstracto.core.interaction.slash.parameter.provider.provided
|
||||
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandOptionTypeMapping;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.provider.SlashCommandParameterProvider;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.sheldan.abstracto.core.interaction.slash.parameter.provider.provided
|
||||
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandOptionTypeMapping;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.provider.SlashCommandParameterProvider;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import dev.sheldan.abstracto.core.service.management.UserInServerManagementServi
|
||||
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.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import dev.sheldan.abstracto.core.models.listener.AChannelCreatedListenerModel;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Channel;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.sheldan.abstracto.core.listener.async.jda;
|
||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.listener.EmoteCreatedModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.EmoteAddedEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,13 +30,13 @@ public class AsyncEmoteCreatedListenerBean extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onEmoteAdded(@NotNull EmoteAddedEvent event) {
|
||||
public void onEmojiAdded(@NotNull EmojiAddedEvent event) {
|
||||
if(listenerList == null) return;
|
||||
EmoteCreatedModel model = getModel(event);
|
||||
listenerList.forEach(joinListener -> listenerService.executeFeatureAwareListener(joinListener, model, emoteCreatedListenerExecutor));
|
||||
}
|
||||
|
||||
private EmoteCreatedModel getModel(EmoteAddedEvent event) {
|
||||
return EmoteCreatedModel.builder().emote(event.getEmote()).build();
|
||||
private EmoteCreatedModel getModel(EmojiAddedEvent event) {
|
||||
return EmoteCreatedModel.builder().emote(event.getEmoji()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.sheldan.abstracto.core.listener.async.jda;
|
||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.listener.EmoteDeletedModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.EmoteRemovedEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,13 +30,13 @@ public class AsyncEmoteDeletedListenerBean extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onEmoteRemoved(@NotNull EmoteRemovedEvent event) {
|
||||
public void onEmojiRemoved(@NotNull EmojiRemovedEvent event) {
|
||||
if(listenerList == null) return;
|
||||
EmoteDeletedModel model = getModel(event);
|
||||
listenerList.forEach(deletedListener -> listenerService.executeFeatureAwareListener(deletedListener, model, emoteDeletedListenerExecutor));
|
||||
}
|
||||
|
||||
private EmoteDeletedModel getModel(EmoteRemovedEvent event) {
|
||||
return EmoteDeletedModel.builder().emote(event.getEmote()).build();
|
||||
private EmoteDeletedModel getModel(EmojiRemovedEvent event) {
|
||||
return EmoteDeletedModel.builder().emote(event.getEmoji()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.sheldan.abstracto.core.listener.async.jda;
|
||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.listener.EmoteNameUpdatedModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.update.EmoteUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.update.EmojiUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,14 +30,14 @@ public class AsyncEmoteUpdatedListenerBean extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onEmoteUpdateName(@NotNull EmoteUpdateNameEvent event) {
|
||||
public void onEmojiUpdateName(@NotNull EmojiUpdateNameEvent event) {
|
||||
if(listenerList == null) return;
|
||||
EmoteNameUpdatedModel model = getModel(event);
|
||||
listenerList.forEach(deletedListener -> listenerService.executeFeatureAwareListener(deletedListener, model, emoteDeletedListenerExecutor));
|
||||
}
|
||||
|
||||
private EmoteNameUpdatedModel getModel(EmoteUpdateNameEvent event) {
|
||||
return EmoteNameUpdatedModel.builder().emote(event.getEmote()).newValue(event.getNewValue()).oldValue(event.getOldValue()).build();
|
||||
private EmoteNameUpdatedModel getModel(EmojiUpdateNameEvent event) {
|
||||
return EmoteNameUpdatedModel.builder().emote(event.getEmoji()).newValue(event.getNewValue()).oldValue(event.getOldValue()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.service.BotService;
|
||||
import dev.sheldan.abstracto.core.service.CacheEntityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -9,7 +9,6 @@ import dev.sheldan.abstracto.core.metric.service.MetricTag;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedAttachment;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.models.listener.MessageUpdatedModel;
|
||||
import dev.sheldan.abstracto.core.service.CacheEntityService;
|
||||
import dev.sheldan.abstracto.core.service.MessageCache;
|
||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.listener.EmoteCreatedModel;
|
||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.EmoteAddedEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,14 +26,14 @@ public class EmoteCreatedListenerBean extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onEmoteAdded(@NotNull EmoteAddedEvent event) {
|
||||
public void onEmojiAdded(@NotNull EmojiAddedEvent event) {
|
||||
if(createdListeners == null) return;
|
||||
EmoteCreatedModel model = getModel(event);
|
||||
createdListeners.forEach(listener -> listenerService.executeFeatureAwareListener(listener, model));
|
||||
}
|
||||
|
||||
private EmoteCreatedModel getModel(EmoteAddedEvent event) {
|
||||
return EmoteCreatedModel.builder().emote(event.getEmote()).build();
|
||||
private EmoteCreatedModel getModel(EmojiAddedEvent event) {
|
||||
return EmoteCreatedModel.builder().emote(event.getEmoji()).build();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
||||
@@ -7,7 +7,7 @@ import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.EmoteRemovedEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,14 +38,14 @@ public class EmoteDeletedListenerBean extends ListenerAdapter {
|
||||
private ListenerService listenerService;
|
||||
|
||||
@Override
|
||||
public void onEmoteRemoved(@NotNull EmoteRemovedEvent event) {
|
||||
public void onEmojiRemoved(@NotNull EmojiRemovedEvent event) {
|
||||
if(deletedListeners == null) return;
|
||||
EmoteDeletedModel model = getModel(event);
|
||||
deletedListeners.forEach(listener -> listenerService.executeFeatureAwareListener(listener, model));
|
||||
}
|
||||
|
||||
private EmoteDeletedModel getModel(EmoteRemovedEvent event) {
|
||||
return EmoteDeletedModel.builder().emote(event.getEmote()).build();
|
||||
private EmoteDeletedModel getModel(EmojiRemovedEvent event) {
|
||||
return EmoteDeletedModel.builder().emote(event.getEmoji()).build();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
||||
@@ -2,12 +2,9 @@ package dev.sheldan.abstracto.core.listener.sync.jda;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||
import dev.sheldan.abstracto.core.models.listener.EmoteNameUpdatedModel;
|
||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.emote.update.EmoteUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.events.emoji.update.EmojiUpdateNameEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -25,29 +22,20 @@ public class EmoteUpdatedListenerBean extends ListenerAdapter {
|
||||
@Autowired(required = false)
|
||||
private List<EmoteUpdatedListener> updatedListeners;
|
||||
|
||||
@Autowired
|
||||
private FeatureFlagService featureFlagService;
|
||||
|
||||
@Autowired
|
||||
private FeatureConfigService featureConfigService;
|
||||
|
||||
@Autowired
|
||||
private FeatureModeService featureModeService;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ListenerService listenerService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onEmoteUpdateName(@NotNull EmoteUpdateNameEvent event) {
|
||||
public void onEmojiUpdateName(@NotNull EmojiUpdateNameEvent event) {
|
||||
if(updatedListeners == null) return;
|
||||
EmoteNameUpdatedModel model = getModel(event);
|
||||
updatedListeners.forEach(emoteUpdatedListener -> listenerService.executeFeatureAwareListener(emoteUpdatedListener, model));
|
||||
}
|
||||
|
||||
private EmoteNameUpdatedModel getModel(EmoteUpdateNameEvent event) {
|
||||
return EmoteNameUpdatedModel.builder().emote(event.getEmote()).newValue(event.getNewValue()).oldValue(event.getOldValue()).build();
|
||||
private EmoteNameUpdatedModel getModel(EmojiUpdateNameEvent event) {
|
||||
return EmoteNameUpdatedModel.builder().emote(event.getEmoji()).newValue(event.getNewValue()).oldValue(event.getOldValue()).build();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.sheldan.abstracto.core.command.service.ExceptionService;
|
||||
import dev.sheldan.abstracto.core.service.BotService;
|
||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -7,9 +7,9 @@ import dev.sheldan.abstracto.core.service.management.AllowedMentionManagementSer
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageConfig;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import okhttp3.OkHttpClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.time.Duration;
|
||||
@@ -35,10 +34,10 @@ public class BotServiceBean implements BotService {
|
||||
private OkHttpLogger okHttpLogger;
|
||||
|
||||
@Override
|
||||
public void login() throws LoginException {
|
||||
public void login() {
|
||||
JDABuilder builder = JDABuilder.createDefault(System.getenv("TOKEN"));
|
||||
builder.enableIntents(GUILD_VOICE_STATES, GUILD_BANS,
|
||||
GUILD_EMOJIS, GUILD_MEMBERS, GUILD_MESSAGES,
|
||||
builder.enableIntents(GUILD_VOICE_STATES, GUILD_BANS, MESSAGE_CONTENT,
|
||||
GUILD_EMOJIS_AND_STICKERS, GUILD_MEMBERS, GUILD_MESSAGES,
|
||||
GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGES, GUILD_PRESENCES);
|
||||
|
||||
builder.enableCache(CacheFlag.ACTIVITY);
|
||||
|
||||
@@ -6,6 +6,8 @@ import dev.sheldan.abstracto.core.service.management.UserInServerManagementServi
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationAction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -33,7 +35,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
private CacheEntityServiceBean concreteSelf;
|
||||
|
||||
@Override
|
||||
public CachedEmote getCachedEmoteFromEmote(Emote emote, Guild guild) {
|
||||
public CachedEmote getCachedEmoteFromEmote(CustomEmoji emote, Guild guild) {
|
||||
return CachedEmote.builder()
|
||||
.emoteId(emote.getIdLong())
|
||||
.emoteName(emote.getName())
|
||||
@@ -45,20 +47,21 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CachedEmote getCachedEmoteFromEmote(MessageReaction.ReactionEmote emote, Guild guild) {
|
||||
if(emote.isEmoji()) {
|
||||
public CachedEmote getCachedEmoteFromEmote(Emoji emote, Guild guild) {
|
||||
if(!(emote instanceof CustomEmoji)) {
|
||||
return CachedEmote.builder()
|
||||
.emoteName(emote.getName())
|
||||
.custom(false)
|
||||
.build();
|
||||
} else {
|
||||
CustomEmoji customEmoji = (CustomEmoji) emote;
|
||||
return CachedEmote.builder()
|
||||
.emoteId(emote.getIdLong())
|
||||
.emoteId(customEmoji.getIdLong())
|
||||
.emoteName(emote.getName())
|
||||
.imageURL(emote.getEmote().getImageUrl())
|
||||
.external(emoteService.emoteIsFromGuild(emote.getEmote(), guild))
|
||||
.imageURL(customEmoji.getImageUrl())
|
||||
.external(emoteService.emoteIsFromGuild(customEmoji, guild))
|
||||
.custom(true)
|
||||
.animated(emote.getEmote().isAnimated())
|
||||
.animated(customEmoji.isAnimated())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -187,7 +190,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
}
|
||||
builder.users(aUsers);
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getEmoji(), reaction.getGuild()));
|
||||
future.complete(builder.build());
|
||||
}).exceptionally(throwable -> {
|
||||
future.completeExceptionally(throwable);
|
||||
@@ -212,7 +215,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
if(message.isFromGuild()) {
|
||||
message
|
||||
.getMentions()
|
||||
.getEmotesBag()
|
||||
.getCustomEmojisBag()
|
||||
.forEach(emote -> emotes.add(getCachedEmoteFromEmote(emote, message.getGuild())));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ import dev.sheldan.abstracto.core.service.management.ChannelGroupManagementServi
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -17,11 +17,18 @@ import dev.sheldan.abstracto.core.utils.FileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.Category;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionComponent;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.ItemComponent;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
||||
import net.dv8tion.jda.api.utils.AttachmentOption;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageEditAction;
|
||||
import net.dv8tion.jda.api.utils.FileUpload;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -124,14 +131,15 @@ public class ChannelServiceBean implements ChannelService {
|
||||
log.debug("Sending message {} from channel {} and server {} to channel {}.",
|
||||
message.getId(), message.getChannel().getId(), message.getGuild().getId(), channel.getId());
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
return channel.sendMessage(message).allowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null)).submit();
|
||||
MessageCreateData messageCreateData = MessageCreateData.fromMessage(message);
|
||||
return channel.sendMessage(messageCreateData).setAllowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Message> sendTextToChannel(String text, MessageChannel channel) {
|
||||
log.debug("Sending text to channel {}.", channel.getId());
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
return channel.sendMessage(text).allowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null)).submit();
|
||||
return channel.sendMessage(text).setAllowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,9 +166,9 @@ public class ChannelServiceBean implements ChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageAction sendEmbedToChannelInComplete(MessageEmbed embed, MessageChannel channel) {
|
||||
public MessageCreateAction sendEmbedToChannelInComplete(MessageEmbed embed, MessageChannel channel) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
return channel.sendMessageEmbeds(embed).allowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null));
|
||||
return channel.sendMessageEmbeds(embed).setAllowedMentions(allowedMentionService.getAllowedMentionsFor(channel, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,7 +200,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
throw new IllegalArgumentException("Ephemeral messages are only supported in interaction context.");
|
||||
}
|
||||
List<CompletableFuture<Message>> futures = new ArrayList<>();
|
||||
List<MessageAction> allMessageActions = new ArrayList<>();
|
||||
List<MessageCreateAction> allMessageActions = new ArrayList<>();
|
||||
Iterator<MessageEmbed> embedIterator = messageToSend.getEmbeds().iterator();
|
||||
for (int i = 0; i < messageToSend.getMessages().size(); i++) {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
@@ -206,7 +214,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
messageEmbeds.add(embedToAdd);
|
||||
embedIterator.remove();
|
||||
}
|
||||
MessageAction messageAction = textChannel.sendMessage(text);
|
||||
MessageCreateAction messageAction = textChannel.sendMessage(text);
|
||||
if(!messageEmbeds.isEmpty()) {
|
||||
messageAction.setEmbeds(messageEmbeds);
|
||||
}
|
||||
@@ -235,11 +243,11 @@ public class ChannelServiceBean implements ChannelService {
|
||||
if(!actionRows.isEmpty()) {
|
||||
List<List<ActionRow>> groupedActionRows = ListUtils.partition(actionRows, ComponentService.MAX_BUTTONS_PER_ROW);
|
||||
for (int i = 0; i < allMessageActions.size(); i++) {
|
||||
allMessageActions.set(i, allMessageActions.get(i).setActionRows(groupedActionRows.get(i)));
|
||||
allMessageActions.set(i, allMessageActions.get(i).setComponents(groupedActionRows.get(i)));
|
||||
}
|
||||
for (int i = allMessageActions.size(); i < groupedActionRows.size(); i++) {
|
||||
// TODO maybe possible nicer
|
||||
allMessageActions.add(textChannel.sendMessage(".").setActionRows(groupedActionRows.get(i)));
|
||||
allMessageActions.add(textChannel.sendMessage(".").setComponents(groupedActionRows.get(i)));
|
||||
}
|
||||
AServer server = null;
|
||||
if(textChannel instanceof GuildChannel) {
|
||||
@@ -260,38 +268,28 @@ public class ChannelServiceBean implements ChannelService {
|
||||
}
|
||||
|
||||
if(messageToSend.hasFilesToSend()) {
|
||||
List<FileUpload> attachedFiles = messageToSend
|
||||
.getAttachedFiles()
|
||||
.stream()
|
||||
.map(AttachedFile::convertToFileUpload)
|
||||
.collect(Collectors.toList());
|
||||
if(!allMessageActions.isEmpty()) {
|
||||
// in case there has not been a message, we need to increment it
|
||||
messageToSend.getAttachedFiles().forEach(attachedFile -> {
|
||||
String fileNameToUse = attachedFile.getFileName() != null ? attachedFile.getFileName() : attachedFile.getFile().getName();
|
||||
allMessageActions.set(0, allMessageActions.get(0)
|
||||
.addFile(attachedFile.getFile(), fileNameToUse, attachedFile.getOptions().toArray(new AttachmentOption[0])));
|
||||
});
|
||||
allMessageActions.set(0, allMessageActions.get(0).addFiles(attachedFiles));
|
||||
} else {
|
||||
metricService.incrementCounter(MESSAGE_SEND_METRIC);
|
||||
messageToSend.getAttachedFiles().forEach(attachedFile -> allMessageActions.set(0, allMessageActions.get(0)
|
||||
.addFile(attachedFile.getFile(), attachedFile.getFileName(), attachedFile.getOptions().toArray(new AttachmentOption[0]))));
|
||||
|
||||
AttachedFile firstAttachment = messageToSend.getAttachedFiles().get(0);
|
||||
String fileNameToUse = firstAttachment.getFileName() != null ? firstAttachment.getFileName() : firstAttachment.getFile().getName();
|
||||
allMessageActions.add(textChannel.sendFile(firstAttachment.getFile(), fileNameToUse, firstAttachment.getOptions().toArray(new AttachmentOption[0])));
|
||||
if(messageToSend.getAttachedFiles().size() > 1) {
|
||||
messageToSend.getAttachedFiles().stream().skip(1).forEach(attachedFile -> {
|
||||
String innerFileNameToUse = attachedFile.getFileName() != null ? attachedFile.getFileName() : attachedFile.getFile().getName();
|
||||
allMessageActions.set(0, allMessageActions.get(0).addFile(attachedFile.getFile(), innerFileNameToUse, attachedFile.getOptions().toArray(new AttachmentOption[0])));
|
||||
});
|
||||
}
|
||||
allMessageActions.add(textChannel.sendFiles(attachedFiles));
|
||||
}
|
||||
}
|
||||
Set<Message.MentionType> allowedMentions = allowedMentionService.getAllowedMentionsFor(textChannel, messageToSend);
|
||||
allMessageActions.forEach(messageAction -> {
|
||||
if(messageToSend.getReferencedMessageId() != null) {
|
||||
messageAction = messageAction.referenceById(messageToSend.getReferencedMessageId());
|
||||
messageAction = messageAction.setMessageReference(messageToSend.getReferencedMessageId());
|
||||
if(messageToSend.getMessageConfig() != null && !messageToSend.getMessageConfig().isMentionsReferencedMessage()) {
|
||||
messageAction = messageAction.mentionRepliedUser(false);
|
||||
}
|
||||
}
|
||||
futures.add(messageAction.allowedMentions(allowedMentions).submit());
|
||||
futures.add(messageAction.setAllowedMentions(allowedMentions).submit());
|
||||
});
|
||||
return futures;
|
||||
}
|
||||
@@ -318,7 +316,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Message> editMessageInAChannelFuture(MessageToSend messageToSend, MessageChannel channel, Long messageId) {
|
||||
MessageAction messageAction;
|
||||
MessageEditAction messageAction;
|
||||
if(!messageToSend.getMessages().isEmpty() && !StringUtils.isBlank(messageToSend.getMessages().get(0))) {
|
||||
log.debug("Editing message {} with new text content.", messageId);
|
||||
messageAction = channel.editMessageById(messageId, messageToSend.getMessages().get(0));
|
||||
@@ -334,10 +332,7 @@ public class ChannelServiceBean implements ChannelService {
|
||||
throw new IllegalArgumentException("Message to send did not contain anything to send.");
|
||||
}
|
||||
}
|
||||
if(messageToSend.getReferencedMessageId() != null) {
|
||||
messageAction = messageAction.referenceById(messageToSend.getReferencedMessageId());
|
||||
}
|
||||
messageAction = messageAction.setActionRows(messageToSend.getActionRows());
|
||||
messageAction = messageAction.setComponents(messageToSend.getActionRows());
|
||||
metricService.incrementCounter(MESSAGE_EDIT_METRIC);
|
||||
return messageAction.submit();
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import dev.sheldan.abstracto.core.service.management.DefaultEmoteManagementServi
|
||||
import dev.sheldan.abstracto.core.service.management.EmoteManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageReaction;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -41,9 +41,9 @@ public class EmoteServiceBean implements EmoteService {
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Override
|
||||
public boolean isEmoteUsableByBot(Emote emote) {
|
||||
public boolean isEmoteUsableByBot(CustomEmoji emote) {
|
||||
for (Guild guild : botService.getInstance().getGuilds()) {
|
||||
Emote emoteById = guild.getEmoteById(emote.getId());
|
||||
CustomEmoji emoteById = guild.getEmojiById(emote.getId());
|
||||
if(emoteById != null) {
|
||||
return true;
|
||||
}
|
||||
@@ -52,18 +52,19 @@ public class EmoteServiceBean implements EmoteService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEmote buildAEmoteFromReaction(MessageReaction.ReactionEmote reaction) {
|
||||
if(reaction.isEmote()) {
|
||||
return AEmote.builder().emoteKey(reaction.getName()).custom(true).emoteId(reaction.getEmote().getIdLong()).animated(reaction.getEmote().isAnimated()).build();
|
||||
public AEmote buildAEmoteFromReaction(Emoji reaction) {
|
||||
if(reaction.getType().equals(Emoji.Type.CUSTOM)) {
|
||||
CustomEmoji CustomEmoji = (CustomEmoji) reaction;
|
||||
return AEmote.builder().emoteKey(reaction.getName()).custom(true).emoteId(CustomEmoji.getIdLong()).animated(CustomEmoji.isAnimated()).build();
|
||||
} else {
|
||||
return AEmote.builder().emoteKey(reaction.getEmoji()).custom(false).build();
|
||||
return AEmote.builder().emoteKey(reaction.getName()).custom(false).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEmoteAsMention(AEmote emote, Long serverId, String defaultText) {
|
||||
if(emote != null && emote.getCustom()) {
|
||||
Optional<Emote> emoteOptional = getEmote(serverId, emote);
|
||||
Optional<CustomEmoji> emoteOptional = getEmote(serverId, emote);
|
||||
if (emoteOptional.isPresent()) {
|
||||
return emoteOptional.get().getAsMention();
|
||||
} else {
|
||||
@@ -109,11 +110,12 @@ public class EmoteServiceBean implements EmoteService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReactionEmoteAEmote(MessageReaction.ReactionEmote reaction, AEmote storedEmote) {
|
||||
if(reaction.isEmote() && storedEmote.getCustom()) {
|
||||
return reaction.getEmote().getIdLong() == storedEmote.getEmoteId();
|
||||
} else if(reaction.isEmoji()){
|
||||
return reaction.getEmoji().equals(storedEmote.getEmoteKey());
|
||||
public boolean isReactionEmoteAEmote(Emoji reaction, AEmote storedEmote) {
|
||||
if(reaction.getType().equals(Emoji.Type.CUSTOM) && storedEmote.getCustom() && reaction instanceof CustomEmoji) {
|
||||
CustomEmoji emoji = (CustomEmoji) reaction;
|
||||
return emoji.getIdLong() == storedEmote.getEmoteId();
|
||||
} else if(reaction.getType().equals(Emoji.Type.UNICODE)){
|
||||
return reaction.getName().equals(storedEmote.getEmoteKey());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,24 +157,29 @@ public class EmoteServiceBean implements EmoteService {
|
||||
|
||||
@Override
|
||||
public AEmote getFakeEmote(Object object) {
|
||||
if(object instanceof Emote) {
|
||||
Emote emote = (Emote) object;
|
||||
if(object instanceof CustomEmoji) {
|
||||
CustomEmoji emote = (CustomEmoji) object;
|
||||
return getFakeEmoteFromEmote(emote);
|
||||
} else if(object instanceof String) {
|
||||
String emoteText = (String) object;
|
||||
return AEmote.builder().fake(true).custom(false).emoteKey(emoteText).build();
|
||||
return AEmote
|
||||
.builder()
|
||||
.fake(true)
|
||||
.custom(false)
|
||||
.emoteKey(emoteText)
|
||||
.build();
|
||||
}
|
||||
throw new IllegalArgumentException("Not possible to convert given object to AEmote.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEmote getFakeEmoteFromEmote(Emote emote) {
|
||||
public AEmote getFakeEmoteFromEmote(CustomEmoji emote) {
|
||||
AServer server = null;
|
||||
if(emote.getGuild() != null) {
|
||||
if(emote instanceof RichCustomEmoji) {
|
||||
RichCustomEmoji richCustomEmoji = (RichCustomEmoji) emote;
|
||||
server = AServer
|
||||
.builder()
|
||||
.id(emote.getGuild()
|
||||
.getIdLong())
|
||||
.id(richCustomEmoji.getGuild().getIdLong())
|
||||
.fake(true)
|
||||
.build();
|
||||
}
|
||||
@@ -189,50 +196,52 @@ public class EmoteServiceBean implements EmoteService {
|
||||
|
||||
@Override
|
||||
public AEmote getFakeEmoteFromEmoji(Emoji emoji) {
|
||||
return AEmote
|
||||
.builder()
|
||||
.fake(true)
|
||||
.emoteKey(emoji.getName())
|
||||
.custom(emoji.isCustom())
|
||||
.animated(emoji.isAnimated())
|
||||
.emoteId(emoji.getIdLong())
|
||||
.build();
|
||||
if(emoji instanceof CustomEmoji) {
|
||||
return getFakeEmoteFromEmote((CustomEmoji) emoji);
|
||||
} else {
|
||||
return AEmote
|
||||
.builder()
|
||||
.fake(true)
|
||||
.emoteKey(emoji.getName())
|
||||
.custom(false)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emoteIsFromGuild(Emote emote, Guild guild) {
|
||||
return guild.getEmoteById(emote.getId()) != null;
|
||||
public boolean emoteIsFromGuild(CustomEmoji emote, Guild guild) {
|
||||
return guild.getEmojiById(emote.getId()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Emote> getEmoteFromCachedEmote(CachedEmote cachedEmote) {
|
||||
public CompletableFuture<CustomEmoji> getEmoteFromCachedEmote(CachedEmote cachedEmote) {
|
||||
if(!cachedEmote.getCustom()) {
|
||||
throw new IllegalArgumentException("Given Emote was not a custom emote.");
|
||||
}
|
||||
Guild guild = guildService.getGuildById(cachedEmote.getServerId());
|
||||
return guild.retrieveEmoteById(cachedEmote.getEmoteId()).submit().thenApply(listedEmote -> listedEmote);
|
||||
return guild.retrieveEmojiById(cachedEmote.getEmoteId()).submit().thenApply(listedEmote -> listedEmote);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Emote> getEmote(Long serverId, AEmote emote) {
|
||||
public Optional<CustomEmoji> getEmote(Long serverId, AEmote emote) {
|
||||
if(Boolean.FALSE.equals(emote.getCustom())) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Optional<Guild> guildById = guildService.getGuildByIdOptional(serverId);
|
||||
if(guildById.isPresent()) {
|
||||
Guild guild = guildById.get();
|
||||
Emote emoteById = guild.getEmoteById(emote.getEmoteId());
|
||||
CustomEmoji emoteById = guild.getEmojiById(emote.getEmoteId());
|
||||
return Optional.ofNullable(emoteById);
|
||||
}
|
||||
throw new GuildNotFoundException(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Emote> getEmote(AEmote emote) {
|
||||
public Optional<Emoji> getEmote(AEmote emote) {
|
||||
if(Boolean.FALSE.equals(emote.getCustom())) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.ofNullable(botService.getInstance().getEmoteById(emote.getEmoteId()));
|
||||
return Optional.ofNullable(botService.getInstance().getEmojiById(emote.getEmoteId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import dev.sheldan.abstracto.core.models.template.commands.SetupCompletedNotific
|
||||
import dev.sheldan.abstracto.core.models.template.commands.SetupInitialMessageModel;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -11,8 +11,8 @@ import dev.sheldan.abstracto.core.service.management.ConfigManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.EmoteManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.PostTargetManagement;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FeatureValidationServiceBean implements FeatureValidatorService {
|
||||
if(emoteOptional.isPresent()) {
|
||||
AEmote emote = emoteOptional.get();
|
||||
if(emote.getCustom()) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emote.getEmoteId());
|
||||
RichCustomEmoji emoteById = botService.getInstance().getEmojiById(emote.getEmoteId());
|
||||
if(emoteById == null) {
|
||||
rejectEmote(emoteKey, featureValidationResult);
|
||||
} else {
|
||||
|
||||
@@ -8,6 +8,8 @@ import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import dev.sheldan.abstracto.core.exception.GuildNotFoundException;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
|
||||
@@ -12,9 +12,12 @@ 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.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageEditAction;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -224,13 +227,13 @@ public class MessageServiceBean implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageAction editMessage(Message message, MessageEmbed messageEmbed) {
|
||||
public MessageEditAction editMessage(Message message, MessageEmbed messageEmbed) {
|
||||
metricService.incrementCounter(MESSAGE_EDIT_METRIC);
|
||||
return message.editMessageEmbeds(messageEmbed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageAction editMessage(Message message, String text, MessageEmbed messageEmbed) {
|
||||
public MessageEditAction editMessage(Message message, String text, MessageEmbed messageEmbed) {
|
||||
metricService.incrementCounter(MESSAGE_EDIT_METRIC);
|
||||
return message.editMessage(text).setEmbeds(messageEmbed);
|
||||
}
|
||||
@@ -254,7 +257,8 @@ public class MessageServiceBean implements MessageService {
|
||||
@Override
|
||||
public CompletableFuture<Message> editMessageWithActionRowsMessage(Message message, List<ActionRow> rows) {
|
||||
metricService.incrementCounter(MESSAGE_EDIT_METRIC);
|
||||
return message.editMessage(message).setActionRows(rows).submit();
|
||||
MessageEditData messageEditData = MessageEditData.fromMessage(message);
|
||||
return message.editMessage(messageEditData).setComponents(rows).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ import dev.sheldan.abstracto.core.service.management.PostTargetManagement;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -15,6 +15,9 @@ import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
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.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -84,12 +87,12 @@ public class ReactionServiceBean implements ReactionService {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionFromMessage(MessageReaction reaction, CachedMessage cachedMessage, User user) {
|
||||
return messageService.loadMessageFromCachedMessage(cachedMessage).thenCompose(message -> removeReactionFromMessageWithFuture(reaction.getReactionEmote(), message, user));
|
||||
return messageService.loadMessageFromCachedMessage(cachedMessage).thenCompose(message -> removeReactionFromMessageWithFuture(reaction.getEmoji(), message, user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionFromMessage(MessageReaction reaction, CachedMessage cachedMessage) {
|
||||
return messageService.loadMessageFromCachedMessage(cachedMessage).thenCompose(message -> removeReactionFromMessageWithFuture(reaction.getReactionEmote(), message));
|
||||
return messageService.loadMessageFromCachedMessage(cachedMessage).thenCompose(message -> removeReactionFromMessageWithFuture(reaction.getEmoji(), message));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +121,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
@Override
|
||||
public CompletableFuture<Void> addDefaultReactionToMessageAsync(String unicode, Message message) {
|
||||
metricService.incrementCounter(REACTION_ADDED_METRIC);
|
||||
return message.addReaction(unicode).submit();
|
||||
return message.addReaction(Emoji.fromUnicode(unicode)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,7 +154,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
@Override
|
||||
public CompletableFuture<Void> addReactionToMessageAsync(AEmote emote, Guild guild, Message message) {
|
||||
if(Boolean.TRUE.equals(emote.getCustom())) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emote.getEmoteId());
|
||||
CustomEmoji emoteById = botService.getInstance().getEmojiById(emote.getEmoteId());
|
||||
if(emoteById != null) {
|
||||
log.debug("Adding custom emote {} as reaction to message {}.", emoteById.getId(), message.getId());
|
||||
return addReactionToMessageAsync(emoteById, message);
|
||||
@@ -166,14 +169,14 @@ public class ReactionServiceBean implements ReactionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> addReactionToMessageAsync(Emote emote, Message message) {
|
||||
public CompletableFuture<Void> addReactionToMessageAsync(Emoji emote, Message message) {
|
||||
metricService.incrementCounter(REACTION_ADDED_METRIC);
|
||||
return message.addReaction(emote).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> addReactionToMessageAsync(Long emoteId, Long serverId, Message message) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emoteId);
|
||||
CustomEmoji emoteById = botService.getInstance().getEmojiById(emoteId);
|
||||
if(emoteById == null) {
|
||||
throw new EmoteNotInServerException(emoteId);
|
||||
}
|
||||
@@ -189,7 +192,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionFromMessageWithFuture(AEmote emote, Message message) {
|
||||
if(Boolean.TRUE.equals(emote.getCustom())) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emote.getEmoteId());
|
||||
CustomEmoji emoteById = botService.getInstance().getEmojiById(emote.getEmoteId());
|
||||
if(emoteById == null) {
|
||||
throw new EmoteNotInServerException(emote.getEmoteId());
|
||||
}
|
||||
@@ -202,43 +205,35 @@ public class ReactionServiceBean implements ReactionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionFromMessageWithFuture(MessageReaction.ReactionEmote emote, Message message) {
|
||||
if(emote.isEmote()) {
|
||||
return removeReaction(message, emote.getEmote());
|
||||
} else {
|
||||
return removeReaction(message, emote.getEmoji());
|
||||
}
|
||||
public CompletableFuture<Void> removeReactionFromMessageWithFuture(Emoji emote, Message message) {
|
||||
return removeReaction(message, emote);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionFromMessageWithFuture(MessageReaction.ReactionEmote emote, Message message, User user) {
|
||||
if(emote.isEmote()) {
|
||||
return removeReaction(message, emote.getEmote(), user);
|
||||
} else {
|
||||
return removeReaction(message, emote.getEmoji(), user);
|
||||
}
|
||||
public CompletableFuture<Void> removeReactionFromMessageWithFuture(Emoji emoji, Message message, User user) {
|
||||
return removeReaction(message, emoji, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(Message message, String key) {
|
||||
public CompletableFuture<Void> removeReaction(Message message, String unicode) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
return message.removeReaction(key).submit();
|
||||
return message.removeReaction(Emoji.fromUnicode(unicode)).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(Message message, String key, User user) {
|
||||
public CompletableFuture<Void> removeReaction(Message message, String unicode, User user) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
return message.removeReaction(key, user).submit();
|
||||
return message.removeReaction(Emoji.fromUnicode(unicode), user).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(Message message, Emote emoteById) {
|
||||
public CompletableFuture<Void> removeReaction(Message message, Emoji emoteById) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
return message.removeReaction(emoteById).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(Message message, Emote emoteById, User user) {
|
||||
public CompletableFuture<Void> removeReaction(Message message, Emoji emoteById, User user) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
return message.removeReaction(emoteById, user).submit();
|
||||
}
|
||||
@@ -247,7 +242,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
public CompletableFuture<Void> removeReaction(Message message, CachedEmote cachedEmote, User user) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
String customEmoteAsUnicode = cachedEmote.getEmoteName() + ":" + cachedEmote.getEmoteId();
|
||||
return ((TextChannel) message.getChannel()).removeReactionById(message.getId(), customEmoteAsUnicode, user).submit();
|
||||
return ((TextChannel) message.getChannel()).removeReactionById(message.getId(), Emoji.fromUnicode(customEmoteAsUnicode), user).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +257,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
@Override
|
||||
public CompletableFuture<Void> clearReactionFromMessageWithFuture(AEmote emote, Message message) {
|
||||
if(Boolean.TRUE.equals(emote.getCustom())) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emote.getEmoteId());
|
||||
CustomEmoji emoteById = botService.getInstance().getEmojiById(emote.getEmoteId());
|
||||
if(emoteById == null) {
|
||||
throw new EmoteNotInServerException(emote.getEmoteId());
|
||||
}
|
||||
@@ -274,12 +269,12 @@ public class ReactionServiceBean implements ReactionService {
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> clearReaction(Message message, String key) {
|
||||
public CompletableFuture<Void> clearReaction(Message message, String unicode) {
|
||||
metricService.incrementCounter(REACTION_CLEARED_METRIC);
|
||||
return message.clearReactions(key).submit();
|
||||
return message.clearReactions(Emoji.fromUnicode(unicode)).submit();
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> clearReaction(Message message, Emote emoteById) {
|
||||
public CompletableFuture<Void> clearReaction(Message message, Emoji emoteById) {
|
||||
metricService.incrementCounter(REACTION_CLEARED_METRIC);
|
||||
return message.clearReactions(emoteById).submit();
|
||||
}
|
||||
@@ -346,7 +341,7 @@ public class ReactionServiceBean implements ReactionService {
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReactionOfUserFromMessageAsync(AEmote emote, Message message, Member member) {
|
||||
if(Boolean.TRUE.equals(emote.getCustom())) {
|
||||
Emote emoteById = botService.getInstance().getEmoteById(emote.getEmoteId());
|
||||
CustomEmoji emoteById = botService.getInstance().getEmojiById(emote.getEmoteId());
|
||||
if(emoteById == null) {
|
||||
throw new EmoteNotInServerException(emote.getEmoteId());
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import dev.sheldan.abstracto.core.utils.SnowflakeUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -10,9 +10,7 @@ import dev.sheldan.abstracto.core.models.listener.AChannelDeletedListenerModel;
|
||||
import dev.sheldan.abstracto.core.repository.ChannelRepository;
|
||||
import dev.sheldan.abstracto.core.service.LockService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Channel;
|
||||
import net.dv8tion.jda.api.entities.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -6,7 +6,7 @@ import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.repository.EmoteRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class EmoteManagementServiceBean implements EmoteManagementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEmote setEmoteToCustomEmote(String name, Emote emote, Long serverId) {
|
||||
public AEmote setEmoteToCustomEmote(String name, CustomEmoji emote, Long serverId) {
|
||||
return setEmoteToCustomEmote(name, emote.getName(), emote.getIdLong(), emote.isAnimated(), serverId);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -18,12 +18,11 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Emoji;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
import net.dv8tion.jda.api.utils.AttachmentOption;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -124,7 +123,7 @@ public class TemplateServiceBean implements TemplateService {
|
||||
createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
|
||||
}
|
||||
if (buttonConfig.getEmoteMarkdown() != null) {
|
||||
createdButton = createdButton.withEmoji(Emoji.fromMarkdown(buttonConfig.getEmoteMarkdown()));
|
||||
createdButton = createdButton.withEmoji(Emoji.fromFormatted(buttonConfig.getEmoteMarkdown()));
|
||||
}
|
||||
if(currentRow == null) {
|
||||
currentRow = ActionRow.of(createdButton);
|
||||
@@ -173,14 +172,10 @@ public class TemplateServiceBean implements TemplateService {
|
||||
List<AttachedFile> files = new ArrayList<>();
|
||||
if(messageConfiguration.getFiles() != null && !messageConfiguration.getFiles().isEmpty()) {
|
||||
messageConfiguration.getFiles().forEach(fileToAttach -> {
|
||||
List<AttachmentOption> options = new ArrayList<>();
|
||||
if(fileToAttach.getSpoiler() != null && fileToAttach.getSpoiler()) {
|
||||
options.add(AttachmentOption.SPOILER);
|
||||
}
|
||||
AttachedFile attachedFile = AttachedFile
|
||||
.builder()
|
||||
.fileName(fileToAttach.getFileName() != null ? fileToAttach.getFileName() : RandomStringUtils.randomAlphabetic(5))
|
||||
.options(options)
|
||||
.spoiler(fileToAttach.getSpoiler())
|
||||
.build();
|
||||
files.add(attachedFile);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user