pulled some more user facing strings into templates

This commit is contained in:
Sheldan
2020-05-14 00:49:57 +02:00
parent 40731157f7
commit 4c826676d0
15 changed files with 46 additions and 10 deletions

View File

@@ -14,6 +14,7 @@ import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.experience.config.features.ExperienceFeature;
import dev.sheldan.abstracto.experience.service.ExperienceRoleService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -35,6 +36,8 @@ public class SetExpRole extends AbstractConditionableCommand {
@Autowired
private RoleService roleService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
@@ -51,7 +54,7 @@ public class SetExpRole extends AbstractConditionableCommand {
experienceRoleService.setRoleToLevel(role, level, server, commandContext.getUserInitiatedContext().getChannel());
return CommandResult.fromSuccess();
}
return CommandResult.fromError("Could not find role");
return CommandResult.fromError(templateService.renderTemplate("could_not_find_role", new Object()));
}
@Override

View File

@@ -30,7 +30,7 @@ public class ShowEmote extends AbstractConditionableCommand {
List<Object> parameters = commandContext.getParameters().getParameters();
Object emoteParameter = parameters.get(0);
if(!(emoteParameter instanceof Emote)) {
return CommandResult.fromError("No custom emote found.");
return CommandResult.fromError(templateService.renderTemplate("no_custom_emote_found", new Object()));
}
Emote emote = (Emote) emoteParameter;
ShowEmoteLog emoteLog = (ShowEmoteLog) ContextConverter.fromCommandContext(commandContext, ShowEmoteLog.class);

View File

@@ -12,6 +12,7 @@ import dev.sheldan.abstracto.core.command.execution.*;
import dev.sheldan.abstracto.core.command.execution.UnParsedCommandParameter;
import dev.sheldan.abstracto.core.Constants;
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
import dev.sheldan.abstracto.core.exception.RoleNotFoundInDBException;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
@@ -175,9 +176,11 @@ public class CommandReceivedHandler extends ListenerAdapter {
}
} else if(param.getType().equals(ARole.class)) {
if(StringUtils.isNumeric(value)) {
parsedParameters.add(roleManagementService.findRole(Long.parseLong(value), userInitiatedServerContext.getServer()));
long roleId = Long.parseLong(value);
parsedParameters.add(roleManagementService.findRole(roleId, userInitiatedServerContext.getServer()).orElseThrow(() -> new RoleNotFoundInDBException(roleId, message.getGuild().getIdLong())));
} else {
parsedParameters.add(roleManagementService.findRole(roleIterator.next().getIdLong(), userInitiatedServerContext.getServer()));
long roleId = roleIterator.next().getIdLong();
parsedParameters.add(roleManagementService.findRole(roleId, userInitiatedServerContext.getServer()).orElseThrow(() -> new RoleNotFoundInDBException(roleId, message.getGuild().getIdLong())));
}
} else if(param.getType().equals(Boolean.class)) {
parsedParameters.add(Boolean.valueOf(value));

View File

@@ -15,6 +15,7 @@ import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.config.features.CoreFeatures;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -36,6 +37,9 @@ public class Allow extends AbstractConditionableCommand {
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -48,7 +52,7 @@ public class Allow extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.unRestrictCommand(command, commandContext.getUserInitiatedContext().getServer());
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -17,6 +17,7 @@ import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.FeatureFlagService;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -41,6 +42,9 @@ public class AllowRole extends AbstractConditionableCommand {
@Autowired
private FeatureFlagService featureFlagService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -52,7 +56,7 @@ public class AllowRole extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.allowCommandForRole(command, role);
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -16,6 +16,7 @@ import dev.sheldan.abstracto.core.config.features.CoreFeatures;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -37,6 +38,9 @@ public class DisAllowRole extends AbstractConditionableCommand {
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -50,7 +54,7 @@ public class DisAllowRole extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.disAllowCommandForRole(command, role);
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -16,6 +16,7 @@ import dev.sheldan.abstracto.core.config.features.CoreFeatures;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -37,6 +38,9 @@ public class MakeAffected extends AbstractConditionableCommand {
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -50,7 +54,7 @@ public class MakeAffected extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.makeRoleAffectedByCommand(command, role);
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -16,6 +16,7 @@ import dev.sheldan.abstracto.core.config.features.CoreFeatures;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -37,6 +38,9 @@ public class MakeImmune extends AbstractConditionableCommand {
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -50,7 +54,7 @@ public class MakeImmune extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.makeRoleImmuneForCommand(command, role);
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -15,6 +15,7 @@ import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.config.features.CoreFeatures;
import dev.sheldan.abstracto.core.models.database.AFeature;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -36,6 +37,9 @@ public class Restrict extends AbstractConditionableCommand {
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private TemplateService templateService;
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
@@ -48,7 +52,7 @@ public class Restrict extends AbstractConditionableCommand {
ACommand command = commandManagementService.findCommandByName(name);
commandService.restrictCommand(command, commandContext.getUserInitiatedContext().getServer());
} else {
return CommandResult.fromError("No Feature/Command with that name");
return CommandResult.fromError(templateService.renderTemplate("no_feature_command_found", new Object()));
}
return CommandResult.fromSuccess();
}

View File

@@ -0,0 +1 @@
<#include "could_not_find_role_text">

View File

@@ -0,0 +1 @@
<#include "no_custom_emote_found_text">

View File

@@ -0,0 +1 @@
<#include "no_feature_command_found_text">