refactored command responses to use a central place for configuration in an extra module

fixed makeAffected role parameter
made command check name case insensitive
added name to parameter for decayAllWarnings
removed simple log from message edited listener
This commit is contained in:
Sheldan
2020-04-30 22:29:49 +02:00
parent d5482fabd4
commit 59dc8c602a
312 changed files with 284 additions and 154 deletions

View File

@@ -30,7 +30,7 @@ public class CommandManagementServiceBean implements CommandManagementService {
public ACommand createCommand(String name, AModule module, AFeature feature) {
ACommand command = ACommand
.builder()
.name(name)
.name(name.toLowerCase())
.module(module)
.feature(feature)
.build();
@@ -40,7 +40,7 @@ public class CommandManagementServiceBean implements CommandManagementService {
@Override
public ACommand findCommandByName(String name) {
return commandRepository.findByName(name);
return commandRepository.findByName(name.toLowerCase());
}
@Override

View File

@@ -40,8 +40,7 @@ public class MakeAffected extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
String name = (String) commandContext.getParameters().getParameters().get(0);
Long roleId = (Long) commandContext.getParameters().getParameters().get(1);
ARole role = roleManagementService.findRole(roleId);
ARole role = (ARole) commandContext.getParameters().getParameters().get(1);
if(featureManagementService.featureExists(name)) {
AFeature feature = featureManagementService.getFeature(name);
feature.getCommands().forEach(command ->

View File

@@ -1,12 +0,0 @@
package dev.sheldan.abstracto.core.repository;
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface FeatureJobTriggerRepository extends JpaRepository<AFeatureJobTrigger, Long> {
List<AFeatureJobTrigger> findByFeature(AFeatureFlag featureFlag);
}

View File

@@ -1 +0,0 @@
Adds the mentioned channel to the channel group identified by the name.

View File

@@ -1 +0,0 @@
Allows the command or feature to be executed by everyone regardless of role.

View File

@@ -1 +0,0 @@
This causes the role checks for each command in the feature/for the given command to be disabled.

View File

@@ -1 +0,0 @@
Allows the given role to execute the commands in the given feature or the command.

View File

@@ -1,4 +0,0 @@
Allows the role to execute all commands in the given feature or the command directly.
In case the names coincide, the the feature will be taken first. The restriction of commands to certain roles is only in effect, if the command is restricted (see `restrict`).
When executing this command, the affected commands are automatically set to restricted.
The provided role can either be a role ID or a the mention of the role.

View File

@@ -1 +0,0 @@
Adds the mentioned channel to the channel group identified by the name.

View File

@@ -1,5 +0,0 @@
Forbids the role to execute all commands in the given feature or the command directly.
Does nothing in case the role was not allowed in the first place.
In case the names coincide, the the feature will be taken first. The restriction of commands to certain roles is only in effect, if the command is restricted (see `restrict`).
When executing this command, the affected commands are automatically set to restricted.
The provided role can either be a role ID or a the mention of the role.

View File

@@ -1 +1 @@
The following features are available: ${features?join(", ")}
<#assign featureString>${features?join(", ")}</#assign><#include "disable_available_features">

View File

@@ -1,3 +0,0 @@
Disables name of the given feature. If no feature is given, it will print the currently known features.
This does not work retroactively, and does not remove any date associated with the feature.
This will prevent commands of the feature being used.

View File

@@ -1,2 +0,0 @@
Makes it impossible to execute a command in a channel group.
A command is considered disabled for a given channel, if the command is disabled in all channel groups the channel is part of.

View File

@@ -1 +1 @@
The following features are available: ${features?join(", ")}
<#assign featureString>${features?join(", ")}</#assign><#include "enable_available_features">

View File

@@ -1,2 +0,0 @@
Used to enable a feature of the server. If no feature is passed, this will print all the currently known features.
This will make it possible that the commands contained in this feature will be executed again.

View File

@@ -1,2 +0,0 @@
Makes it possible to execute a command in a channel group.
A command is considered enabled for a given channel, if the command is enabled in one channel group the channel is part of.

View File

@@ -1 +0,0 @@
Lists all currently known features and their current status.

View File

@@ -1 +0,0 @@
This will print all the currently known features and whether they are enabled on this server or not.

View File

@@ -1,6 +1,6 @@
{
"title": {
"title": "Currently available features"
"title": "<#include "features_embed_title">"
},
"color" : {
"r": 200,
@@ -9,7 +9,7 @@
},
"description": "
<#list features as feature>
${feature.featureFlag.enabled?string('✅', '❌')} **<#include "${feature.featureConfig.feature.key}_feature">** Key: `${feature.featureConfig.feature.key}`
${feature.featureFlag.enabled?string('✅', '❌')} **<#include "${feature.featureConfig.feature.key}_feature">** <#include "feature_embed_key">: `${feature.featureConfig.feature.key}`
</#list>
"
}

View File

@@ -1,48 +1,46 @@
{
"title": {
"title": "Help - Command ${command.name} details"
"title": "<#include "help_command_embed_title">"
},
"color" : {
"r": 200,
"g": 0,
"b": 255
},
"description": "Name: **${command.name}**
Description: <#if command.templated >
<#include "${command.name}_description">
<#else>
${command.description}
</#if>
"description": "<#include "help_command_embed_command_name">: **${command.name}**
<#include "help_command_embed_command_description">: <#if command.templated> <#include "${command.name}_description"> <#else> ${command.description} </#if>
<#if command.help??>
<#if command.help.templated>
Usage: `<#include "${command.name}_usage">`
Detailed help: <#include "${command.name}_long_help">
<#include "help_command_embed_command_usage">: `<#include "${command.name}_usage">`
<#include "help_command_embed_command_detailed_help">: <#include "${command.name}_long_help">
<#else>
Usage: `${command.help.usage}`
Detailed help: ${command.help.longHelp}
<#include "help_command_embed_command_usage">: `${command.help.usage}`
<#include "help_command_embed_command_detailed_help">: ${command.help.longHelp}
</#if>
<#if command.aliases?? && command.aliases?size gt 0>
Aliases: `${command.aliases?join("`, `")}`
<#include "help_command_embed_command_aliases">: `${command.aliases?join("`, `")}`
</#if>
Restrictions:
<#include "help_command_embed_command_description">:
<#if restricted?? && restricted>
Executable by:<#if allowedRoles??> <#list allowedRoles as allowedRole> ${allowedRole.asMention}<#sep>or<#else>Nobody</#list> </#if>
<#if immuneRoles?? > Immune roles: <#list immuneRoles as immuneRole> ${immuneRole.asMention}<#sep>or<#else>None</#list> </#if>
<#include "help_command_embed_command_description"><#if allowedRoles??> <#list allowedRoles as allowedRole> ${allowedRole.asMention}<#sep><#include "help_command_embed_or"><#else><#include "help_command_embed_command_executable_by_nobody"></#list> </#if>
<#if immuneRoles?? ><#include "help_command_embed_command_immune">: <#list immuneRoles as immuneRole> ${immuneRole.asMention}<#sep><#include "help_command_embed_or"><#else>None</#list> </#if>
<#else>
Not restricted
<#include "help_command_embed_command_not_restricted">
</#if>
</#if>
Parameters:
<#include "help_command_embed_command_parameters">:
<#if command.parameters??>
<#list command.parameters as parameter>
${parameter.name}: ${(parameter.description)!""}
Optional: ${parameter.optional?string('yes', 'no')}
<#include "help_command_embed_command_description"> `${parameter.name}`: ${(parameter.description)!""}
<#include "help_command_embed_command_optional"><#sep>
<#else>
No parameters
<#include "help_command_embed_command_no_parameters">
</#list>
<#else>
No parameters
<#include "help_command_embed_command_no_parameters">
</#if>
"
}

View File

@@ -1,4 +0,0 @@
Provides support on how to use the commands.
Gives an overview in which modules the commands are and what commands are available.
Displays descriptions about commands and detailed information how to use them.
If no parameter is provided, displays all the currently known modules and description.

View File

@@ -1,6 +1,7 @@
{
<#assign name>${module.moduleInterface.info.name}</#assign>
"title": {
"title": "Help - Module ${module.moduleInterface.info.name} details"
"title": "<#include "help_module_embed_title">"
},
"color" : {
"r": 200,
@@ -8,15 +9,15 @@
"b": 255
},
"description": "
Module name: **${module.moduleInterface.info.name}**
Description: ${module.moduleInterface.info.description}
Commands:
<#include "help_module_embed_module_name">: **${module.moduleInterface.info.name}**
<#include "help_module_embed_module_description">: ${module.moduleInterface.info.description}
<#include "help_module_embed_commands">:
<#list module.commands as command>`${command.configuration.name}`<#sep>, </#list>
<#if module.subModules??>
Submodules: <#list module.subModules as module>`${module.info.name}`<#sep>, </#list>
<#include "help_module_embed_sub_modules">: <#list module.subModules as module>`${module.info.name}`<#sep>, </#list>
</#if>
",
"footer": {
"text": "Use 'help <command name>' for a detailed overview of this command."
"text": "<#include "help_command_embed_hint_footer">"
}
}

View File

@@ -1,6 +1,6 @@
{
"title": {
"title": "Help - Module overview"
"title": "<#include "help_modules_embed_title">"
},
"color" : {
"r": 200,
@@ -9,11 +9,11 @@
},
"description": "
<#list modules as module>
Module name: **${module.info.name}**
Description: ${module.info.description}
<#include "help_module_embed_module_name">: **${module.info.name}**
<#include "help_module_embed_module_description">: ${module.info.description}
</#list>
",
"footer": {
"text": "Use 'help <module name>' for a list of commands of this module."
"text": "<#include "help_modules_embed_footer_hint">"
}
}

View File

@@ -1 +0,0 @@
This will list all the currently known channel groups and the respective channels contained in the group.

View File

@@ -1,12 +1,15 @@
{
"title": {
"title": "Current configured channel groups"
"title": "<#include "listChannelGroups_embed_title">"
},
"color" : {
"r": 200,
"g": 0,
"b": 255
},
<#if groups?size = 0>
"description": "<#include "listChannelGroups_no_channel_group">",
</#if>
"fields": [
<#list groups as group>
{
@@ -18,6 +21,7 @@
</#list>
"
}<#sep>,
<#else>
</#list>
]
}

View File

@@ -1,5 +0,0 @@
Makes the given role affected by certain commands like `ban`, `warn` or `mute`.
When a feature name is used, all commands of this feature will be changed.
Not all commands actually support this functionality.
By default all roles are affected by the commands.
The provided role can either be a role ID or a the mention of the role.

View File

@@ -1 +0,0 @@
Makes a role immune against certain commands/complete features

View File

@@ -1,5 +0,0 @@
Makes the given role immune to certain commands like `ban`, `warn` or `mute`.
When a feature name is used, all commands of this feature will be changed.
Not all commands actually support this functionality.
By default all roles are affected by the commands.
The provided role can either be a role ID or a the mention of the role.

View File

@@ -1 +0,0 @@
Prints the time in milliseconds of the last heartbeat request.

View File

@@ -1 +1 @@
Latency: ${latency} ms.
<#include "ping_latency_response">

View File

@@ -1 +1 @@
The provided post target is invalid. <#include "posttarget_no_target">
<#include "posttarget_invalid_post_target_response"> <#include "posttarget_no_target">

View File

@@ -1,2 +0,0 @@
Sets the target of the given posts to a channel. You have to mention the channel with #.
The available post targets will be printed when executed with no parameters.

View File

@@ -1 +1 @@
The available post targets are: ${validPostTargets?join(", ")}
<#include "posttarget_available_post_targets">: ${validPostTargets?join(", ")}.

View File

@@ -1 +0,0 @@
Removes the mentioned channel from the channel group identified by the name.

View File

@@ -1,3 +0,0 @@
Makes the command affected by role restrictions.
If a command is not restricted, any role is able to execute it, even though there are certain roles allowed to execute it.
If a feature name is given, all the commands in the feature are getting restricted.

View File

@@ -1 +0,0 @@
The bot uses certain when doing certain actions. This command can be used to redefine these emotes.

View File

@@ -1 +0,0 @@
Changes the value of a numerical value of the bots configuration

View File

@@ -1 +0,0 @@
Sets a numerical value in the bots configuration to the given value.

View File

@@ -1,2 +0,0 @@
Changes the prefix of the bot on this server. This effect is immediate.
This prefix can also be multiple characters.

View File

@@ -1 +1 @@
User ${user.name}#${user.discriminator} (${user.asMention}) has joined the guild.
<#assign user>${user.name}#${user.discriminator} (${user.asMention})</#assign><#include "user_joined_text">

View File

@@ -1 +1 @@
User ${user.name}#${user.discriminator} (${userMention}) has left the guild.
<#assign user>${user.name}#${user.discriminator} (${user.asMention})</#assign><#include "user_left_text">