[AB-104] adding server wide member individual command cooldown and commands to set/reset this cooldown configuration on a command level

removing custom cooldown handling from payday and slots commands
This commit is contained in:
Sheldan
2023-09-06 01:23:55 +02:00
parent 156725afa6
commit 73a73dc4f2
28 changed files with 345 additions and 141 deletions

View File

@@ -6,6 +6,7 @@ import lombok.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
@@ -51,6 +52,9 @@ public class ACommandInAServer implements Serializable {
@Column(name = "slash_command_id")
private Long slashCommandId;
@Column(name = "member_cooldown")
private Duration memberCooldown;
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;

View File

@@ -10,9 +10,11 @@ import dev.sheldan.abstracto.core.command.model.database.ACommand;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AServer;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
public interface CommandService {
@@ -30,4 +32,5 @@ public interface CommandService {
UnParsedCommandParameter getUnParsedCommandParameter(String messageContent, Message message);
CompletableFuture<Parameters> getParametersForCommand(String commandName, Message messageContainingContent);
Parameter cloneParameter(Parameter parameter);
void setServerCooldownTo(String commandName, Guild guild, Duration duration);
}

View File

@@ -4,6 +4,7 @@ import dev.sheldan.abstracto.core.command.model.database.ACommand;
import dev.sheldan.abstracto.core.command.model.database.ACommandInAServer;
import dev.sheldan.abstracto.core.models.database.AServer;
import java.time.Duration;
import java.util.List;
public interface CommandInServerManagementService {
@@ -11,6 +12,7 @@ public interface CommandInServerManagementService {
ACommandInAServer createCommandInServer(ACommand command, AServer server, Long commandId);
boolean doesCommandExistInServer(ACommand command, AServer server);
ACommandInAServer getCommandForServer(ACommand command, AServer server);
void setCooldownForCommandInServer(ACommand command, AServer server, Duration duration);
ACommandInAServer getCommandForServer(ACommand command, Long serverId);
ACommandInAServer getCommandForServer(Long commandInServerId);
List<ACommandInAServer> getCommandsForServer(List<Long> commandInServerId);

View File

@@ -3,6 +3,7 @@ package dev.sheldan.abstracto.core.interaction.slash;
public class CoreSlashCommandNames {
public static final String UTILITY = "utility";
public static final String CONFIG = "config";
public static final String COOLDOWN = "cooldown";
public static final String FEATURE = "feature";
public static final String CHANNELS = "channels";
public static final String POST_TARGET = "posttarget";