mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-20 13:26:50 +00:00
[AB-xxx] reworking mute logging to use audit log events instead of active logging and member update events
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
package dev.sheldan.abstracto.moderation.model.template.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||
import dev.sheldan.abstracto.core.utils.MessageUtils;
|
||||
import dev.sheldan.abstracto.moderation.model.database.Mute;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* Used when rendering the notification when a member was muted. The template is: "unmute_log_embed"
|
||||
*/
|
||||
@Getter
|
||||
@SuperBuilder
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UnMuteLog {
|
||||
/**
|
||||
* The un-muted Member, is null if the member left the server
|
||||
*/
|
||||
private MemberDisplay unMutedUser;
|
||||
/**
|
||||
* The user casting the mute, is null if the member left the server
|
||||
*/
|
||||
private MemberDisplay mutingUser;
|
||||
/**
|
||||
* The persisted mute object from the database containing the information about the mute
|
||||
*/
|
||||
private Mute mute;
|
||||
|
||||
/**
|
||||
* The actual duration between the date the mute started and the current time
|
||||
* @return The difference between mute start and now
|
||||
*/
|
||||
public Duration getMuteDuration() {
|
||||
return Duration.between(mute.getMuteDate(), Instant.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* The duration between the date the mute started and the un-mute planned
|
||||
* @return The difference between mute start and the target date
|
||||
*/
|
||||
public Duration getPlannedMuteDuration() {
|
||||
return Duration.between(mute.getMuteDate(), mute.getMuteTargetDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* The un-mute date, which is now, because this is the un-mute log message.
|
||||
* @return The current time stamp
|
||||
*/
|
||||
public Instant getUnmuteDate() {
|
||||
return Instant.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the link to the original message triggering the mute
|
||||
* @return A string containing an URL leading to the message where the mute was triggered
|
||||
*/
|
||||
public String getMessageUrl() {
|
||||
if(this.mute.getMessageId() != null && this.mute.getMutingChannel() != null) {
|
||||
return MessageUtils.buildMessageUrl(this.mute.getServer().getId(), this.mute.getMutingChannel().getId(), this.mute.getMessageId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user