moved some more templates to template config

fixed usage of post target exceptions
This commit is contained in:
Sheldan
2020-05-13 17:45:55 +02:00
parent 80505d1014
commit cb1abaed7d
32 changed files with 34 additions and 22 deletions

View File

@@ -3,7 +3,7 @@ package dev.sheldan.abstracto.modmail.service;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import com.jagrosh.jdautilities.menu.ButtonMenu;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.exception.PostTargetNotValidException;
import dev.sheldan.abstracto.core.exception.PostTargetNotFoundException;
import dev.sheldan.abstracto.core.models.FullGuild;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.UndoActionInstance;
@@ -398,7 +398,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
log.error("Failed to log messages for mod mail thread {}.", modMailThreadId, innerThrowable);
return null;
});
} catch (PostTargetNotValidException po) {
} catch (PostTargetNotFoundException po) {
log.error("Failed to log mod mail messages", po);
sendModMailFailure("modmail_exception_post_target_not_defined", innerModMailThread.getUser(), modMailThreadId, feedBack, po);
} catch (Exception e) {

View File

@@ -10,6 +10,6 @@
},
<#assign user>${threadUser.member.effectiveName}#${threadUser.member.user.discriminator} (${threadUser.member.user.id})</#assign>
<#assign joinDate>${threadUser.member.timeJoined}</#assign>
<#assign roles><#list threadUser.member.roles as role>${role.asMention}<#sep>,<#else>No roles</#list></#assign>
<#assign roles><#list threadUser.member.roles as role>${role.asMention}<#sep>,<#else><#include "modmail_thread_header_no_roles"></#list></#assign>
"description": "<#include "modmail_thread_header_embed_description">"
}

View File

