mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-25 22:58:12 +00:00
[AB-150] creating repost detection feature including configuration and documentation
adding http and hash service adding ability to add default emotes to a message to message service adding message embedded listener to wrap the embedded event adding custom channel groups which can be defined by modules, in case a change on a channel group (only created and updated) happens a listener is available in order to sync the state in dependant areas changing command receiver re-throwing abstracto runtime exceptions in order to display them better changing channel group parameter handler to throw an exception in case the channel group was not found adding User in a server parameter handler split channel not found exception to be able to differentiate between not found in database and not found in guild changing exception handling in command received handler to handle the case for only one parameter handler future which failed (the whole single future failed, which was not reported) changing parameter type of `removeFromChannelGroup` to AChannel in order to be able to delete channels in the database via ID moving method to mock utils for mocking consumer removing parameter validation from commands, as it should be done in the command received handler and parameter handlers anyway
This commit is contained in:
@@ -34,7 +34,6 @@ public class Ban extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
String defaultReason = templateService.renderSimpleTemplate(BAN_DEFAULT_REASON_TEMPLATE);
|
||||
|
||||
@@ -29,7 +29,6 @@ public class BanId extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Long userId = (Long) parameters.get(0);
|
||||
String defaultReason = templateService.renderSimpleTemplate(Ban.BAN_DEFAULT_REASON_TEMPLATE);
|
||||
|
||||
@@ -25,7 +25,6 @@ public class DecayAllWarnings extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
return warnService.decayAllWarningsForServer(commandContext.getUserInitiatedContext().getServer())
|
||||
.thenApply(aVoid -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public class DeleteNote extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Long id = (Long) commandContext.getParameters().getParameters().get(0);
|
||||
if(userNoteManagementService.noteExists(id, commandContext.getUserInitiatedContext().getServer())) {
|
||||
userNoteManagementService.deleteNote(id, commandContext.getUserInitiatedContext().getServer());
|
||||
|
||||
@@ -29,7 +29,6 @@ public class DeleteWarning extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Long warnId = (Long) commandContext.getParameters().getParameters().get(0);
|
||||
Optional<Warning> optional = warnManagementService.findByIdOptional(warnId, commandContext.getGuild().getIdLong());
|
||||
optional.ifPresent(warning -> warnManagementService.deleteWarning(warning));
|
||||
|
||||
@@ -32,7 +32,6 @@ public class Kick extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
String defaultReason = templateService.renderSimpleTemplate(KICK_DEFAULT_REASON_TEMPLATE);
|
||||
|
||||
@@ -37,7 +37,6 @@ public class Purge extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Integer amountOfMessages = (Integer) commandContext.getParameters().getParameters().get(0);
|
||||
Member memberToPurgeMessagesOf = null;
|
||||
if(commandContext.getParameters().getParameters().size() == 2) {
|
||||
|
||||
@@ -28,7 +28,6 @@ public class SlowMode extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
TextChannel channel;
|
||||
String durationString = (String) commandContext.getParameters().getParameters().get(0);
|
||||
Duration duration;
|
||||
|
||||
@@ -30,7 +30,6 @@ public class UserNoteCommand extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
String text = (String) parameters.get(1);
|
||||
|
||||
@@ -49,7 +49,6 @@ public class UserNotes extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
List<UserNote> userNotes;
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ public class Warn extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
String defaultReason = templateService.renderSimpleTemplate(WARN_DEFAULT_REASON_TEMPLATE);
|
||||
|
||||
@@ -52,7 +52,6 @@ public class Warnings extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Warning> warnsToDisplay;
|
||||
if(!commandContext.getParameters().getParameters().isEmpty()) {
|
||||
Member member = (Member) commandContext.getParameters().getParameters().get(0);
|
||||
|
||||
@@ -31,7 +31,6 @@ public class Mute extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
Duration duration = (Duration) parameters.get(1);
|
||||
|
||||
@@ -30,7 +30,6 @@ public class SetMuteRole extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
Role jdaRole = (Role) commandContext.getParameters().getParameters().get(0);
|
||||
ARole role = roleManagementService.findRole(jdaRole.getIdLong());
|
||||
muteRoleManagementService.setMuteRoleForServer(commandContext.getUserInitiatedContext().getServer(), role);
|
||||
|
||||
@@ -39,7 +39,6 @@ public class UnMute extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
checkParameters(commandContext);
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Member member = (Member) parameters.get(0);
|
||||
AUserInAServer userToUnMute = userInServerManagementService.loadUser(member);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.moderation.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.ChannelNotFoundException;
|
||||
import dev.sheldan.abstracto.core.exception.ChannelNotInGuildException;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.service.BotService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -41,7 +41,7 @@ public class SlowModeServiceBean implements SlowModeService {
|
||||
TextChannel textChannel = textChannelOptional.get();
|
||||
return this.setSlowMode(textChannel, duration);
|
||||
} else {
|
||||
throw new ChannelNotFoundException(channel.getId());
|
||||
throw new ChannelNotInGuildException(channel.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user