added unmute command to end all mutes, and remove the current one, this also cancels all running jobs, so we need to store the triggers

enabled voice state cache, as its necessary for voice state operations
kick user out of voice chat, if they are in any
changed unmute date to the the effective date of the unmute, instead of the planned date
added possibility to stop a job via the trigger key
This commit is contained in:
Sheldan
2020-04-25 11:10:59 +02:00
parent d4eeb2dadb
commit 7ac2f2ce08
14 changed files with 174 additions and 16 deletions

View File

@@ -48,5 +48,7 @@ public class Mute {
@JoinColumn(name = "mutingChannel")
private AChannel mutingChannel;
private String triggerKey;
}

View File

@@ -10,6 +10,7 @@ import lombok.experimental.SuperBuilder;
import net.dv8tion.jda.api.entities.Member;
import java.time.Duration;
import java.time.Instant;
@Getter
@@ -22,9 +23,17 @@ public class UnMuteLog extends ServerContext {
private Mute mute;
public Duration getMuteDuration() {
return Duration.between(mute.getMuteDate(), Instant.now());
}
public Duration getPlannedMuteDuration() {
return Duration.between(mute.getMuteDate(), mute.getMuteTargetDate());
}
public Instant getUnmuteDate() {
return Instant.now();
}
public String getMessageUrl() {
return MessageUtils.buildMessageUrl(this.mute.getMutingServer().getId() ,this.getMute().getMutingChannel().getId(), this.mute.getMessageId());
}

View File

@@ -15,7 +15,10 @@ public interface MuteService {
Mute muteUser(FullUser userToMute, FullUser userMuting, String reason, Instant unmuteDate, Message message);
void applyMuteRole(AUserInAServer aUserInAServer);
void muteMemberWithLog(Member memberToMute, Member memberMuting, String reason, Instant unmuteDate, MuteLog log, Message message);
void startUnmuteJobFor(Instant unmuteDate, Mute mute);
String startUnmuteJobFor(Instant unmuteDate, Mute mute);
void cancelUnmuteJob(Mute mute);
void unmuteUser(Mute mute);
void endMute(Long muteId);
void completelyUnmuteUser(AUserInAServer aUserInAServer);
void completelyUnmuteUser(Member member);
}

View File

@@ -3,12 +3,17 @@ package dev.sheldan.abstracto.moderation.service.management;
import dev.sheldan.abstracto.core.models.AServerAChannelMessage;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.moderation.models.database.Mute;
import net.dv8tion.jda.api.entities.Member;
import java.time.Instant;
import java.util.List;
public interface MuteManagementService {
Mute createMute(AUserInAServer aUserInAServer, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage creation);
Mute findMute(Long muteId);
Mute saveMute(Mute mute);
boolean hasActiveMute(AUserInAServer userInAServer);
Mute getAMuteOf(AUserInAServer userInAServer);
Mute getAMuteOf(Member userInAServer);
List<Mute> getAllMutesOf(AUserInAServer aUserInAServer);
}