@@ -4,7 +4,7 @@
"name": "${author.effectiveName}",
"avatar": "${author.user.effectiveAvatarUrl}"
<#else>
"name": "${user.id?c} (Has left the server)"
"name": "${user.id?c} (<#include "user_left_server">)"
</#if>
},
"color" : {

View File

@@ -3,6 +3,7 @@ package dev.sheldan.abstracto.core.service;
import dev.sheldan.abstracto.core.config.DynamicKeyLoader;
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
import dev.sheldan.abstracto.core.exception.GuildException;
import dev.sheldan.abstracto.core.exception.PostTargetNotFoundException;
import dev.sheldan.abstracto.core.exception.PostTargetNotValidException;
import dev.sheldan.abstracto.core.service.management.PostTargetManagement;
import dev.sheldan.abstracto.core.models.database.PostTarget;
@@ -70,7 +71,7 @@ public class PostTargetServiceBean implements PostTargetService {
return postTarget;
} else {
log.error("PostTarget {} in server {} was not found!", postTargetName, serverId);
throw new PostTargetNotValidException(postTargetName);
throw new PostTargetNotFoundException(postTargetName);
}
}
@@ -171,7 +172,7 @@ public class PostTargetServiceBean implements PostTargetService {
public void throwIfPostTargetIsNotDefined(String name, Long serverId) {
PostTarget postTarget = postTargetManagement.getPostTarget(name, serverId);
if(postTarget == null) {
throw new PostTargetNotValidException(name);
throw new PostTargetNotValidException(name, dynamicKeyLoader.getPostTargetsAsList());
}
}

View File

@@ -2,7 +2,7 @@ package dev.sheldan.abstracto.core.service.management;
import dev.sheldan.abstracto.core.config.DynamicKeyLoader;
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
import dev.sheldan.abstracto.core.exception.PostTargetNotFoundException;
import dev.sheldan.abstracto.core.exception.PostTargetNotValidException;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.PostTarget;
@@ -36,7 +36,7 @@ public class PostTargetManagementBean implements PostTargetManagement {
@Override
public PostTarget createPostTarget(String name, AServer server, AChannel targetChannel) {
if(!postTargetService.validPostTarget(name)) {
throw new PostTargetNotFoundException(name, dynamicKeyLoader.getPostTargetsAsList());
throw new PostTargetNotValidException(name, dynamicKeyLoader.getPostTargetsAsList());
}
log.info("Creating post target {} pointing towards {}", name, targetChannel);
PostTarget build = PostTarget.builder().name(name).channelReference(targetChannel).serverReference(server).build();

View File

@@ -1 +1 @@
Command was not found.
<#include "command_not_found_text">

View File

@@ -1 +1 @@
Feature has been disabled. Necessary feature is: <#include "${featureConfig.feature.key}_feature">, you can enable it by executing `enable ${featureConfig.feature.key}`.
<#assign featureName><#include "${featureConfig.feature.key}_feature"></#assign><#assign featureKey>${featureConfig.feature.key}</#assign><#include "feature_disabled_text">

View File

@@ -1 +1 @@
Feature ${featureName} not available. The available features are: ${availableFeatures?join(", ")}
<#assign availableFeatures>${availableFeatures?join(", ")}</#assign><#include "feature_not_found_text">

View File

@@ -1 +1 @@
The targeted user is immune against this command, because of the role: ${role.name}.
<#assign roleName>${role.name}</#assign> <#include "immune_role_text">

View File

@@ -1 +1 @@
The necessary parameters were not found. A '${class.simpleName}' was expected as '${parameterName}'. Consult help to see the correct syntax.
<#assign expectedType>${class.simpleName}</#assign><#include "incorrect_parameters_text">

View File

@@ -1 +1 @@
Insufficient parameters: ${parameterName} was not found.
<#include "insufficient_parameters_text">

View File

@@ -1 +1 @@
You lack the necessary role to execute this command. One of the following is needed: <#list allowedRoles as role>${role.name}<#sep>,<#else>None configured.</#list>
<#assign roles><#list allowedRoles as role>${role.name}<#sep>,<#else>None configured.</#list></#assign><#include "insufficient_role_text">

View File

@@ -1 +1 @@
The parameter ${parameterName} had a too large value: ${actualLength}. The maximum is: ${maximumLength}.
<#include "parameter_too_long_text">

View File

@@ -8,12 +8,10 @@ import java.util.List;
public class PostTargetNotFoundException extends AbstractoRunTimeException implements Templatable {
private String postTargetKey;
private List<String> availableTargets;
public PostTargetNotFoundException(String key, List<String> available) {
public PostTargetNotFoundException(String key) {
super("");
this.postTargetKey = key;
this.availableTargets = available;
}
@Override
@@ -25,7 +23,6 @@ public class PostTargetNotFoundException extends AbstractoRunTimeException imple
public Object getTemplateModel() {
HashMap<String, String> param = new HashMap<>();
param.put("key", this.postTargetKey);
param.put("available", String.join(",", this.availableTargets));
return param;
}
}

View File

@@ -3,14 +3,17 @@ package dev.sheldan.abstracto.core.exception;
import dev.sheldan.abstracto.templating.Templatable;
import java.util.HashMap;
import java.util.List;
public class PostTargetNotValidException extends AbstractoRunTimeException implements Templatable {
private String postTargetKey;
private List<String> availableTargets;
public PostTargetNotValidException(String key) {
public PostTargetNotValidException(String key, List<String> available) {
super("");
this.postTargetKey = key;
this.availableTargets = available;
}
@Override
@@ -22,6 +25,7 @@ public class PostTargetNotValidException extends AbstractoRunTimeException imple
public Object getTemplateModel() {
HashMap<String, String> param = new HashMap<>();
param.put("key", this.postTargetKey);
param.put("available", String.join(",", this.availableTargets));
return param;
}
}

View File

@@ -0,0 +1 @@
Feature has been disabled. Necessary feature is: ${featureName}, you can enable it by executing `enable ${featureKey}`.

View File

@@ -0,0 +1 @@
Feature ${featureName} not available. The available features are: ${availableFeatures}.

View File

@@ -0,0 +1 @@
The targeted user is immune against this command, because of the role: ${roleName}.

View File

@@ -0,0 +1 @@
The necessary parameters were not found. A '${expectedType}' was expected as '${parameterName}'. Consult help to see the correct syntax.

View File

@@ -0,0 +1 @@
Insufficient parameters: ${parameterName} was not found.

View File

@@ -0,0 +1 @@
You lack the necessary role to execute this command. One of the following is needed: ${roles}

View File

@@ -0,0 +1 @@
The parameter ${parameterName} had a too large value: ${actualLength}. The maximum is: ${maximumLength}.

View File

@@ -1 +1 @@
Page ${count}
<#include "embed_page_count_page">