mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-13 19:41:38 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Adds channels to a channel group.
|
||||
@@ -1 +0,0 @@
|
||||
Adds the mentioned channel to the channel group identified by the name.
|
||||
@@ -1 +0,0 @@
|
||||
addToChannelGroup <name> <channel>
|
||||
@@ -1 +0,0 @@
|
||||
Allows the command or feature to be executed by everyone regardless of role.
|
||||
@@ -1 +0,0 @@
|
||||
This causes the role checks for each command in the feature/for the given command to be disabled.
|
||||
@@ -1 +0,0 @@
|
||||
allow <command/feature>
|
||||
@@ -1 +0,0 @@
|
||||
Allows the given role to execute the commands in the given feature or the command.
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
allowRole <command/feature> <role>
|
||||
@@ -1 +0,0 @@
|
||||
Adds the given channelIds to the channel group of the given name.
|
||||
@@ -1 +0,0 @@
|
||||
Adds the mentioned channel to the channel group identified by the name.
|
||||
@@ -1 +0,0 @@
|
||||
addToChannelGroup <name> <channel>
|
||||
@@ -1 +0,0 @@
|
||||
Deletes a channel group
|
||||
@@ -1 +0,0 @@
|
||||
Deletes the channel group identified by the name.
|
||||
@@ -1 +0,0 @@
|
||||
deleteChannelGroup <name>
|
||||
@@ -1 +0,0 @@
|
||||
Forbids a role to use a command.
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
disAllowRole <command/feature> <role>
|
||||
@@ -1 +0,0 @@
|
||||
Completely disables a feature for the server.
|
||||
@@ -1 +1 @@
|
||||
The following features are available: ${features?join(", ")}
|
||||
<#assign featureString>${features?join(", ")}</#assign><#include "disable_available_features">
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
disable [featureName]
|
||||
@@ -1 +0,0 @@
|
||||
Disables a command in a channel group.
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
disableCommand <commandName> <channelGroupName>
|
||||
@@ -1 +0,0 @@
|
||||
Echos the input back to the same channel
|
||||
@@ -1 +0,0 @@
|
||||
Echos back the text put in
|
||||
@@ -1 +0,0 @@
|
||||
echo <text>
|
||||
@@ -1 +0,0 @@
|
||||
Enables a feature in the server.
|
||||
@@ -1 +1 @@
|
||||
The following features are available: ${features?join(", ")}
|
||||
<#assign featureString>${features?join(", ")}</#assign><#include "enable_available_features">
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
enable [featureName]
|
||||
@@ -1 +0,0 @@
|
||||
Enables a command in a channel group.
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
enableCommand <commandName> <channelGroupName>
|
||||
@@ -1 +0,0 @@
|
||||
Lists all currently known features and their current status.
|
||||
@@ -1 +0,0 @@
|
||||
This will print all the currently known features and whether they are enabled on this server or not.
|
||||
@@ -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>
|
||||
"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
features
|
||||
@@ -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>
|
||||
"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Provides help on how to use certain commands.
|
||||
@@ -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.
|
||||
@@ -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">"
|
||||
}
|
||||
}
|
||||
@@ -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">"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
help <module/command>
|
||||
@@ -1 +0,0 @@
|
||||
Lists all currently existing channel groups.
|
||||
@@ -1 +0,0 @@
|
||||
This will list all the currently known channel groups and the respective channels contained in the group.
|
||||
@@ -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>
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
listChannelGroups
|
||||
@@ -1 +0,0 @@
|
||||
Makes a role affected by certain commands/features
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
makeAffected <feature/command> <role>
|
||||
@@ -1 +0,0 @@
|
||||
Makes a role immune against certain commands/complete features
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
makeImmune <feature/command> <role>
|
||||
@@ -1 +0,0 @@
|
||||
Prints the latency between the bot and discord.
|
||||
@@ -1 +0,0 @@
|
||||
Prints the time in milliseconds of the last heartbeat request.
|
||||
@@ -1 +1 @@
|
||||
Latency: ${latency} ms.
|
||||
<#include "ping_latency_response">
|
||||
@@ -1 +0,0 @@
|
||||
ping
|
||||
@@ -1 +0,0 @@
|
||||
Sets the target of the given posts to a channel.
|
||||
@@ -1 +1 @@
|
||||
The provided post target is invalid. <#include "posttarget_no_target">
|
||||
<#include "posttarget_invalid_post_target_response"> <#include "posttarget_no_target">
|
||||
@@ -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.
|
||||
@@ -1 +1 @@
|
||||
The available post targets are: ${validPostTargets?join(", ")}
|
||||
<#include "posttarget_available_post_targets">: ${validPostTargets?join(", ")}.
|
||||
@@ -1 +0,0 @@
|
||||
posttarget <target> <channel>
|
||||
@@ -1 +0,0 @@
|
||||
Removes channels from a channel group.
|
||||
@@ -1 +0,0 @@
|
||||
Removes the mentioned channel from the channel group identified by the name.
|
||||
@@ -1 +0,0 @@
|
||||
removeFromChannelGroup <name> <channel>
|
||||
@@ -1 +0,0 @@
|
||||
Restricts a command/feature.
|
||||
@@ -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.
|
||||
@@ -1 +0,0 @@
|
||||
restrict <command/feature>
|
||||
@@ -1 +0,0 @@
|
||||
Changes the emotes used by the bot
|
||||
@@ -1 +0,0 @@
|
||||
The bot uses certain when doing certain actions. This command can be used to redefine these emotes.
|
||||
@@ -1 +0,0 @@
|
||||
setEmote <key> <emote>
|
||||
@@ -1 +0,0 @@
|
||||
Changes the value of a numerical value of the bots configuration
|
||||
@@ -1 +0,0 @@
|
||||
Sets a numerical value in the bots configuration to the given value.
|
||||
@@ -1 +0,0 @@
|
||||
setNumber <configKey> <value>
|
||||
@@ -1 +0,0 @@
|
||||
Changes the prefix of the bot
|
||||
@@ -1,2 +0,0 @@
|
||||
Changes the prefix of the bot on this server. This effect is immediate.
|
||||
This prefix can also be multiple characters.
|
||||
@@ -1 +0,0 @@
|
||||
setPrefix <newPrefix>
|
||||
@@ -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">
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user