mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-07-05 20:30:01 +00:00
[AB-xxx] enabling localization by adding the localization as a system config key
fixing methods which did not provide the server id to template rendering refactoring channel service method to remove a duplicate fixing template loading method to not throw an exception when template was not found
This commit is contained in:
@@ -42,7 +42,7 @@ public class ShowAssignableRolePlaceConfig extends AbstractConditionableCommand
|
|||||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||||
String name = (String) parameters.get(0);
|
String name = (String) parameters.get(0);
|
||||||
AssignableRolePlaceConfig config = service.getAssignableRolePlaceConfig(commandContext.getGuild(), name);
|
AssignableRolePlaceConfig config = service.getAssignableRolePlaceConfig(commandContext.getGuild(), name);
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ASSIGNABLE_ROLES_CONFIG_POST_TEMPLATE_KEY, config, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(ASSIGNABLE_ROLES_CONFIG_POST_TEMPLATE_KEY, config, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class ShowAssignableRolePlaces extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
AssignablePlaceOverview model = service.getAssignableRolePlaceOverview(commandContext.getGuild());
|
AssignablePlaceOverview model = service.getAssignableRolePlaceOverview(commandContext.getGuild());
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ASSIGNABLE_ROLE_PLACES_OVERVIEW_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(ASSIGNABLE_ROLE_PLACES_OVERVIEW_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class Choose extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.chosenValue(choice)
|
.chosenValue(choice)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(CHOOSE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Mock extends AbstractConditionableCommand {
|
|||||||
.originalText(messageText)
|
.originalText(messageText)
|
||||||
.mockingText(mockingText)
|
.mockingText(mockingText)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(MOCK_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(MOCK_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class PressFCommand extends AbstractConditionableCommand {
|
|||||||
Long defaultDurationSeconds = configService.getLongValueOrConfigDefault(PRESS_F_DEFAULT_DURATION_SECONDS, commandContext.getGuild().getIdLong());
|
Long defaultDurationSeconds = configService.getLongValueOrConfigDefault(PRESS_F_DEFAULT_DURATION_SECONDS, commandContext.getGuild().getIdLong());
|
||||||
Duration duration = Duration.ofSeconds(defaultDurationSeconds);
|
Duration duration = Duration.ofSeconds(defaultDurationSeconds);
|
||||||
PressFPromptModel pressFModel = entertainmentService.getPressFModel(text);
|
PressFPromptModel pressFModel = entertainmentService.getPressFModel(text);
|
||||||
List<CompletableFuture<Message>> messages = channelService.sendEmbedTemplateInMessageChannelList(RESPONSE_TEMPLATE, pressFModel, commandContext.getChannel());
|
List<CompletableFuture<Message>> messages = channelService.sendEmbedTemplateInMessageChannel(RESPONSE_TEMPLATE, pressFModel, commandContext.getChannel());
|
||||||
return FutureUtils.toSingleFutureGeneric(messages)
|
return FutureUtils.toSingleFutureGeneric(messages)
|
||||||
.thenAccept(unused -> entertainmentService.persistPressF(text, duration, commandContext.getAuthor(),
|
.thenAccept(unused -> entertainmentService.persistPressF(text, duration, commandContext.getAuthor(),
|
||||||
pressFModel.getPressFComponentId(), commandContext.getChannel(), messages.get(0).join().getIdLong()))
|
pressFModel.getPressFComponentId(), commandContext.getChannel(), messages.get(0).join().getIdLong()))
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class Roll extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.rolled(rolled)
|
.rolled(rolled)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ROLL_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(ROLL_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Roulette extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.result(rouletteResult)
|
.result(rouletteResult)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ROULETTE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(ROULETTE_RESPONSE_TEMPLATE_KEY, responseModel, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class TransferCredits extends AbstractConditionableCommand {
|
|||||||
.targetMember(MemberDisplay.fromMember(targetMember))
|
.targetMember(MemberDisplay.fromMember(targetMember))
|
||||||
.credits(amount)
|
.credits(amount)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(TRANSFER_CREDITS_RESPONSE, responseModel, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(TRANSFER_CREDITS_RESPONSE, responseModel, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class Mines extends AbstractConditionableCommand {
|
|||||||
board.setUserId(event.getMember().getIdLong());
|
board.setUserId(event.getMember().getIdLong());
|
||||||
board.setServerId(serverId);
|
board.setServerId(serverId);
|
||||||
board.setCredits(credit);
|
board.setCredits(credit);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board, serverId);
|
||||||
return interactionService.replyMessageToSend(messageToSend, event)
|
return interactionService.replyMessageToSend(messageToSend, event)
|
||||||
.thenCompose(interactionHook -> interactionHook.retrieveOriginal().submit())
|
.thenCompose(interactionHook -> interactionHook.retrieveOriginal().submit())
|
||||||
.thenApply(message -> {
|
.thenApply(message -> {
|
||||||
@@ -151,7 +151,7 @@ public class Mines extends AbstractConditionableCommand {
|
|||||||
board.setUserId(commandContext.getAuthor().getIdLong());
|
board.setUserId(commandContext.getAuthor().getIdLong());
|
||||||
board.setServerId(serverId);
|
board.setServerId(serverId);
|
||||||
board.setCredits(credit);
|
board.setCredits(credit);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(MINE_BOARD_TEMPLATE_KEY, board, serverId);
|
||||||
List<CompletableFuture<Message>> futures = channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel());
|
List<CompletableFuture<Message>> futures = channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel());
|
||||||
return FutureUtils.toSingleFutureGeneric(futures)
|
return FutureUtils.toSingleFutureGeneric(futures)
|
||||||
.thenAccept(unused -> gameService.persistMineBoardMessage(board, futures.get(0).join()))
|
.thenAccept(unused -> gameService.persistMineBoardMessage(board, futures.get(0).join()))
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class MinesButtonClickedListener implements ButtonClickedListener {
|
|||||||
}
|
}
|
||||||
gameService.uncoverBoard(mineBoard);
|
gameService.uncoverBoard(mineBoard);
|
||||||
}
|
}
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(Mines.MINE_BOARD_TEMPLATE_KEY, mineBoard);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(Mines.MINE_BOARD_TEMPLATE_KEY, mineBoard, model.getServerId());
|
||||||
interactionService.editOriginal(messageToSend, model.getEvent().getHook()).thenAccept(message -> {
|
interactionService.editOriginal(messageToSend, model.getEvent().getHook()).thenAccept(message -> {
|
||||||
gameService.updateMineBoard(mineBoard);
|
gameService.updateMineBoard(mineBoard);
|
||||||
log.info("Updated original mineboard for board {}.", mineBoard.getBoardId());
|
log.info("Updated original mineboard for board {}.", mineBoard.getBoardId());
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
|||||||
.text(pressF.getText())
|
.text(pressF.getText())
|
||||||
.messageId(pressF.getMessageId())
|
.messageId(pressF.getMessageId())
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(PRESS_F_RESULT_TEMPLATE_KEY, model);
|
|
||||||
Long serverId = pressF.getServer().getId();
|
Long serverId = pressF.getServer().getId();
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(PRESS_F_RESULT_TEMPLATE_KEY, model, serverId);
|
||||||
Long channelId = pressF.getPressFChannel().getId();
|
Long channelId = pressF.getPressFChannel().getId();
|
||||||
Long messageId = pressF.getMessageId();
|
Long messageId = pressF.getMessageId();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageEmbedToSendToAChannel(messageToSend, pressF.getPressFChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageEmbedToSendToAChannel(messageToSend, pressF.getPressFChannel()))
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
|||||||
.newRole(oldRoleId != null ? RoleDisplay.fromRole(oldRoleId) : null)
|
.newRole(oldRoleId != null ? RoleDisplay.fromRole(oldRoleId) : null)
|
||||||
.newRole(newRoleId != null ? RoleDisplay.fromRole(newRoleId) : null)
|
.newRole(newRoleId != null ? RoleDisplay.fromRole(newRoleId) : null)
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate("experience_level_up_notification", model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate("experience_level_up_notification", model, serverId);
|
||||||
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, message.getChannel())).thenAccept(unused -> {
|
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, message.getChannel())).thenAccept(unused -> {
|
||||||
log.info("Sent level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
log.info("Sent level up notification to user {} in server {} in channel {}.", member.getIdLong(), serverId, message.getChannel().getIdLong());
|
||||||
}).exceptionally(throwable -> {
|
}).exceptionally(throwable -> {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class GiveawayServiceBean implements GiveawayService {
|
|||||||
giveawayMessageModel.setJoinedUserCount(giveaway.getParticipants().size() + 1L);
|
giveawayMessageModel.setJoinedUserCount(giveaway.getParticipants().size() + 1L);
|
||||||
Long giveawayId = giveaway.getGiveawayId().getId();
|
Long giveawayId = giveaway.getGiveawayId().getId();
|
||||||
log.info("Adding giveaway participating of user {} to giveaway {} in server {}.", member.getIdLong(), giveawayId, member.getGuild().getIdLong());
|
log.info("Adding giveaway participating of user {} to giveaway {} in server {}.", member.getIdLong(), giveawayId, member.getGuild().getIdLong());
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel, member.getGuild().getIdLong());
|
||||||
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), messageChannel, giveaway.getMessageId())
|
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), messageChannel, giveaway.getMessageId())
|
||||||
.thenAccept(message -> {
|
.thenAccept(message -> {
|
||||||
self.persistAddedParticipant(member, giveawayId);
|
self.persistAddedParticipant(member, giveawayId);
|
||||||
@@ -183,13 +183,13 @@ public class GiveawayServiceBean implements GiveawayService {
|
|||||||
.winners(winnerDisplays)
|
.winners(winnerDisplays)
|
||||||
.build();
|
.build();
|
||||||
log.info("Sending result message for giveaway {} in server {}.", giveawayId, serverId);
|
log.info("Sending result message for giveaway {} in server {}.", giveawayId, serverId);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_RESULT_MESSAGE_TEMPLATE_KEY, resultModel);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(GIVEAWAY_RESULT_MESSAGE_TEMPLATE_KEY, resultModel, serverId);
|
||||||
List<CompletableFuture<Message>> resultFutures = channelService.sendMessageEmbedToSendToAChannel(messageToSend, giveaway.getGiveawayChannel());
|
List<CompletableFuture<Message>> resultFutures = channelService.sendMessageEmbedToSendToAChannel(messageToSend, giveaway.getGiveawayChannel());
|
||||||
|
|
||||||
GiveawayMessageModel giveawayMessageModel = GiveawayMessageModel.fromGiveaway(giveaway);
|
GiveawayMessageModel giveawayMessageModel = GiveawayMessageModel.fromGiveaway(giveaway);
|
||||||
giveawayMessageModel.setWinners(winnerDisplays);
|
giveawayMessageModel.setWinners(winnerDisplays);
|
||||||
giveawayMessageModel.setEnded(true);
|
giveawayMessageModel.setEnded(true);
|
||||||
MessageToSend giveawayMessageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel);
|
MessageToSend giveawayMessageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel, serverId);
|
||||||
log.info("Updating original giveaway message for giveaway {} in server {}.", giveawayId, serverId);
|
log.info("Updating original giveaway message for giveaway {} in server {}.", giveawayId, serverId);
|
||||||
GuildMessageChannel messageChannel = channelService.getMessageChannelFromServer(giveaway.getServer().getId(), giveaway.getGiveawayChannel().getId());
|
GuildMessageChannel messageChannel = channelService.getMessageChannelFromServer(giveaway.getServer().getId(), giveaway.getGiveawayChannel().getId());
|
||||||
CompletableFuture<Message> giveawayUpdateFuture = channelService.editMessageInAChannelFuture(giveawayMessageToSend, messageChannel, giveaway.getMessageId());
|
CompletableFuture<Message> giveawayUpdateFuture = channelService.editMessageInAChannelFuture(giveawayMessageToSend, messageChannel, giveaway.getMessageId());
|
||||||
@@ -208,7 +208,7 @@ public class GiveawayServiceBean implements GiveawayService {
|
|||||||
GiveawayMessageModel giveawayMessageModel = GiveawayMessageModel.fromGiveaway(giveaway);
|
GiveawayMessageModel giveawayMessageModel = GiveawayMessageModel.fromGiveaway(giveaway);
|
||||||
giveawayMessageModel.setCancelled(true);
|
giveawayMessageModel.setCancelled(true);
|
||||||
schedulerService.stopTrigger(giveaway.getReminderTriggerKey());
|
schedulerService.stopTrigger(giveaway.getReminderTriggerKey());
|
||||||
MessageToSend giveawayMessageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel);
|
MessageToSend giveawayMessageToSend = templateService.renderEmbedTemplate(GIVEAWAY_MESSAGE_TEMPLATE_KEY, giveawayMessageModel, serverId);
|
||||||
|
|
||||||
GuildMessageChannel messageChannel = channelService.getMessageChannelFromServer(giveaway.getServer().getId(), giveaway.getGiveawayChannel().getId());
|
GuildMessageChannel messageChannel = channelService.getMessageChannelFromServer(giveaway.getServer().getId(), giveaway.getGiveawayChannel().getId());
|
||||||
log.debug("Updating original giveaway message to consider cancellation for giveaway {} in server {}.", giveawayId, serverId);
|
log.debug("Updating original giveaway message to consider cancellation for giveaway {} in server {}.", giveawayId, serverId);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class AmongusText extends AbstractConditionableCommand {
|
|||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
String text = (String) commandContext.getParameters().getParameters().get(0);
|
String text = (String) commandContext.getParameters().getParameters().get(0);
|
||||||
File amongusTextImage = imageGenerationService.getAmongusTextImage(text);
|
File amongusTextImage = imageGenerationService.getAmongusTextImage(text);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(AMONGUS_TEXT_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(AMONGUS_TEXT_EMBED_TEMPLATE_KEY, new Object(), commandContext.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
@@ -76,7 +76,7 @@ public class AmongusText extends AbstractConditionableCommand {
|
|||||||
event.deferReply().queue();
|
event.deferReply().queue();
|
||||||
String text = slashCommandParameterService.getCommandOption(TEXT_PARAMETER_KEY, event, String.class);
|
String text = slashCommandParameterService.getCommandOption(TEXT_PARAMETER_KEY, event, String.class);
|
||||||
File amongusTextImage = imageGenerationService.getAmongusTextImage(text);
|
File amongusTextImage = imageGenerationService.getAmongusTextImage(text);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(AMONGUS_TEXT_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(AMONGUS_TEXT_EMBED_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class Bonk extends AbstractConditionableCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
File bonkGifFile = imageGenerationService.getBonkGif(member.getEffectiveAvatar().getUrl(imageSize));
|
File bonkGifFile = imageGenerationService.getBonkGif(member.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(BONK_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(BONK_EMBED_TEMPLATE_KEY, new Object(), commandContext.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
@@ -99,7 +99,7 @@ public class Bonk extends AbstractConditionableCommand {
|
|||||||
targetMember = event.getMember();
|
targetMember = event.getMember();
|
||||||
}
|
}
|
||||||
File bonkGifFile = imageGenerationService.getBonkGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
File bonkGifFile = imageGenerationService.getBonkGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(BONK_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(BONK_EMBED_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class Pat extends AbstractConditionableCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
File patGifFile = imageGenerationService.getPatGif(member.getEffectiveAvatar().getUrl(imageSize));
|
File patGifFile = imageGenerationService.getPatGif(member.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(PAT_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(PAT_EMBED_TEMPLATE_KEY, new Object(), commandContext.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
@@ -99,7 +99,7 @@ public class Pat extends AbstractConditionableCommand {
|
|||||||
targetMember = event.getMember();
|
targetMember = event.getMember();
|
||||||
}
|
}
|
||||||
File patGifFile = imageGenerationService.getPatGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
File patGifFile = imageGenerationService.getPatGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(PAT_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(PAT_EMBED_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class Triggered extends AbstractConditionableCommand {
|
|||||||
member = (Member) parameters.get(0);
|
member = (Member) parameters.get(0);
|
||||||
}
|
}
|
||||||
File triggeredGifFile = imageGenerationService.getTriggeredGif(member.getEffectiveAvatar().getUrl(imageSize));
|
File triggeredGifFile = imageGenerationService.getTriggeredGif(member.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(TRIGGERED_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(TRIGGERED_EMBED_TEMPLATE_KEY, new Object(), commandContext.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
@@ -91,7 +91,7 @@ public class Triggered extends AbstractConditionableCommand {
|
|||||||
targetMember = event.getMember();
|
targetMember = event.getMember();
|
||||||
}
|
}
|
||||||
File triggeredGifFile = imageGenerationService.getTriggeredGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
File triggeredGifFile = imageGenerationService.getTriggeredGif(targetMember.getEffectiveAvatar().getUrl(imageSize));
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(TRIGGERED_EMBED_TEMPLATE_KEY, new Object());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(TRIGGERED_EMBED_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
AttachedFile file = AttachedFile
|
AttachedFile file = AttachedFile
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class MyWarnings extends AbstractConditionableCommand {
|
|||||||
.totalWarnCount(totalWarnCount)
|
.totalWarnCount(totalWarnCount)
|
||||||
.currentWarnCount(currentWarnCount)
|
.currentWarnCount(currentWarnCount)
|
||||||
.build();
|
.build();
|
||||||
channelService.sendEmbedTemplateInTextChannelList(MY_WARNINGS_RESPONSE_EMBED_TEMPLATE, model, commandContext.getChannel());
|
channelService.sendEmbedTemplateInMessageChannel(MY_WARNINGS_RESPONSE_EMBED_TEMPLATE, model, commandContext.getChannel());
|
||||||
return CommandResult.fromIgnored();
|
return CommandResult.fromIgnored();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class UserNotes extends AbstractConditionableCommand {
|
|||||||
CompletableFuture<List<NoteEntryModel>> listCompletableFuture = userNotesConverter.fromNotes(userNotes);
|
CompletableFuture<List<NoteEntryModel>> listCompletableFuture = userNotesConverter.fromNotes(userNotes);
|
||||||
return listCompletableFuture.thenCompose(noteEntryModels -> {
|
return listCompletableFuture.thenCompose(noteEntryModels -> {
|
||||||
model.setUserNotes(noteEntryModels);
|
model.setUserNotes(noteEntryModels);
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(USER_NOTES_RESPONSE_TEMPLATE, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(USER_NOTES_RESPONSE_TEMPLATE, model, commandContext.getChannel()))
|
||||||
.thenApply(aVoid -> CommandResult.fromIgnored());
|
.thenApply(aVoid -> CommandResult.fromIgnored());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class BanModerationActionModalListener implements ModalInteractionListene
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if(StringUtils.isBlank(tempReason)) {
|
if(StringUtils.isBlank(tempReason)) {
|
||||||
reason = templateService.renderSimpleTemplate(DEFAULT_BAN_REASON_TEMPLATE_KEY);
|
reason = templateService.renderSimpleTemplate(DEFAULT_BAN_REASON_TEMPLATE_KEY, model.getServerId());
|
||||||
} else {
|
} else {
|
||||||
reason = tempReason;
|
reason = tempReason;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class HoneyPotRoleAddedListener implements RoleAddedListener {
|
|||||||
.memberDisplay(MemberDisplay.fromMember(model.getTargetMember()))
|
.memberDisplay(MemberDisplay.fromMember(model.getTargetMember()))
|
||||||
.roleDisplay(RoleDisplay.fromRole(model.getRole()))
|
.roleDisplay(RoleDisplay.fromRole(model.getRole()))
|
||||||
.build();
|
.build();
|
||||||
String banReason = templateService.renderTemplate(HONEYPOT_BAN_REASON_TEMPLATE, reasonModel);
|
String banReason = templateService.renderTemplate(HONEYPOT_BAN_REASON_TEMPLATE, reasonModel, model.getServerId());
|
||||||
banService.banUserWithNotification(model.getTargetUser(), banReason, ServerUser.fromMember(model.getTargetMember().getGuild().getSelfMember()),
|
banService.banUserWithNotification(model.getTargetUser(), banReason, ServerUser.fromMember(model.getTargetMember().getGuild().getSelfMember()),
|
||||||
model.getTargetMember().getGuild(), Duration.ofDays(7)).thenAccept(banResult -> {
|
model.getTargetMember().getGuild(), Duration.ofDays(7)).thenAccept(banResult -> {
|
||||||
log.info("Banned user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId());
|
log.info("Banned user {} in guild {} due to role {}.", model.getTargetUser().getUserId(), model.getTargetUser().getServerId(), model.getRoleId());
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class MyWarningsTest {
|
|||||||
Long totalWarnCount = 10L;
|
Long totalWarnCount = 10L;
|
||||||
when(warnManagementService.getTotalWarnsForUser(aUserInAServer)).thenReturn(totalWarnCount);
|
when(warnManagementService.getTotalWarnsForUser(aUserInAServer)).thenReturn(totalWarnCount);
|
||||||
CommandResult result = testUnit.execute(noParameter);
|
CommandResult result = testUnit.execute(noParameter);
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(eq(MyWarnings.MY_WARNINGS_RESPONSE_EMBED_TEMPLATE), argumentCaptor.capture(), eq(noParameter.getChannel()));
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(eq(MyWarnings.MY_WARNINGS_RESPONSE_EMBED_TEMPLATE), argumentCaptor.capture(), eq(noParameter.getChannel()));
|
||||||
CommandTestUtilities.checkSuccessfulCompletion(result);
|
CommandTestUtilities.checkSuccessfulCompletion(result);
|
||||||
MyWarningsModel usedModel = argumentCaptor.getValue();
|
MyWarningsModel usedModel = argumentCaptor.getValue();
|
||||||
Assert.assertEquals(activeWarnCount, usedModel.getCurrentWarnCount());
|
Assert.assertEquals(activeWarnCount, usedModel.getCurrentWarnCount());
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class UserNotesTest {
|
|||||||
CompletableFuture<List<NoteEntryModel>> convertedNotes = CompletableFuture.completedFuture(Arrays.asList(firstConvertedNote, secondConvertedNote));
|
CompletableFuture<List<NoteEntryModel>> convertedNotes = CompletableFuture.completedFuture(Arrays.asList(firstConvertedNote, secondConvertedNote));
|
||||||
when(userNotesConverter.fromNotes(userNotes)).thenReturn(convertedNotes);
|
when(userNotesConverter.fromNotes(userNotes)).thenReturn(convertedNotes);
|
||||||
CompletableFuture<CommandResult> result = testUnit.executeAsync(parameters);
|
CompletableFuture<CommandResult> result = testUnit.executeAsync(parameters);
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(eq(UserNotes.USER_NOTES_RESPONSE_TEMPLATE), captor.capture(), eq(parameters.getChannel()));
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(eq(UserNotes.USER_NOTES_RESPONSE_TEMPLATE), captor.capture(), eq(parameters.getChannel()));
|
||||||
ListNotesModel usedModel = captor.getValue();
|
ListNotesModel usedModel = captor.getValue();
|
||||||
List<NoteEntryModel> notes = convertedNotes.join();
|
List<NoteEntryModel> notes = convertedNotes.join();
|
||||||
Assert.assertEquals(notes.size(), usedModel.getUserNotes().size());
|
Assert.assertEquals(notes.size(), usedModel.getUserNotes().size());
|
||||||
@@ -96,7 +96,7 @@ public class UserNotesTest {
|
|||||||
when(userNotesConverter.fromNotes(userNotes)).thenReturn(convertedNotes);
|
when(userNotesConverter.fromNotes(userNotes)).thenReturn(convertedNotes);
|
||||||
CompletableFuture<CommandResult> result = testUnit.executeAsync(parameters);
|
CompletableFuture<CommandResult> result = testUnit.executeAsync(parameters);
|
||||||
List<NoteEntryModel> notes = convertedNotes.join();
|
List<NoteEntryModel> notes = convertedNotes.join();
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(eq(UserNotes.USER_NOTES_RESPONSE_TEMPLATE), captor.capture(), eq(parameters.getChannel()));
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(eq(UserNotes.USER_NOTES_RESPONSE_TEMPLATE), captor.capture(), eq(parameters.getChannel()));
|
||||||
ListNotesModel usedModel = captor.getValue();
|
ListNotesModel usedModel = captor.getValue();
|
||||||
Assert.assertEquals(notes.size(), usedModel.getUserNotes().size());
|
Assert.assertEquals(notes.size(), usedModel.getUserNotes().size());
|
||||||
for (int i = 0; i < usedModel.getUserNotes().size(); i++) {
|
for (int i = 0; i < usedModel.getUserNotes().size(); i++) {
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ public class Close extends AbstractConditionableCommand {
|
|||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||||
// the default value of the note is configurable via template
|
// the default value of the note is configurable via template
|
||||||
String note = parameters.size() == 1 ? (String) parameters.get(0) : templateService.renderTemplate(MODMAIL_CLOSE_DEFAULT_NOTE_TEMPLATE_KEY, new Object());
|
String note = parameters.size() == 1 ? (String) parameters.get(0) : templateService.renderTemplate(MODMAIL_CLOSE_DEFAULT_NOTE_TEMPLATE_KEY, new Object(), commandContext.getGuild()
|
||||||
|
.getIdLong());
|
||||||
ModMailThread modMailThread = modMailThreadManagementService.getByChannelId(commandContext.getChannel().getIdLong());
|
ModMailThread modMailThread = modMailThreadManagementService.getByChannelId(commandContext.getChannel().getIdLong());
|
||||||
if(ModMailThreadState.CLOSED.equals(modMailThread.getState()) || ModMailThreadState.CLOSING.equals(modMailThread.getState())) {
|
if(ModMailThreadState.CLOSED.equals(modMailThread.getState()) || ModMailThreadState.CLOSING.equals(modMailThread.getState())) {
|
||||||
throw new ModMailThreadClosedException();
|
throw new ModMailThreadClosedException();
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public class CloseSilently extends AbstractConditionableCommand {
|
|||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||||
// default note text is configurable via template, because the note is optional
|
// default note text is configurable via template, because the note is optional
|
||||||
String note = parameters.size() == 1 ? (String) parameters.get(0) : templateService.renderTemplate("modmail_close_default_note", new Object());
|
String note = parameters.size() == 1 ? (String) parameters.get(0) : templateService.renderTemplate("modmail_close_default_note", new Object(), commandContext.getGuild()
|
||||||
|
.getIdLong());
|
||||||
ModMailThread modMailThread = modMailThreadManagementService.getByChannelId(commandContext.getChannel().getIdLong());
|
ModMailThread modMailThread = modMailThreadManagementService.getByChannelId(commandContext.getChannel().getIdLong());
|
||||||
if(ModMailThreadState.CLOSED.equals(modMailThread.getState()) || ModMailThreadState.CLOSING.equals(modMailThread.getState())) {
|
if(ModMailThreadState.CLOSED.equals(modMailThread.getState()) || ModMailThreadState.CLOSING.equals(modMailThread.getState())) {
|
||||||
throw new ModMailThreadClosedException();
|
throw new ModMailThreadClosedException();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class Contact extends AbstractConditionableCommand {
|
|||||||
.existingModMailThread(existingThread)
|
.existingModMailThread(existingThread)
|
||||||
.executingMemberDisplay(MemberNameDisplay.fromMember(targetUser))
|
.executingMemberDisplay(MemberNameDisplay.fromMember(targetUser))
|
||||||
.build();
|
.build();
|
||||||
List<CompletableFuture<Message>> futures = channelService.sendEmbedTemplateInTextChannelList(MODMAIL_THREAD_ALREADY_EXISTS_TEMPLATE, model, commandContext.getChannel());
|
List<CompletableFuture<Message>> futures = channelService.sendEmbedTemplateInMessageChannel(MODMAIL_THREAD_ALREADY_EXISTS_TEMPLATE, model, commandContext.getChannel());
|
||||||
return FutureUtils.toSingleFutureGeneric(futures).thenApply(aVoid -> CommandResult.fromIgnored());
|
return FutureUtils.toSingleFutureGeneric(futures).thenApply(aVoid -> CommandResult.fromIgnored());
|
||||||
} else {
|
} else {
|
||||||
return modMailThreadService.createModMailThreadForUser(targetUser.getUser(), targetUser.getGuild(), null, false, commandContext.getUndoActions(), false)
|
return modMailThreadService.createModMailThreadForUser(targetUser.getUser(), targetUser.getGuild(), null, false, commandContext.getUndoActions(), false)
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
.createdChannel(messageChannel)
|
.createdChannel(messageChannel)
|
||||||
.userDisplay(UserDisplay.fromUser(user))
|
.userDisplay(UserDisplay.fromUser(user))
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannelList(MODMAIL_THREAD_CREATED_TEMPLATE_KEY, model, feedBackChannel));
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(MODMAIL_THREAD_CREATED_TEMPLATE_KEY, model, feedBackChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -473,7 +473,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("No server available to open a modmail thread in.");
|
log.info("No server available to open a modmail thread in.");
|
||||||
// in case there is no server available, send an error message
|
// in case there is no server available, send an error message
|
||||||
channelService.sendEmbedTemplateInMessageChannelList("modmail_no_server_available", new Object(), initialMessage.getChannel());
|
channelService.sendEmbedTemplateInMessageChannel("modmail_no_server_available", new Object(), initialMessage.getChannel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
.latestModMailThread(latestThread)
|
.latestModMailThread(latestThread)
|
||||||
.pastModMailThreadCount((long)oldThreads.size())
|
.pastModMailThreadCount((long)oldThreads.size())
|
||||||
.build();
|
.build();
|
||||||
List<CompletableFuture<Message>> messages = channelService.sendEmbedTemplateInTextChannelList("modmail_thread_header", header, channel);
|
List<CompletableFuture<Message>> messages = channelService.sendEmbedTemplateInMessageChannel("modmail_thread_header", header, channel);
|
||||||
return CompletableFuture.allOf(messages.toArray(new CompletableFuture[0]));
|
return CompletableFuture.allOf(messages.toArray(new CompletableFuture[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
// in this case there was no text channel on the server associated with the mod mail thread
|
// in this case there was no text channel on the server associated with the mod mail thread
|
||||||
// close the existing one, so the user can start a new one
|
// close the existing one, so the user can start a new one
|
||||||
self.closeModMailThreadInDb(modmailThreadId);
|
self.closeModMailThreadInDb(modmailThreadId);
|
||||||
String textToSend = templateService.renderTemplate("modmail_failed_to_forward_message", new Object());
|
String textToSend = templateService.renderTemplate("modmail_failed_to_forward_message", new Object(), serverId);
|
||||||
return channelService.sendTextToChannel(textToSend, messageFromUser.getChannel());
|
return channelService.sendTextToChannel(textToSend, messageFromUser.getChannel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,8 +792,9 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
log.info("Notifying user about the closed modmail thread {}.", modMailThreadId);
|
log.info("Notifying user about the closed modmail thread {}.", modMailThreadId);
|
||||||
ModMailThread modMailThread = modMailThreadOpt.get();
|
ModMailThread modMailThread = modMailThreadOpt.get();
|
||||||
HashMap<String, String> closingMessage = new HashMap<>();
|
HashMap<String, String> closingMessage = new HashMap<>();
|
||||||
String defaultValue = templateService.renderSimpleTemplate("modmail_closing_user_message_description");
|
Long serverId = modMailThread.getServer().getId();
|
||||||
closingMessage.put("closingMessage", configService.getStringValue(MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY, modMailThread.getServer().getId(), defaultValue));
|
String defaultValue = templateService.renderSimpleTemplate("modmail_closing_user_message_description", serverId);
|
||||||
|
closingMessage.put("closingMessage", configService.getStringValue(MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY, serverId, defaultValue));
|
||||||
return messageService.sendEmbedToUser(modMailThreaduser, "modmail_closing_user_message", closingMessage).thenCompose(message ->
|
return messageService.sendEmbedToUser(modMailThreaduser, "modmail_closing_user_message", closingMessage).thenCompose(message ->
|
||||||
self.deleteChannelAndClose(modMailThreadId, undoActions)
|
self.deleteChannelAndClose(modMailThreadId, undoActions)
|
||||||
).exceptionally(throwable -> {
|
).exceptionally(throwable -> {
|
||||||
@@ -875,7 +876,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
.loggedMessages(0)
|
.loggedMessages(0)
|
||||||
.totalMessages(messages.getMessages().size())
|
.totalMessages(messages.getMessages().size())
|
||||||
.build();
|
.build();
|
||||||
List<CompletableFuture<Message>> updateMessageFutures = channelService.sendEmbedTemplateInTextChannelList(MODMAIL_CLOSE_PROGRESS_TEMPLATE_KEY, progressModel, channel);
|
List<CompletableFuture<Message>> updateMessageFutures = channelService.sendEmbedTemplateInMessageChannel(MODMAIL_CLOSE_PROGRESS_TEMPLATE_KEY, progressModel, channel);
|
||||||
return FutureUtils.toSingleFutureGeneric(updateMessageFutures)
|
return FutureUtils.toSingleFutureGeneric(updateMessageFutures)
|
||||||
.thenCompose(updateMessage -> self.logMessages(modMailThreadId, messages, context, updateMessageFutures.get(0).join()));
|
.thenCompose(updateMessage -> self.logMessages(modMailThreadId, messages, context, updateMessageFutures.get(0).join()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class ModMailCategorySetupBean implements ModMailCategorySetup {
|
|||||||
model.setServerId(user.getGuildId());
|
model.setServerId(user.getGuildId());
|
||||||
}
|
}
|
||||||
log.info("Executing mod mail category setup for server {}.", user.getGuildId());
|
log.info("Executing mod mail category setup for server {}.", user.getGuildId());
|
||||||
String messageText = templateService.renderTemplate(messageTemplateKey, model);
|
String messageText = templateService.renderTemplate(messageTemplateKey, model, user.getGuildId());
|
||||||
AChannel channel = channelManagementService.loadChannel(user.getChannelId());
|
AChannel channel = channelManagementService.loadChannel(user.getChannelId());
|
||||||
CompletableFuture<SetupStepResult> future = new CompletableFuture<>();
|
CompletableFuture<SetupStepResult> future = new CompletableFuture<>();
|
||||||
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(user.getGuildId(), user.getUserId());
|
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(user.getGuildId(), user.getUserId());
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class Profanities extends AbstractConditionableCommand {
|
|||||||
.falsePositives(falsePositives)
|
.falsePositives(falsePositives)
|
||||||
.truePositives(positiveReports)
|
.truePositives(positiveReports)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(PROFANITIES_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(PROFANITIES_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class RepostLeaderboard extends AbstractConditionableCommand {
|
|||||||
.userExecuting(userFuture.join())
|
.userExecuting(userFuture.join())
|
||||||
.member(commandContext.getAuthor())
|
.member(commandContext.getAuthor())
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(REPOST_LEADERBOARD_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()));
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(REPOST_LEADERBOARD_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()));
|
||||||
}).thenApply(o -> CommandResult.fromIgnored());
|
}).thenApply(o -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ShowRepostCheckChannels extends AbstractConditionableCommand {
|
|||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
List<RepostCheckChannelGroup> channelGroups = checkChannelService.getChannelGroupsWithEnabledCheck(commandContext.getGuild().getIdLong());
|
List<RepostCheckChannelGroup> channelGroups = checkChannelService.getChannelGroupsWithEnabledCheck(commandContext.getGuild().getIdLong());
|
||||||
RepostCheckChannelsModel model = converter.fromRepostCheckChannelGroups(channelGroups, commandContext.getGuild());
|
RepostCheckChannelsModel model = converter.fromRepostCheckChannelGroups(channelGroups, commandContext.getGuild());
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SHOW_REPOST_CHECK_CHANNELS_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_REPOST_CHECK_CHANNELS_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class RepostLeaderboardTest {
|
|||||||
when(converter.convertSingleUser(userResult)).thenReturn(CompletableFuture.completedFuture(convertedUserResult));
|
when(converter.convertSingleUser(userResult)).thenReturn(CompletableFuture.completedFuture(convertedUserResult));
|
||||||
CompletableFuture<CommandResult> resultFuture = testUnit.executeAsync(noParameters);
|
CompletableFuture<CommandResult> resultFuture = testUnit.executeAsync(noParameters);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(resultFuture);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(resultFuture);
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(eq(RepostLeaderboard.REPOST_LEADERBOARD_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()));
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(eq(RepostLeaderboard.REPOST_LEADERBOARD_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()));
|
||||||
RepostLeaderboardModel model = modelCaptor.getValue();
|
RepostLeaderboardModel model = modelCaptor.getValue();
|
||||||
Assert.assertEquals(noParameters.getGuild(), model.getGuild());
|
Assert.assertEquals(noParameters.getGuild(), model.getGuild());
|
||||||
Assert.assertEquals(convertedList, model.getEntries());
|
Assert.assertEquals(convertedList, model.getEntries());
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ShowRepostCheckChannelsTest {
|
|||||||
when(converter.fromRepostCheckChannelGroups(groupList, noParameters.getGuild())).thenReturn(model);
|
when(converter.fromRepostCheckChannelGroups(groupList, noParameters.getGuild())).thenReturn(model);
|
||||||
CompletableFuture<CommandResult> futureResult = testUnit.executeAsync(noParameters);
|
CompletableFuture<CommandResult> futureResult = testUnit.executeAsync(noParameters);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(futureResult);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(futureResult);
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(ShowRepostCheckChannels.SHOW_REPOST_CHECK_CHANNELS_RESPONSE_TEMPLATE_KEY, model, noParameters.getChannel());
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(ShowRepostCheckChannels.SHOW_REPOST_CHECK_CHANNELS_RESPONSE_TEMPLATE_KEY, model, noParameters.getChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -62,17 +62,17 @@ public class DeletedEmoteStats extends AbstractConditionableCommand {
|
|||||||
// only show the embed, if there are static emotes to show
|
// only show the embed, if there are static emotes to show
|
||||||
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
||||||
log.debug("Deleted emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
log.debug("Deleted emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_DELETED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_DELETED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
// only show the embed, if there are animated emotes to show
|
// only show the embed, if there are animated emotes to show
|
||||||
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
||||||
log.debug("Deleted emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
log.debug("Deleted emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_DELETED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_DELETED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
// if neither static nor animated emote stats are available, show an embed indicating so
|
// if neither static nor animated emote stats are available, show an embed indicating so
|
||||||
if(!emoteStatsModel.areStatsAvailable()) {
|
if(!emoteStatsModel.areStatsAvailable()) {
|
||||||
log.info("No delete emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
log.info("No delete emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ public class EmoteStat extends AbstractConditionableCommand {
|
|||||||
}
|
}
|
||||||
EmoteStatsResultDisplay emoteStatsModel = usedEmoteService.getEmoteStatForEmote(trackedEmote, statsSince);
|
EmoteStatsResultDisplay emoteStatsModel = usedEmoteService.getEmoteStatForEmote(trackedEmote, statsSince);
|
||||||
if(emoteStatsModel.getResult().getAmount() == null) {
|
if(emoteStatsModel.getResult().getAmount() == null) {
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STAT_RESPONSE, emoteStatsModel, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STAT_RESPONSE, emoteStatsModel, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,17 +63,17 @@ public class EmoteStats extends AbstractConditionableCommand {
|
|||||||
// only show embed if static emote stats are available
|
// only show embed if static emote stats are available
|
||||||
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
||||||
log.debug("Emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
log.debug("Emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
// only show embed if animated emote stats are available
|
// only show embed if animated emote stats are available
|
||||||
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
||||||
log.debug("Emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
log.debug("Emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
// show an embed if no emote stats are available indicating so
|
// show an embed if no emote stats are available indicating so
|
||||||
if(!emoteStatsModel.areStatsAvailable()) {
|
if(!emoteStatsModel.areStatsAvailable()) {
|
||||||
log.info("No emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
log.info("No emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class ExportEmoteStats extends AbstractConditionableCommand {
|
|||||||
List<UsedEmote> usedEmotes = usedEmoteManagementService.loadEmoteUsagesForServerSince(actualServer, statsSince);
|
List<UsedEmote> usedEmotes = usedEmoteManagementService.loadEmoteUsagesForServerSince(actualServer, statsSince);
|
||||||
// if there are no stats available, render a message indicating so
|
// if there are no stats available, render a message indicating so
|
||||||
if(usedEmotes.isEmpty()) {
|
if(usedEmotes.isEmpty()) {
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(DOWNLOAD_EMOTE_STATS_NO_STATS_AVAILABLE_RESPONSE_TEMPLATE_KEY, new Object(), commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(DOWNLOAD_EMOTE_STATS_NO_STATS_AVAILABLE_RESPONSE_TEMPLATE_KEY, new Object(), commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
// info might not be nice to handle in the template, and 1970 would look weird to users
|
// info might not be nice to handle in the template, and 1970 would look weird to users
|
||||||
|
|||||||
@@ -66,19 +66,19 @@ public class ExternalEmoteStats extends AbstractConditionableCommand {
|
|||||||
// only show embed if static emote stats are available
|
// only show embed if static emote stats are available
|
||||||
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
||||||
log.debug("External emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
log.debug("External emote stats has {} static emotes since {}.", emoteStatsModel.getStaticEmotes().size(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only show embed if animated emote stats are available
|
// only show embed if animated emote stats are available
|
||||||
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
if(!emoteStatsModel.getAnimatedEmotes().isEmpty()) {
|
||||||
log.debug("External emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
log.debug("External emote stats has {} animated emotes since {}.", emoteStatsModel.getAnimatedEmotes(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE, emoteStatsModel, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show an embed if no emote stats are available indicating so
|
// show an embed if no emote stats are available indicating so
|
||||||
if(!emoteStatsModel.areStatsAvailable()) {
|
if(!emoteStatsModel.areStatsAvailable()) {
|
||||||
log.info("No external emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
log.info("No external emote stats available for guild {} since {}.", commandContext.getGuild().getIdLong(), statsSince);
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ShowExternalTrackedEmote extends AbstractConditionableCommand {
|
|||||||
if(!trackedEmote.getExternal()) {
|
if(!trackedEmote.getExternal()) {
|
||||||
throw new AbstractoTemplatedException("Emote is not external", "showExternalTrackedEmote_emote_is_not_external");
|
throw new AbstractoTemplatedException("Emote is not external", "showExternalTrackedEmote_emote_is_not_external");
|
||||||
}
|
}
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SHOW_EXTERNAL_TRACKED_EMOTE_RESPONSE_TEMPLATE_KEY, trackedEmote, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_EXTERNAL_TRACKED_EMOTE_RESPONSE_TEMPLATE_KEY, trackedEmote, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,25 +63,25 @@ public class ShowTrackedEmotes extends AbstractConditionableCommand {
|
|||||||
// only show the embed, if there are static tracked emotes
|
// only show the embed, if there are static tracked emotes
|
||||||
if(!trackedEmoteOverview.getStaticEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getStaticEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only show the embed if there are animated tracked emotes
|
// only show the embed if there are animated tracked emotes
|
||||||
if(!trackedEmoteOverview.getAnimatedEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getAnimatedEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only show the embed, if there are deleted static emotes
|
// only show the embed, if there are deleted static emotes
|
||||||
if(!trackedEmoteOverview.getDeletedStaticEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getDeletedStaticEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only show the embed, if there are deleted animated emotes
|
// only show the embed, if there are deleted animated emotes
|
||||||
if(!trackedEmoteOverview.getDeletedAnimatedEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getDeletedAnimatedEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean externalTrackingEnabled = featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, commandContext.getGuild().getIdLong(), EmoteTrackingMode.EXTERNAL_EMOTES);
|
boolean externalTrackingEnabled = featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, commandContext.getGuild().getIdLong(), EmoteTrackingMode.EXTERNAL_EMOTES);
|
||||||
@@ -92,19 +92,19 @@ public class ShowTrackedEmotes extends AbstractConditionableCommand {
|
|||||||
// only show the embed if there are external static emotes
|
// only show the embed if there are external static emotes
|
||||||
if(!trackedEmoteOverview.getExternalStaticEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getExternalStaticEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only show the embed if there are external animated emotes
|
// only show the embed if there are external animated emotes
|
||||||
if(!trackedEmoteOverview.getExternalAnimatedEmotes().isEmpty()) {
|
if(!trackedEmoteOverview.getExternalAnimatedEmotes().isEmpty()) {
|
||||||
noTrackedEmotesAvailable = false;
|
noTrackedEmotesAvailable = false;
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, trackedEmoteOverview, commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are no tracked emotes available, show an embed indicating so
|
// if there are no tracked emotes available, show an embed indicating so
|
||||||
if(noTrackedEmotesAvailable) {
|
if(noTrackedEmotesAvailable) {
|
||||||
messagePromises.addAll(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
messagePromises.addAll(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE, new Object(), commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
return FutureUtils.toSingleFutureGeneric(messagePromises)
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class SyncTrackedEmotes extends AbstractConditionableCommand {
|
|||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
TrackedEmoteSynchronizationResult syncResult = trackedEmoteService.synchronizeTrackedEmotes(commandContext.getGuild());
|
TrackedEmoteSynchronizationResult syncResult = trackedEmoteService.synchronizeTrackedEmotes(commandContext.getGuild());
|
||||||
// show a result of how many emotes were deleted/added
|
// show a result of how many emotes were deleted/added
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SYNC_TRACKED_EMOTES_RESULT_RESPONSE, syncResult, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SYNC_TRACKED_EMOTES_RESULT_RESPONSE, syncResult, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class DeletedEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class DeletedEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class DeletedEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(false);
|
when(model.areStatsAvailable()).thenReturn(false);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class DeletedEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
when(usedEmoteService.getDeletedEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class EmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class EmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class EmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(false);
|
when(model.areStatsAvailable()).thenReturn(false);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class EmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
when(usedEmoteService.getActiveEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class ExportEmoteStatsTest {
|
|||||||
when(usedEmoteManagementService.loadEmoteUsagesForServerSince(server, Instant.EPOCH)).thenReturn(usedEmotes);
|
when(usedEmoteManagementService.loadEmoteUsagesForServerSince(server, Instant.EPOCH)).thenReturn(usedEmotes);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
||||||
verify(channelService, times(1)).sendEmbedTemplateInTextChannelList(eq(DOWNLOAD_EMOTE_STATS_NO_STATS_AVAILABLE_RESPONSE_TEMPLATE_KEY), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(1)).sendEmbedTemplateInMessageChannel(eq(DOWNLOAD_EMOTE_STATS_NO_STATS_AVAILABLE_RESPONSE_TEMPLATE_KEY), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ExternalEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class ExternalEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class ExternalEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(false);
|
when(model.areStatsAvailable()).thenReturn(false);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class ExternalEmoteStatsTest {
|
|||||||
when(model.areStatsAvailable()).thenReturn(true);
|
when(model.areStatsAvailable()).thenReturn(true);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
when(usedEmoteService.getExternalEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ShowExternalTrackedEmoteTest {
|
|||||||
when(fakeTrackedEmote.getTrackedEmoteId()).thenReturn(trackedEmoteServer);
|
when(fakeTrackedEmote.getTrackedEmoteId()).thenReturn(trackedEmoteServer);
|
||||||
when(trackedEmoteManagementService.loadByTrackedEmoteServer(fakeTrackedEmote.getTrackedEmoteId())).thenReturn(actualTrackedEmote);
|
when(trackedEmoteManagementService.loadByTrackedEmoteServer(fakeTrackedEmote.getTrackedEmoteId())).thenReturn(actualTrackedEmote);
|
||||||
CommandContext commandContext = CommandTestUtilities.getWithParameters(Arrays.asList(fakeTrackedEmote));
|
CommandContext commandContext = CommandTestUtilities.getWithParameters(Arrays.asList(fakeTrackedEmote));
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_EXTERNAL_TRACKED_EMOTE_RESPONSE_TEMPLATE_KEY, actualTrackedEmote, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_EXTERNAL_TRACKED_EMOTE_RESPONSE_TEMPLATE_KEY, actualTrackedEmote, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CompletableFuture<CommandResult> resultFuture = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> resultFuture = testUnit.executeAsync(commandContext);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(resultFuture);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(resultFuture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
when(commandContext.getGuild().getIdLong()).thenReturn(SERVER_ID);
|
when(commandContext.getGuild().getIdLong()).thenReturn(SERVER_ID);
|
||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
||||||
@@ -62,7 +62,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
when(commandContext.getGuild().getIdLong()).thenReturn(SERVER_ID);
|
when(commandContext.getGuild().getIdLong()).thenReturn(SERVER_ID);
|
||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), true)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), true)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
||||||
@@ -76,7 +76,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
AvailableTrackedEmote staticEmote = Mockito.mock(AvailableTrackedEmote.class);
|
AvailableTrackedEmote staticEmote = Mockito.mock(AvailableTrackedEmote.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getStaticEmotes()).thenReturn(Arrays.asList(staticEmote));
|
when(overview.getStaticEmotes()).thenReturn(Arrays.asList(staticEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -92,7 +92,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
AvailableTrackedEmote animatedEmote = Mockito.mock(AvailableTrackedEmote.class);
|
AvailableTrackedEmote animatedEmote = Mockito.mock(AvailableTrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -108,7 +108,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getDeletedStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getDeletedStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -124,7 +124,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(false);
|
||||||
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getDeletedAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getDeletedAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -141,7 +141,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
||||||
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getExternalStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getExternalStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -157,7 +157,7 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
||||||
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getExternalAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getExternalAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
when(trackedEmoteService.loadTrackedEmoteOverview(commandContext.getGuild(), false)).thenReturn(overview);
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
@@ -173,12 +173,12 @@ public class ShowTrackedEmotesTest {
|
|||||||
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
TrackedEmoteOverview overview = Mockito.mock(TrackedEmoteOverview.class);
|
||||||
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
when(featureModeService.featureModeActive(StatisticFeatureDefinition.EMOTE_TRACKING, SERVER_ID, EmoteTrackingMode.EXTERNAL_EMOTES)).thenReturn(true);
|
||||||
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
TrackedEmote animatedEmote = Mockito.mock(TrackedEmote.class);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE, overview, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
when(overview.getExternalAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getExternalAnimatedEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
when(overview.getExternalStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
when(overview.getExternalStaticEmotes()).thenReturn(Arrays.asList(animatedEmote));
|
||||||
AvailableTrackedEmote trackedEmote = Mockito.mock(AvailableTrackedEmote.class);
|
AvailableTrackedEmote trackedEmote = Mockito.mock(AvailableTrackedEmote.class);
|
||||||
@@ -196,25 +196,25 @@ public class ShowTrackedEmotesTest {
|
|||||||
|
|
||||||
private void verifyNoMessage(CommandContext commandContext, boolean noStats, boolean staticEmote, boolean animatedEmote, boolean deletedStatic, boolean deletedAnimated, boolean externalStatic, boolean externalAnimated) {
|
private void verifyNoMessage(CommandContext commandContext, boolean noStats, boolean staticEmote, boolean animatedEmote, boolean deletedStatic, boolean deletedAnimated, boolean externalStatic, boolean externalAnimated) {
|
||||||
if(noStats) {
|
if(noStats) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_NO_STATS_AVAILABLE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(staticEmote) {
|
if(staticEmote) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(animatedEmote) {
|
if(animatedEmote) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(deletedStatic) {
|
if(deletedStatic) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_DELETED_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(deletedAnimated) {
|
if(deletedAnimated) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_DELETED_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(externalStatic) {
|
if(externalStatic) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_EXTERNAL_STATIC_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
if(externalAnimated) {
|
if(externalAnimated) {
|
||||||
verify(channelService, times(0)).sendEmbedTemplateInTextChannelList(eq(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
verify(channelService, times(0)).sendEmbedTemplateInMessageChannel(eq(SHOW_TRACKED_EMOTES_EXTERNAL_ANIMATED_RESPONSE), any(), eq(commandContext.getChannel()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class SyncTrackedEmotesTest {
|
|||||||
CommandContext commandContext = CommandTestUtilities.getNoParameters();
|
CommandContext commandContext = CommandTestUtilities.getNoParameters();
|
||||||
TrackedEmoteSynchronizationResult result = Mockito.mock(TrackedEmoteSynchronizationResult.class);
|
TrackedEmoteSynchronizationResult result = Mockito.mock(TrackedEmoteSynchronizationResult.class);
|
||||||
when(trackedEmoteService.synchronizeTrackedEmotes(commandContext.getGuild())).thenReturn(result);
|
when(trackedEmoteService.synchronizeTrackedEmotes(commandContext.getGuild())).thenReturn(result);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(SYNC_TRACKED_EMOTES_RESULT_RESPONSE, result, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
when(channelService.sendEmbedTemplateInMessageChannel(SYNC_TRACKED_EMOTES_RESULT_RESPONSE, result, commandContext.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||||
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
CompletableFuture<CommandResult> asyncResult = testUnit.executeAsync(commandContext);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(asyncResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ShowSuggestion extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
SuggestionInfoModel suggestionInfoModel = suggestionService.getSuggestionInfo(commandContext.getGuild().getIdLong(), suggestionId);
|
SuggestionInfoModel suggestionInfoModel = suggestionService.getSuggestionInfo(commandContext.getGuild().getIdLong(), suggestionId);
|
||||||
return FutureUtils.toSingleFutureGeneric(
|
return FutureUtils.toSingleFutureGeneric(
|
||||||
channelService.sendEmbedTemplateInTextChannelList(SHOW_SUGGESTION_TEMPLATE_KEY, suggestionInfoModel, commandContext.getChannel()))
|
channelService.sendEmbedTemplateInMessageChannel(SHOW_SUGGESTION_TEMPLATE_KEY, suggestionInfoModel, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class PollServiceBean implements PollService {
|
|||||||
.payloadType(PollAddOptionButtonPayload.class)
|
.payloadType(PollAddOptionButtonPayload.class)
|
||||||
.build();
|
.build();
|
||||||
componentPayloadManagementService.createButtonPayload(buttonConfigModel, serverId);
|
componentPayloadManagementService.createButtonPayload(buttonConfigModel, serverId);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model, serverId);
|
||||||
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
||||||
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
||||||
.thenAccept(unused -> self.persistPoll(messageFutures.get(0).join(), pollCreationRequest));
|
.thenAccept(unused -> self.persistPoll(messageFutures.get(0).join(), pollCreationRequest));
|
||||||
@@ -281,7 +281,7 @@ public class PollServiceBean implements PollService {
|
|||||||
.payloadType(QuickPollSelectionMenuPayload.class)
|
.payloadType(QuickPollSelectionMenuPayload.class)
|
||||||
.build();
|
.build();
|
||||||
componentPayloadManagementService.createStringSelectMenuPayload(selectMenuConfigModel, serverId);
|
componentPayloadManagementService.createStringSelectMenuPayload(selectMenuConfigModel, serverId);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(QUICK_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(QUICK_POLL_TEMPLATE_KEY, model, serverId);
|
||||||
List<CompletableFuture<Message>> messageFutures = interactionService.sendMessageToInteraction(messageToSend, interactionHook);
|
List<CompletableFuture<Message>> messageFutures = interactionService.sendMessageToInteraction(messageToSend, interactionHook);
|
||||||
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
||||||
.thenAccept(unused -> self.persistPoll(messageFutures.get(0).join(), pollCreationRequest));
|
.thenAccept(unused -> self.persistPoll(messageFutures.get(0).join(), pollCreationRequest));
|
||||||
@@ -339,7 +339,7 @@ public class PollServiceBean implements PollService {
|
|||||||
pollOptionManagementService.addOptionToPoll(poll, label, description, adderUser);
|
pollOptionManagementService.addOptionToPoll(poll, label, description, adderUser);
|
||||||
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
||||||
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model, serverId);
|
||||||
MessageChannel pollChannel = adder.getGuild().getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
MessageChannel pollChannel = adder.getGuild().getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
||||||
List<CompletableFuture<Message>> messageFutures = channelService.editMessagesInAChannelFuture(messageToSend, pollChannel, Arrays.asList(poll.getMessageId()));
|
List<CompletableFuture<Message>> messageFutures = channelService.editMessagesInAChannelFuture(messageToSend, pollChannel, Arrays.asList(poll.getMessageId()));
|
||||||
return FutureUtils.toSingleFutureGeneric(messageFutures);
|
return FutureUtils.toSingleFutureGeneric(messageFutures);
|
||||||
@@ -371,7 +371,7 @@ public class PollServiceBean implements PollService {
|
|||||||
.topOptions(topOptions)
|
.topOptions(topOptions)
|
||||||
.description(poll.getDescription())
|
.description(poll.getDescription())
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_EVALUATION_UPDATE_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_EVALUATION_UPDATE_TEMPLATE_KEY, model, serverId);
|
||||||
log.info("Sending update message for poll evaluation of server poll {} in server {}.", pollId, serverId);
|
log.info("Sending update message for poll evaluation of server poll {} in server {}.", pollId, serverId);
|
||||||
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
||||||
GuildMessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
GuildMessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
||||||
@@ -406,7 +406,7 @@ public class PollServiceBean implements PollService {
|
|||||||
.messageLink(MessageUtils.buildMessageUrl(serverId, poll.getChannel().getId(), poll.getMessageId()))
|
.messageLink(MessageUtils.buildMessageUrl(serverId, poll.getChannel().getId(), poll.getMessageId()))
|
||||||
.description(poll.getDescription())
|
.description(poll.getDescription())
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_REMINDER_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_REMINDER_TEMPLATE_KEY, model, serverId);
|
||||||
log.info("Sending poll reminder about server poll {} in server {}.", pollId, serverId);
|
log.info("Sending poll reminder about server poll {} in server {}.", pollId, serverId);
|
||||||
return FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLL_REMINDER, serverId));
|
return FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLL_REMINDER, serverId));
|
||||||
}
|
}
|
||||||
@@ -439,7 +439,7 @@ public class PollServiceBean implements PollService {
|
|||||||
.build();
|
.build();
|
||||||
MessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
MessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
||||||
CompletableFuture<Message> removeComponentFuture = channelService.removeComponents(channel, poll.getMessageId());
|
CompletableFuture<Message> removeComponentFuture = channelService.removeComponents(channel, poll.getMessageId());
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(QUICK_POLL_EVALUATION_UPDATE_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(QUICK_POLL_EVALUATION_UPDATE_TEMPLATE_KEY, model, serverId);
|
||||||
CompletableFuture<Void> updateMessageFuture = FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, channel));
|
CompletableFuture<Void> updateMessageFuture = FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, channel));
|
||||||
return CompletableFuture.allOf(removeComponentFuture, updateMessageFuture)
|
return CompletableFuture.allOf(removeComponentFuture, updateMessageFuture)
|
||||||
.thenApply(message -> null);
|
.thenApply(message -> null);
|
||||||
@@ -463,7 +463,7 @@ public class PollServiceBean implements PollService {
|
|||||||
if(poll.getEvaluationJobTriggerKey() != null) {
|
if(poll.getEvaluationJobTriggerKey() != null) {
|
||||||
schedulerService.stopTrigger(poll.getEvaluationJobTriggerKey());
|
schedulerService.stopTrigger(poll.getEvaluationJobTriggerKey());
|
||||||
}
|
}
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_CLOSE_MESSAGE, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_CLOSE_MESSAGE, model, serverId);
|
||||||
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, PollPostTarget.POLLS, serverId);
|
||||||
MessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
MessageChannel channel = channelService.getMessageChannelFromServer(serverId, poll.getChannel().getId());
|
||||||
CompletableFuture<Message> removeComponentsFuture = channelService.removeComponents(channel, poll.getMessageId());
|
CompletableFuture<Message> removeComponentsFuture = channelService.removeComponents(channel, poll.getMessageId());
|
||||||
@@ -527,7 +527,7 @@ public class PollServiceBean implements PollService {
|
|||||||
model.setAllowAdditions(false);
|
model.setAllowAdditions(false);
|
||||||
model.setShowDecisions(true);
|
model.setShowDecisions(true);
|
||||||
model.setAllowMultiple(false);
|
model.setAllowMultiple(false);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model, guild.getIdLong());
|
||||||
MessageChannel pollChannel = guild.getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
MessageChannel pollChannel = guild.getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
||||||
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), pollChannel, poll.getMessageId())
|
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), pollChannel, poll.getMessageId())
|
||||||
.thenApply(message -> null);
|
.thenApply(message -> null);
|
||||||
@@ -536,7 +536,7 @@ public class PollServiceBean implements PollService {
|
|||||||
public CompletableFuture<Void> updatePollMessage(Poll poll, Guild guild) {
|
public CompletableFuture<Void> updatePollMessage(Poll poll, Guild guild) {
|
||||||
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
||||||
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model, guild.getIdLong());
|
||||||
MessageChannel pollChannel = guild.getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
MessageChannel pollChannel = guild.getChannelById(GuildMessageChannel.class, poll.getChannel().getId());
|
||||||
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), pollChannel, poll.getMessageId())
|
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), pollChannel, poll.getMessageId())
|
||||||
.thenApply(message -> null);
|
.thenApply(message -> null);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ShowAvatar extends AbstractConditionableCommand {
|
|||||||
.build();
|
.build();
|
||||||
log.info("Showing avatar for member {} towards user {} in channel {} in server {}.",
|
log.info("Showing avatar for member {} towards user {} in channel {} in server {}.",
|
||||||
memberToShow.getId(), commandContext.getAuthor().getId(), commandContext.getChannel().getId(), commandContext.getGuild().getId());
|
memberToShow.getId(), commandContext.getAuthor().getId(), commandContext.getChannel().getId(), commandContext.getGuild().getId());
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SHOW_AVATAR_RESPONSE_TEMPLATE, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_AVATAR_RESPONSE_TEMPLATE, model, commandContext.getChannel()))
|
||||||
.thenApply(aVoid -> CommandResult.fromIgnored());
|
.thenApply(aVoid -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ShowEmote extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.emote(emoteParameter)
|
.emote(emoteParameter)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SHOW_EMOTE_RESPONSE_TEMPLATE, emoteLog, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_EMOTE_RESPONSE_TEMPLATE, emoteLog, commandContext.getChannel()))
|
||||||
.thenApply(aVoid -> CommandResult.fromIgnored());
|
.thenApply(aVoid -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class UserInfo extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompletableFuture<Void> sendResponse(MessageChannel channel, UserInfoModel model) {
|
public CompletableFuture<Void> sendResponse(MessageChannel channel, UserInfoModel model) {
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(USER_INFO_RESPONSE, model, channel));
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(USER_INFO_RESPONSE, model, channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ThreadReaderCommand extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.tweetId(tweetId)
|
.tweetId(tweetId)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(THREAD_READER_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(THREAD_READER_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ConditionPostExecution implements PostCommandExecution {
|
|||||||
.member(commandContext.getAuthor())
|
.member(commandContext.getAuthor())
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
channelService.sendEmbedTemplateInTextChannelList(GENERIC_COMMAND_EXCEPTION_MODEL_KEY, conditionModel, commandContext.getChannel());
|
channelService.sendEmbedTemplateInMessageChannel(GENERIC_COMMAND_EXCEPTION_MODEL_KEY, conditionModel, commandContext.getChannel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,14 +61,14 @@ public class ExceptionServiceBean implements ExceptionService {
|
|||||||
|
|
||||||
private void reportGenericException(Throwable throwable, CommandContext context) {
|
private void reportGenericException(Throwable throwable, CommandContext context) {
|
||||||
GenericExceptionModel exceptionModel = buildCommandModel(throwable, context);
|
GenericExceptionModel exceptionModel = buildCommandModel(throwable, context);
|
||||||
channelService.sendEmbedTemplateInTextChannelList("generic_command_exception", exceptionModel, context.getChannel());
|
channelService.sendEmbedTemplateInMessageChannel("generic_command_exception", exceptionModel, context.getChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportExceptionToGuildMessageReceivedContext(Throwable exception, MessageReceivedEvent event) {
|
public void reportExceptionToGuildMessageReceivedContext(Throwable exception, MessageReceivedEvent event) {
|
||||||
if(exception instanceof Templatable){
|
if(exception instanceof Templatable){
|
||||||
GenericExceptionModel model = buildMemberContext(exception, event.getMember());
|
GenericExceptionModel model = buildMemberContext(exception, event.getMember());
|
||||||
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model);
|
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model, event.getGuild().getIdLong());
|
||||||
channelService.sendTextToChannel(text, event.getChannel());
|
channelService.sendTextToChannel(text, event.getChannel());
|
||||||
} else {
|
} else {
|
||||||
channelService.sendTextToChannel(exception.getLocalizedMessage(), event.getChannel());
|
channelService.sendTextToChannel(exception.getLocalizedMessage(), event.getChannel());
|
||||||
@@ -79,7 +79,7 @@ public class ExceptionServiceBean implements ExceptionService {
|
|||||||
public void reportExceptionToPrivateMessageReceivedContext(Throwable exception, MessageReceivedEvent event) {
|
public void reportExceptionToPrivateMessageReceivedContext(Throwable exception, MessageReceivedEvent event) {
|
||||||
if(exception instanceof Templatable){
|
if(exception instanceof Templatable){
|
||||||
GenericExceptionModel model = buildPrivateMessageReceivedModel(exception, event.getAuthor());
|
GenericExceptionModel model = buildPrivateMessageReceivedModel(exception, event.getAuthor());
|
||||||
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model);
|
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model, event.getGuild().getIdLong());
|
||||||
channelService.sendTextToChannel(text, event.getChannel());
|
channelService.sendTextToChannel(text, event.getChannel());
|
||||||
} else {
|
} else {
|
||||||
channelService.sendTextToChannel(exception.getLocalizedMessage(), event.getChannel());
|
channelService.sendTextToChannel(exception.getLocalizedMessage(), event.getChannel());
|
||||||
@@ -90,7 +90,7 @@ public class ExceptionServiceBean implements ExceptionService {
|
|||||||
public void reportExceptionToChannel(Throwable exception, MessageChannel channel, Member member) {
|
public void reportExceptionToChannel(Throwable exception, MessageChannel channel, Member member) {
|
||||||
if(exception instanceof Templatable){
|
if(exception instanceof Templatable){
|
||||||
GenericExceptionModel model = buildMemberContext(exception, member);
|
GenericExceptionModel model = buildMemberContext(exception, member);
|
||||||
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model);
|
String text = templateService.renderTemplate(MODEL_WRAPPER_TEMPLATE_KEY, model, member.getGuild().getIdLong());
|
||||||
channelService.sendTextToChannel(text, channel);
|
channelService.sendTextToChannel(text, channel);
|
||||||
} else {
|
} else {
|
||||||
channelService.sendTextToChannel(exception.getLocalizedMessage(), channel);
|
channelService.sendTextToChannel(exception.getLocalizedMessage(), channel);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class FeatureModes extends AbstractConditionableCommand {
|
|||||||
.builder()
|
.builder()
|
||||||
.featureModes(featureModes)
|
.featureModes(featureModes)
|
||||||
.build();
|
.build();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(FEATURE_MODES_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(FEATURE_MODES_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(aVoid -> CommandResult.fromIgnored());
|
.thenApply(aVoid -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class ShowEffects extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
ShowEffectsModel model = getModel();
|
ShowEffectsModel model = getModel();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(SHOW_EFFECTS_RESPONSE_TEMPLATE,
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(SHOW_EFFECTS_RESPONSE_TEMPLATE,
|
||||||
model, commandContext.getChannel()))
|
model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class Documentation extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannelList(DOCUMENTATION_RESPONSE_TEMPLATE_KEY, new Object(), commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(DOCUMENTATION_RESPONSE_TEMPLATE_KEY, new Object(), commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromIgnored());
|
.thenApply(unused -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class Ping extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
PingModel model = buildModel(commandContext.getJda());
|
PingModel model = buildModel(commandContext.getJda());
|
||||||
return channelService.sendTextTemplateInTextChannel(PING_TEMPLATE, model, commandContext.getChannel())
|
return channelService.sendTextTemplateInMessageChannel(PING_TEMPLATE, model, commandContext.getChannel())
|
||||||
.thenApply(message -> CommandResult.fromIgnored());
|
.thenApply(message -> CommandResult.fromIgnored());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class Uptime extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
UptimeModel model = getModel();
|
UptimeModel model = getModel();
|
||||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(UPTIME_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(UPTIME_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
public class ServerContext {
|
public class ServerContext {
|
||||||
private Long serverId;
|
private Long serverId;
|
||||||
|
private String locale;
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
this.serverId = null;
|
this.serverId = null;
|
||||||
|
this.locale = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class SlashCommandServiceBean implements SlashCommandService {
|
|||||||
if(!isTemplated) {
|
if(!isTemplated) {
|
||||||
description = commandConfiguration.getDescription();
|
description = commandConfiguration.getDescription();
|
||||||
} else {
|
} else {
|
||||||
description = templateService.renderSimpleTemplate(internalCommandName + "_description");
|
description = templateService.renderSimpleTemplate(internalCommandName + "_description", serverId);
|
||||||
}
|
}
|
||||||
String rootName = slashConfig.getSlashCompatibleRootName();
|
String rootName = slashConfig.getSlashCompatibleRootName();
|
||||||
String groupName = slashConfig.getSlashCompatibleGroupName();
|
String groupName = slashConfig.getSlashCompatibleGroupName();
|
||||||
@@ -125,33 +125,33 @@ public class SlashCommandServiceBean implements SlashCommandService {
|
|||||||
for (int i = 0; i < parameter.getListSize(); i++) {
|
for (int i = 0; i < parameter.getListSize(); i++) {
|
||||||
for (OptionType type : types) {
|
for (OptionType type : types) {
|
||||||
String parameterName = slashCommandParameterService.getFullQualifiedParameterName(parameter.getSlashCompatibleName(), type) + "_" + i;
|
String parameterName = slashCommandParameterService.getFullQualifiedParameterName(parameter.getSlashCompatibleName(), type) + "_" + i;
|
||||||
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName()) : parameter.getDescription();
|
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName(), serverId) : parameter.getDescription();
|
||||||
OptionData optionData = new OptionData(type, parameterName, parameterDescription, false);
|
OptionData optionData = new OptionData(type, parameterName, parameterDescription, false);
|
||||||
addChoices(optionData, parameter, internalCommandName, isTemplated);
|
addChoices(optionData, parameter, internalCommandName, isTemplated, serverId);
|
||||||
optionalParameters.add(optionData);
|
optionalParameters.add(optionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
types.forEach(type -> {
|
types.forEach(type -> {
|
||||||
String parameterName = slashCommandParameterService.getFullQualifiedParameterName(parameter.getSlashCompatibleName(), type);
|
String parameterName = slashCommandParameterService.getFullQualifiedParameterName(parameter.getSlashCompatibleName(), type);
|
||||||
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName()) : parameter.getDescription();
|
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName(), serverId) : parameter.getDescription();
|
||||||
OptionData optionData = new OptionData(type, parameterName, parameterDescription, false);
|
OptionData optionData = new OptionData(type, parameterName, parameterDescription, false);
|
||||||
addChoices(optionData, parameter, internalCommandName, isTemplated);
|
addChoices(optionData, parameter, internalCommandName, isTemplated, serverId);
|
||||||
optionalParameters.add(optionData);
|
optionalParameters.add(optionData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OptionType type = types.get(0);
|
OptionType type = types.get(0);
|
||||||
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName()) : parameter.getDescription();
|
String parameterDescription = isTemplated ? templateService.renderSimpleTemplate(internalCommandName + "_parameter_" + parameter.getName(), serverId) : parameter.getDescription();
|
||||||
if(parameter.isListParam()) {
|
if(parameter.isListParam()) {
|
||||||
for (int i = 0; i < parameter.getListSize(); i++) {
|
for (int i = 0; i < parameter.getListSize(); i++) {
|
||||||
OptionData optionData = new OptionData(type, parameter.getSlashCompatibleName() + "_" + i, parameterDescription, false);
|
OptionData optionData = new OptionData(type, parameter.getSlashCompatibleName() + "_" + i, parameterDescription, false);
|
||||||
addChoices(optionData, parameter, internalCommandName, isTemplated);
|
addChoices(optionData, parameter, internalCommandName, isTemplated, serverId);
|
||||||
optionalParameters.add(optionData);
|
optionalParameters.add(optionData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OptionData optionData = new OptionData(type, parameter.getSlashCompatibleName(), parameterDescription, !parameter.isOptional(), parameter.getSupportsAutoComplete());
|
OptionData optionData = new OptionData(type, parameter.getSlashCompatibleName(), parameterDescription, !parameter.isOptional(), parameter.getSupportsAutoComplete());
|
||||||
addChoices(optionData, parameter, internalCommandName, isTemplated);
|
addChoices(optionData, parameter, internalCommandName, isTemplated, serverId);
|
||||||
requiredParameters.add(optionData);
|
requiredParameters.add(optionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,9 +160,9 @@ public class SlashCommandServiceBean implements SlashCommandService {
|
|||||||
return requiredParameters;
|
return requiredParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChoices(OptionData optionData, Parameter parameter, String commandName, boolean isTemplated) {
|
private void addChoices(OptionData optionData, Parameter parameter, String commandName, boolean isTemplated, Long serverId) {
|
||||||
parameter.getChoices().forEach(choiceKey -> {
|
parameter.getChoices().forEach(choiceKey -> {
|
||||||
String value = isTemplated ? templateService.renderSimpleTemplate(commandName + "_parameter_" + parameter.getName() + "_choice_" + choiceKey) : choiceKey;
|
String value = isTemplated ? templateService.renderSimpleTemplate(commandName + "_parameter_" + parameter.getName() + "_choice_" + choiceKey, serverId) : choiceKey;
|
||||||
optionData.addChoice(value, choiceKey);
|
optionData.addChoice(value, choiceKey);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ public class ChannelServiceBean implements ChannelService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<CompletableFuture<Message>> sendEmbedTemplateInTextChannelList(String templateKey, Object model, MessageChannel channel) {
|
public List<CompletableFuture<Message>> sendEmbedTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel) {
|
||||||
MessageToSend messageToSend;
|
MessageToSend messageToSend;
|
||||||
if(channel instanceof GuildChannel) {
|
if(channel instanceof GuildChannel) {
|
||||||
messageToSend = templateService.renderEmbedTemplate(templateKey, model, ((GuildChannel)channel).getGuild().getIdLong());
|
messageToSend = templateService.renderEmbedTemplate(templateKey, model, ((GuildChannel)channel).getGuild().getIdLong());
|
||||||
@@ -476,14 +476,7 @@ public class ChannelServiceBean implements ChannelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CompletableFuture<Message>> sendEmbedTemplateInMessageChannelList(String templateKey, Object model, MessageChannel channel) {
|
public CompletableFuture<Message> sendTextTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel) {
|
||||||
// message channel on its own, does not have a guild, so we cant say for which server we want to render the template
|
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(templateKey, model);
|
|
||||||
return sendMessageToSendToChannel(messageToSend, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Message> sendTextTemplateInTextChannel(String templateKey, Object model, MessageChannel channel) {
|
|
||||||
String text;
|
String text;
|
||||||
if(channel instanceof GuildChannel) {
|
if(channel instanceof GuildChannel) {
|
||||||
text = templateService.renderTemplate(templateKey, model, ((GuildChannel)channel).getGuild().getIdLong());
|
text = templateService.renderTemplate(templateKey, model, ((GuildChannel)channel).getGuild().getIdLong());
|
||||||
@@ -494,13 +487,6 @@ public class ChannelServiceBean implements ChannelService {
|
|||||||
return sendTextToChannel(text, channel);
|
return sendTextToChannel(text, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Message> sendTextTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel) {
|
|
||||||
// message channel on its own, does not have a guild, so we cant say for which server we want to render the template
|
|
||||||
String text = templateService.renderTemplate(templateKey, model);
|
|
||||||
return sendTextToChannel(text, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> deleteMessagesInChannel(MessageChannel messageChannel, List<Message> messages) {
|
public CompletableFuture<Void> deleteMessagesInChannel(MessageChannel messageChannel, List<Message> messages) {
|
||||||
metricService.incrementCounter(CHANNEL_MESSAGE_BULK_DELETE_METRIC);
|
metricService.incrementCounter(CHANNEL_MESSAGE_BULK_DELETE_METRIC);
|
||||||
@@ -580,7 +566,7 @@ public class ChannelServiceBean implements ChannelService {
|
|||||||
public CompletableFuture<Message> sendSimpleTemplateToChannel(Long serverId, Long channelId, String template) {
|
public CompletableFuture<Message> sendSimpleTemplateToChannel(Long serverId, Long channelId, String template) {
|
||||||
GuildMessageChannel foundChannel = getMessageChannelFromServer(serverId, channelId);
|
GuildMessageChannel foundChannel = getMessageChannelFromServer(serverId, channelId);
|
||||||
if(foundChannel != null) {
|
if(foundChannel != null) {
|
||||||
return sendTextTemplateInTextChannel(template, new Object(), foundChannel);
|
return sendTextTemplateInMessageChannel(template, new Object(), foundChannel);
|
||||||
} else {
|
} else {
|
||||||
log.info("Channel {} in server {} not found.", channelId, serverId);
|
log.info("Channel {} in server {} not found.", channelId, serverId);
|
||||||
throw new IllegalArgumentException("Incorrect channel type.");
|
throw new IllegalArgumentException("Incorrect channel type.");
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class MessageServiceBean implements MessageService {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> sendEmbedToUser(User user, String template, Object model) {
|
public CompletableFuture<Void> sendEmbedToUser(User user, String template, Object model) {
|
||||||
return openPrivateChannelForUser(user).thenCompose(privateChannel ->
|
return openPrivateChannelForUser(user).thenCompose(privateChannel ->
|
||||||
FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannelList(template, model, privateChannel)));
|
FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(template, model, privateChannel)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<PrivateChannel> openPrivateChannelForUser(User user) {
|
public CompletableFuture<PrivateChannel> openPrivateChannelForUser(User user) {
|
||||||
@@ -192,7 +192,7 @@ public class MessageServiceBean implements MessageService {
|
|||||||
public CompletableFuture<Message> sendEmbedToUserWithMessage(User user, String template, Object model) {
|
public CompletableFuture<Message> sendEmbedToUserWithMessage(User user, String template, Object model) {
|
||||||
log.debug("Sending direct message with template {} to user {}.", template, user.getIdLong());
|
log.debug("Sending direct message with template {} to user {}.", template, user.getIdLong());
|
||||||
return openPrivateChannelForUser(user).thenCompose(privateChannel ->
|
return openPrivateChannelForUser(user).thenCompose(privateChannel ->
|
||||||
channelService.sendEmbedTemplateInMessageChannelList(template, model, privateChannel).get(0));
|
channelService.sendEmbedTemplateInMessageChannel(template, model, privateChannel).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class PaginatorServiceBean implements PaginatorService {
|
|||||||
.build();
|
.build();
|
||||||
String embedConfig = templateService.renderTemplate(templateKey + "_paginator", wrapperModel, serverId);
|
String embedConfig = templateService.renderTemplate(templateKey + "_paginator", wrapperModel, serverId);
|
||||||
PaginatorConfiguration configuration = gson.fromJson(embedConfig, PaginatorConfiguration.class);
|
PaginatorConfiguration configuration = gson.fromJson(embedConfig, PaginatorConfiguration.class);
|
||||||
setupFooters(configuration);
|
setupFooters(configuration, serverId);
|
||||||
|
|
||||||
configuration.setPaginatorId(componentService.generateComponentId());
|
configuration.setPaginatorId(componentService.generateComponentId());
|
||||||
configuration.setSinglePage(configuration.getEmbedConfigs().size() < 2);
|
configuration.setSinglePage(configuration.getEmbedConfigs().size() < 2);
|
||||||
@@ -138,14 +138,14 @@ public class PaginatorServiceBean implements PaginatorService {
|
|||||||
.thenAccept(message -> self.setupButtonPayloads(message, setup, serverId));
|
.thenAccept(message -> self.setupButtonPayloads(message, setup, serverId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupFooters(PaginatorConfiguration configuration) {
|
private void setupFooters(PaginatorConfiguration configuration, Long serverId) {
|
||||||
for (int i = 0; i < configuration.getEmbedConfigs().size(); i++) {
|
for (int i = 0; i < configuration.getEmbedConfigs().size(); i++) {
|
||||||
PaginatorFooterModel paginatorModel = PaginatorFooterModel
|
PaginatorFooterModel paginatorModel = PaginatorFooterModel
|
||||||
.builder()
|
.builder()
|
||||||
.page(i + 1)
|
.page(i + 1)
|
||||||
.pageCount(configuration.getEmbedConfigs().size())
|
.pageCount(configuration.getEmbedConfigs().size())
|
||||||
.build();
|
.build();
|
||||||
String footerText = templateService.renderTemplate(PAGINATOR_FOOTER_TEMPLATE_KEY, paginatorModel);
|
String footerText = templateService.renderTemplate(PAGINATOR_FOOTER_TEMPLATE_KEY, paginatorModel, serverId);
|
||||||
MessageConfiguration messageConfig = configuration.getEmbedConfigs().get(i);
|
MessageConfiguration messageConfig = configuration.getEmbedConfigs().get(i);
|
||||||
if(messageConfig.getEmbeds() == null || messageConfig.getEmbeds().isEmpty()) {
|
if(messageConfig.getEmbeds() == null || messageConfig.getEmbeds().isEmpty()) {
|
||||||
messageConfig.setEmbeds(new ArrayList<>(Arrays.asList(EmbedConfiguration.builder().build())));
|
messageConfig.setEmbeds(new ArrayList<>(Arrays.asList(EmbedConfiguration.builder().build())));
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ import java.util.Optional;
|
|||||||
@Component
|
@Component
|
||||||
public class DatabaseTemplateLoader implements TemplateLoader {
|
public class DatabaseTemplateLoader implements TemplateLoader {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TemplateService templateService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EffectiveTemplateManagementService effectiveTemplateManagementService;
|
private EffectiveTemplateManagementService effectiveTemplateManagementService;
|
||||||
|
|
||||||
@@ -43,7 +40,7 @@ public class DatabaseTemplateLoader implements TemplateLoader {
|
|||||||
} else {
|
} else {
|
||||||
templateByKey = effectiveTemplateManagementService.getTemplateByKey(s);
|
templateByKey = effectiveTemplateManagementService.getTemplateByKey(s);
|
||||||
}
|
}
|
||||||
return templateByKey.orElseThrow(() -> new IOException(String.format("Failed to load template. %s", s)));
|
return templateByKey.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -502,12 +502,21 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public MessageToSend renderEmbedTemplate(String key, Object model, Long serverId) {
|
public MessageToSend renderEmbedTemplate(String key, Object model, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderEmbedTemplate(key, model);
|
return renderEmbedTemplate(key, model);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME not thread safe
|
||||||
|
private void initLocaleFromServer() {
|
||||||
|
if(serverContext.getServerId() != null) {
|
||||||
|
String localeConfig = configService.getStringValueOrConfigDefault(CoreFeatureConfig.LOCALE_CONFIG_KEY, serverContext.getServerId());
|
||||||
|
serverContext.setLocale(localeConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isEmptyEmbed(EmbedConfiguration configuration) {
|
private boolean isEmptyEmbed(EmbedConfiguration configuration) {
|
||||||
if (configuration.getMetaConfig() != null && configuration.getMetaConfig().isPreventEmptyEmbed()) {
|
if (configuration.getMetaConfig() != null && configuration.getMetaConfig().isPreventEmptyEmbed()) {
|
||||||
return configuration.getFields() == null && configuration.getDescription() == null && configuration.getImageUrl() == null;
|
return configuration.getFields() == null && configuration.getDescription() == null && configuration.getImageUrl() == null;
|
||||||
@@ -524,6 +533,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public MessageToSend renderTemplateToMessageToSend(String key, Object model, Long serverId) {
|
public MessageToSend renderTemplateToMessageToSend(String key, Object model, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderTemplateToMessageToSend(key, model);
|
return renderTemplateToMessageToSend(key, model);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
@@ -729,6 +739,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public String renderTemplateWithMap(String key, HashMap<String, Object> parameters, Long serverId) {
|
public String renderTemplateWithMap(String key, HashMap<String, Object> parameters, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderTemplateWithMap(key, parameters);
|
return renderTemplateWithMap(key, parameters);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
@@ -756,6 +767,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public String renderTemplate(String key, Object model, Long serverId) {
|
public String renderTemplate(String key, Object model, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderTemplate(key, model);
|
return renderTemplate(key, model);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
@@ -773,7 +785,11 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
*/
|
*/
|
||||||
private String renderTemplateToString(String key, Object model) throws IOException, TemplateException {
|
private String renderTemplateToString(String key, Object model) throws IOException, TemplateException {
|
||||||
StringWriter result = new StringWriter();
|
StringWriter result = new StringWriter();
|
||||||
Template template = configuration.getTemplate(key, null, serverContext.getServerId(), null, true, false);
|
Locale locale = null;
|
||||||
|
if(serverContext.getLocale() != null) {
|
||||||
|
locale = Locale.forLanguageTag(serverContext.getLocale());
|
||||||
|
}
|
||||||
|
Template template = configuration.getTemplate(key, locale, serverContext.getServerId(), null, true, false);
|
||||||
template.process(model, result);
|
template.process(model, result);
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
@@ -793,6 +809,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public String renderSimpleTemplate(String key, Long serverId) {
|
public String renderSimpleTemplate(String key, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderSimpleTemplate(key);
|
return renderSimpleTemplate(key);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
@@ -814,6 +831,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public String renderTemplatable(Templatable templatable, Long serverId) {
|
public String renderTemplatable(Templatable templatable, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderTemplatable(templatable);
|
return renderTemplatable(templatable);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
@@ -824,6 +842,7 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
public String renderDuration(Duration duration, Long serverId) {
|
public String renderDuration(Duration duration, Long serverId) {
|
||||||
try {
|
try {
|
||||||
serverContext.setServerId(serverId);
|
serverContext.setServerId(serverId);
|
||||||
|
initLocaleFromServer();
|
||||||
return renderDuration(duration);
|
return renderDuration(duration);
|
||||||
} finally {
|
} finally {
|
||||||
serverContext.clear();
|
serverContext.clear();
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ abstracto.systemConfigs.prefix.stringValue=!
|
|||||||
abstracto.systemConfigs.noCommandFoundReporting.name=noCommandFoundReporting
|
abstracto.systemConfigs.noCommandFoundReporting.name=noCommandFoundReporting
|
||||||
abstracto.systemConfigs.noCommandFoundReporting.stringValue=true
|
abstracto.systemConfigs.noCommandFoundReporting.stringValue=true
|
||||||
|
|
||||||
|
abstracto.systemConfigs.locale.name=locale
|
||||||
|
abstracto.systemConfigs.locale.stringValue=en-US
|
||||||
|
|
||||||
abstracto.systemConfigs.confirmationTimeout.name=confirmationTimeout
|
abstracto.systemConfigs.confirmationTimeout.name=confirmationTimeout
|
||||||
abstracto.systemConfigs.confirmationTimeout.longValue=120
|
abstracto.systemConfigs.confirmationTimeout.longValue=120
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class FeatureModesTest {
|
|||||||
AServer server = Mockito.mock(AServer.class);
|
AServer server = Mockito.mock(AServer.class);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(featureModeService.getEffectiveFeatureModes(server)).thenReturn(featureModeDisplays);
|
when(featureModeService.getEffectiveFeatureModes(server)).thenReturn(featureModeDisplays);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(FeatureModes.FEATURE_MODES_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()))).thenReturn(new ArrayList<>());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(FeatureModes.FEATURE_MODES_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()))).thenReturn(new ArrayList<>());
|
||||||
CompletableFuture<CommandResult> commandResultCompletableFuture = testUnit.executeAsync(noParameters);
|
CompletableFuture<CommandResult> commandResultCompletableFuture = testUnit.executeAsync(noParameters);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(commandResultCompletableFuture);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(commandResultCompletableFuture);
|
||||||
List<FeatureModeDisplay> usedDisplays = modelCaptor.getValue().getFeatureModes();
|
List<FeatureModeDisplay> usedDisplays = modelCaptor.getValue().getFeatureModes();
|
||||||
@@ -86,7 +86,7 @@ public class FeatureModesTest {
|
|||||||
AServer server = Mockito.mock(AServer.class);
|
AServer server = Mockito.mock(AServer.class);
|
||||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||||
when(featureModeService.getEffectiveFeatureModes(server, feature)).thenReturn(featureModeDisplays);
|
when(featureModeService.getEffectiveFeatureModes(server, feature)).thenReturn(featureModeDisplays);
|
||||||
when(channelService.sendEmbedTemplateInTextChannelList(eq(FeatureModes.FEATURE_MODES_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()))).thenReturn(new ArrayList<>());
|
when(channelService.sendEmbedTemplateInMessageChannel(eq(FeatureModes.FEATURE_MODES_RESPONSE_TEMPLATE_KEY), modelCaptor.capture(), eq(noParameters.getChannel()))).thenReturn(new ArrayList<>());
|
||||||
CompletableFuture<CommandResult> commandResultCompletableFuture = testUnit.executeAsync(noParameters);
|
CompletableFuture<CommandResult> commandResultCompletableFuture = testUnit.executeAsync(noParameters);
|
||||||
CommandTestUtilities.checkSuccessfulCompletionAsync(commandResultCompletableFuture);
|
CommandTestUtilities.checkSuccessfulCompletionAsync(commandResultCompletableFuture);
|
||||||
List<FeatureModeDisplay> usedDisplays = modelCaptor.getValue().getFeatureModes();
|
List<FeatureModeDisplay> usedDisplays = modelCaptor.getValue().getFeatureModes();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.List;
|
|||||||
public class CoreFeatureConfig implements FeatureConfig {
|
public class CoreFeatureConfig implements FeatureConfig {
|
||||||
|
|
||||||
public static final String NO_COMMAND_REPORTING_CONFIG_KEY = "noCommandFoundReporting";
|
public static final String NO_COMMAND_REPORTING_CONFIG_KEY = "noCommandFoundReporting";
|
||||||
|
public static final String LOCALE_CONFIG_KEY = "locale";
|
||||||
public static final String SUCCESS_REACTION_KEY = "successReaction";
|
public static final String SUCCESS_REACTION_KEY = "successReaction";
|
||||||
public static final String WARN_REACTION_KEY = "warnReaction";
|
public static final String WARN_REACTION_KEY = "warnReaction";
|
||||||
public static final String MAX_MESSAGES_KEY = "maxMessages";
|
public static final String MAX_MESSAGES_KEY = "maxMessages";
|
||||||
@@ -28,6 +29,6 @@ public class CoreFeatureConfig implements FeatureConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getRequiredSystemConfigKeys() {
|
public List<String> getRequiredSystemConfigKeys() {
|
||||||
return Arrays.asList(NO_COMMAND_REPORTING_CONFIG_KEY, MAX_MESSAGES_KEY, CONFIRMATION_TIMEOUT);
|
return Arrays.asList(NO_COMMAND_REPORTING_CONFIG_KEY, MAX_MESSAGES_KEY, CONFIRMATION_TIMEOUT, LOCALE_CONFIG_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ public interface ChannelService {
|
|||||||
CompletableFuture<Void> archiveThreadChannel(ThreadChannel threadChannel);
|
CompletableFuture<Void> archiveThreadChannel(ThreadChannel threadChannel);
|
||||||
CompletableFuture<Void> deleteTextChannel(AChannel channel);
|
CompletableFuture<Void> deleteTextChannel(AChannel channel);
|
||||||
CompletableFuture<Void> deleteTextChannel(Long serverId, Long channelId);
|
CompletableFuture<Void> deleteTextChannel(Long serverId, Long channelId);
|
||||||
List<CompletableFuture<Message>> sendEmbedTemplateInTextChannelList(String templateKey, Object model, MessageChannel channel);
|
List<CompletableFuture<Message>> sendEmbedTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel);
|
||||||
List<CompletableFuture<Message>> sendEmbedTemplateInMessageChannelList(String templateKey, Object model, MessageChannel channel);
|
|
||||||
CompletableFuture<Message> sendTextTemplateInTextChannel(String templateKey, Object model, MessageChannel channel);
|
|
||||||
CompletableFuture<Message> sendTextTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel);
|
CompletableFuture<Message> sendTextTemplateInMessageChannel(String templateKey, Object model, MessageChannel channel);
|
||||||
CompletableFuture<Void> deleteMessagesInChannel(MessageChannel messageChannel, List<Message> messages);
|
CompletableFuture<Void> deleteMessagesInChannel(MessageChannel messageChannel, List<Message> messages);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user