[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:
Sheldan
2024-11-22 21:54:13 +01:00
parent 0e95ddf198
commit 453378f0b6
72 changed files with 181 additions and 172 deletions

View File

@@ -54,7 +54,7 @@ public class MyWarnings extends AbstractConditionableCommand {
.totalWarnCount(totalWarnCount)
.currentWarnCount(currentWarnCount)
.build();
channelService.sendEmbedTemplateInTextChannelList(MY_WARNINGS_RESPONSE_EMBED_TEMPLATE, model, commandContext.getChannel());
channelService.sendEmbedTemplateInMessageChannel(MY_WARNINGS_RESPONSE_EMBED_TEMPLATE, model, commandContext.getChannel());
return CommandResult.fromIgnored();
}

View File

@@ -90,7 +90,7 @@ public class UserNotes extends AbstractConditionableCommand {
CompletableFuture<List<NoteEntryModel>> listCompletableFuture = userNotesConverter.fromNotes(userNotes);
return listCompletableFuture.thenCompose(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());
});
}

View File

@@ -81,7 +81,7 @@ public class BanModerationActionModalListener implements ModalInteractionListene
.findFirst()
.orElse(null);
if(StringUtils.isBlank(tempReason)) {
reason = templateService.renderSimpleTemplate(DEFAULT_BAN_REASON_TEMPLATE_KEY);
reason = templateService.renderSimpleTemplate(DEFAULT_BAN_REASON_TEMPLATE_KEY, model.getServerId());
} else {
reason = tempReason;
}

View File

@@ -78,7 +78,7 @@ public class HoneyPotRoleAddedListener implements RoleAddedListener {
.memberDisplay(MemberDisplay.fromMember(model.getTargetMember()))
.roleDisplay(RoleDisplay.fromRole(model.getRole()))
.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()),
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());