mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-13 19:41:38 +00:00
fixed command and feature mapping
added a bunch of java doc to moderation interface added check in case the text channel on the server was deleted while the mod mail thread was still open This now returns an error to the user side and prompts to message the bot again in order to create a new mod mail thread
This commit is contained in:
@@ -24,18 +24,18 @@ public class MuteManagementServiceBean implements MuteManagementService {
|
|||||||
private UserInServerManagementService userInServerManagementService;
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mute createMute(AUserInAServer aUserInAServer, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage origin) {
|
public Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage muteMessage) {
|
||||||
log.trace("Creating mute for user {} executed by user {} in server {}, user will be unmuted at {}",
|
log.trace("Creating mute for user {} executed by user {} in server {}, user will be unmuted at {}",
|
||||||
aUserInAServer.getUserReference().getId(), mutingUser.getUserReference().getId(), aUserInAServer.getServerReference().getId(), unmuteDate);
|
mutedUser.getUserReference().getId(), mutingUser.getUserReference().getId(), mutedUser.getServerReference().getId(), unmuteDate);
|
||||||
Mute mute = Mute
|
Mute mute = Mute
|
||||||
.builder()
|
.builder()
|
||||||
.muteDate(Instant.now())
|
.muteDate(Instant.now())
|
||||||
.mutedUser(aUserInAServer)
|
.mutedUser(mutedUser)
|
||||||
.mutingUser(mutingUser)
|
.mutingUser(mutingUser)
|
||||||
.muteTargetDate(unmuteDate)
|
.muteTargetDate(unmuteDate)
|
||||||
.mutingServer(aUserInAServer.getServerReference())
|
.mutingServer(mutedUser.getServerReference())
|
||||||
.mutingChannel(origin.getChannel())
|
.mutingChannel(muteMessage.getChannel())
|
||||||
.messageId(origin.getMessageId())
|
.messageId(muteMessage.getMessageId())
|
||||||
.reason(reason)
|
.reason(reason)
|
||||||
.muteEnded(false)
|
.muteEnded(false)
|
||||||
.build();
|
.build();
|
||||||
@@ -65,8 +65,8 @@ public class MuteManagementServiceBean implements MuteManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mute getAMuteOf(Member userInAServer) {
|
public Mute getAMuteOf(Member member) {
|
||||||
return getAMuteOf(userInServerManagementService.loadUser(userInAServer));
|
return getAMuteOf(userInServerManagementService.loadUser(member));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import javax.persistence.*;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table used to store mutes in order to track when the mute was cast and when it ended.
|
||||||
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="mute")
|
@Table(name="mute")
|
||||||
@Builder
|
@Builder
|
||||||
@@ -18,37 +21,70 @@ import java.util.Objects;
|
|||||||
@Setter
|
@Setter
|
||||||
public class Mute {
|
public class Mute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The globally unique id of the mute.
|
||||||
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AUserInAServer} which was muted
|
||||||
|
*/
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "mutedUser", nullable = false)
|
@JoinColumn(name = "mutedUser", nullable = false)
|
||||||
private AUserInAServer mutedUser;
|
private AUserInAServer mutedUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AUserInAServer} which casted the mute
|
||||||
|
*/
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "mutingUser", nullable = false)
|
@JoinColumn(name = "mutingUser", nullable = false)
|
||||||
private AUserInAServer mutingUser;
|
private AUserInAServer mutingUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reason of the mute which is stored
|
||||||
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date when the mute was cast, and the start date
|
||||||
|
*/
|
||||||
private Instant muteDate;
|
private Instant muteDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date at which this mute should be removed in the future
|
||||||
|
*/
|
||||||
private Instant muteTargetDate;
|
private Instant muteTargetDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the mute already ended, be it manually or when the time passed
|
||||||
|
*/
|
||||||
private Boolean muteEnded;
|
private Boolean muteEnded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message which contained the command which caused this mute
|
||||||
|
*/
|
||||||
@Column
|
@Column
|
||||||
private Long messageId;
|
private Long messageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AServer} in which this mute was cast
|
||||||
|
*/
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "mutingServer", nullable = false)
|
@JoinColumn(name = "mutingServer", nullable = false)
|
||||||
private AServer mutingServer;
|
private AServer mutingServer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The channel in which this mute was cast
|
||||||
|
*/
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "mutingChannel")
|
@JoinColumn(name = "mutingChannel")
|
||||||
private AChannel mutingChannel;
|
private AChannel mutingChannel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the mute is scheduled to be un-done with quartz, this stores the quartz trigger in order to cancel it, if need be.
|
||||||
|
*/
|
||||||
private String triggerKey;
|
private String triggerKey;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import javax.persistence.*;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A warning which was given a member with a special reason by a moderating member. This warning is bound to a server.
|
||||||
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="warning")
|
@Table(name="warning")
|
||||||
@Builder
|
@Builder
|
||||||
@@ -14,31 +17,52 @@ import java.util.Objects;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class Warning {
|
public class Warning {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The globally unique id of this warning
|
||||||
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Getter
|
@Getter
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AUserInAServer} which was warned
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "warnedUserId", nullable = false)
|
@JoinColumn(name = "warnedUserId", nullable = false)
|
||||||
private AUserInAServer warnedUser;
|
private AUserInAServer warnedUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link AUserInAServer} which gave the warning
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "warningUserId", nullable = false)
|
@JoinColumn(name = "warningUserId", nullable = false)
|
||||||
private AUserInAServer warningUser;
|
private AUserInAServer warningUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reason why this warning was cast
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date at which the warning was cast
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private Instant warnDate;
|
private Instant warnDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the warning was already decayed and is not active anymore
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Boolean decayed;
|
private Boolean decayed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date at which the warning was decayed
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Instant decayDate;
|
private Instant decayDate;
|
||||||
|
|||||||
@@ -6,12 +6,26 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was banned by ID. The template is: "banid_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
public class BanIdLog extends UserInitiatedServerContext {
|
public class BanIdLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The reason of the ban
|
||||||
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The member executing the ban
|
||||||
|
*/
|
||||||
private Member banningUser;
|
private Member banningUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Discord Snowflake of the user being banned.
|
||||||
|
*/
|
||||||
private Long bannedUserId;
|
private Long bannedUserId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,24 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was banned. The template is: "ban_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
public class BanLog extends UserInitiatedServerContext {
|
public class BanLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The reason of the ban
|
||||||
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
/**
|
||||||
|
* The member executing the ban
|
||||||
|
*/
|
||||||
private Member banningUser;
|
private Member banningUser;
|
||||||
|
/**
|
||||||
|
* The member being banned
|
||||||
|
*/
|
||||||
private Member bannedUser;
|
private Member bannedUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,23 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was kicked. The template is: "kick_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
public class KickLogModel extends UserInitiatedServerContext {
|
public class KickLogModel extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The reason of the kick
|
||||||
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
/**
|
||||||
|
* The member executing the kick
|
||||||
|
*/
|
||||||
private Member kickingUser;
|
private Member kickingUser;
|
||||||
|
/**
|
||||||
|
* The member being kicked
|
||||||
|
*/
|
||||||
private Member kickedUser;
|
private Member kickedUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,34 @@ import net.dv8tion.jda.api.entities.Message;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was muted. The template is: "mute_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
public class MuteLog extends UserInitiatedServerContext {
|
public class MuteLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The {@link Member} being muted
|
||||||
|
*/
|
||||||
private Member mutedUser;
|
private Member mutedUser;
|
||||||
|
/**
|
||||||
|
* The {@link Member} executing the mute
|
||||||
|
*/
|
||||||
private Member mutingUser;
|
private Member mutingUser;
|
||||||
|
/**
|
||||||
|
* The {@link Message} triggering the command to mute
|
||||||
|
*/
|
||||||
private Message message;
|
private Message message;
|
||||||
|
/**
|
||||||
|
* The persisted mute object from the database containing the information about the mute
|
||||||
|
*/
|
||||||
private Mute mute;
|
private Mute mute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Duration} of the mute between the mute was cast and and the date it should end
|
||||||
|
* @return The {@link Duration} between start and target date
|
||||||
|
*/
|
||||||
public Duration getMuteDuration() {
|
public Duration getMuteDuration() {
|
||||||
return Duration.between(mute.getMuteDate(), mute.getMuteTargetDate());
|
return Duration.between(mute.getMuteDate(), mute.getMuteTargetDate());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,18 @@ import dev.sheldan.abstracto.moderation.models.database.Mute;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to render the message notification send to the member informing about the mute. The template is: "mute_notification"
|
||||||
|
*/
|
||||||
@Value
|
@Value
|
||||||
@Builder
|
@Builder
|
||||||
public class MuteNotification {
|
public class MuteNotification {
|
||||||
|
/**
|
||||||
|
* The persisted mute object from the database containing the information about the mute
|
||||||
|
*/
|
||||||
private Mute mute;
|
private Mute mute;
|
||||||
|
/**
|
||||||
|
* The name of the server in which the user was muted.
|
||||||
|
*/
|
||||||
private String serverName;
|
private String serverName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,19 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to render the response of the myWarnings command. The template is: 'myWarnings_response_embed'
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class MyWarningsModel extends UserInitiatedServerContext {
|
public class MyWarningsModel extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The total amount of warnings the member has
|
||||||
|
*/
|
||||||
private Long totalWarnCount;
|
private Long totalWarnCount;
|
||||||
|
/**
|
||||||
|
* The current (only active) amount of warnings the member has
|
||||||
|
*/
|
||||||
private Long currentWarnCount;
|
private Long currentWarnCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,55 @@ import net.dv8tion.jda.api.entities.Member;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was muted. The template is: "unmute_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UnMuteLog extends ServerContext {
|
public class UnMuteLog extends ServerContext {
|
||||||
|
/**
|
||||||
|
* The un-muted Member, is null if the member left the server
|
||||||
|
*/
|
||||||
private Member unMutedUser;
|
private Member unMutedUser;
|
||||||
|
/**
|
||||||
|
* The user casting the mute, is null if the member left the server
|
||||||
|
*/
|
||||||
private Member mutingUser;
|
private Member mutingUser;
|
||||||
|
/**
|
||||||
|
* The persisted mute object from the database containing the information about the mute
|
||||||
|
*/
|
||||||
private Mute 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() {
|
public Duration getMuteDuration() {
|
||||||
return Duration.between(mute.getMuteDate(), Instant.now());
|
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() {
|
public Duration getPlannedMuteDuration() {
|
||||||
return Duration.between(mute.getMuteDate(), mute.getMuteTargetDate());
|
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() {
|
public Instant getUnmuteDate() {
|
||||||
return Instant.now();
|
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() {
|
public String getMessageUrl() {
|
||||||
return MessageUtils.buildMessageUrl(this.mute.getMutingServer().getId() ,this.getMute().getMutingChannel().getId(), this.mute.getMessageId());
|
return MessageUtils.buildMessageUrl(this.mute.getMutingServer().getId() ,this.getMute().getMutingChannel().getId(), this.mute.getMessageId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,24 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single warning containing the full user instead of only the warning object when the warnings command is executed.
|
||||||
|
* The template is: "warnings_warn_entry"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Builder
|
@Builder
|
||||||
public class WarnEntry {
|
public class WarnEntry {
|
||||||
|
/**
|
||||||
|
* The {@link Warning} of this entry
|
||||||
|
*/
|
||||||
private Warning warning;
|
private Warning warning;
|
||||||
|
/**
|
||||||
|
* The {@link FullUser} containing information about the user being warned. The member property is null if the user left the server
|
||||||
|
*/
|
||||||
private FullUser warnedUser;
|
private FullUser warnedUser;
|
||||||
|
/**
|
||||||
|
* The {@link FullUser} containing information about the user warning. The member property is null if the user left the server
|
||||||
|
*/
|
||||||
private FullUser warningUser;
|
private FullUser warningUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,31 @@ import lombok.experimental.SuperBuilder;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the notification when a member was warned. The template is: "warn_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Setter
|
@Setter
|
||||||
public class WarnLog extends UserInitiatedServerContext {
|
public class WarnLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The reason why the warn was cast
|
||||||
|
*/
|
||||||
private String reason;
|
private String reason;
|
||||||
|
/**
|
||||||
|
* The {@link Member} being warned
|
||||||
|
*/
|
||||||
private Member warnedUser;
|
private Member warnedUser;
|
||||||
|
/**
|
||||||
|
* The {@link Member} casting the warn
|
||||||
|
*/
|
||||||
private Member warningUser;
|
private Member warningUser;
|
||||||
|
/**
|
||||||
|
* The {@link Message} which contained the command triggering the warn
|
||||||
|
*/
|
||||||
private Message message;
|
private Message message;
|
||||||
|
/**
|
||||||
|
* The persisted {@link Warning} object from the database containing the information about the warning
|
||||||
|
*/
|
||||||
private Warning warning;
|
private Warning warning;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,18 @@ import dev.sheldan.abstracto.moderation.models.database.Warning;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to render the message notification send to the member informing about the warn. The template is: "warn_notification"
|
||||||
|
*/
|
||||||
@Value
|
@Value
|
||||||
@Builder
|
@Builder
|
||||||
public class WarnNotification {
|
public class WarnNotification {
|
||||||
|
/**
|
||||||
|
* The persisted mute object from the database containing the information about the warning
|
||||||
|
*/
|
||||||
private Warning warning;
|
private Warning warning;
|
||||||
|
/**
|
||||||
|
* The name of the server on which the warn was cast
|
||||||
|
*/
|
||||||
private String serverName;
|
private String serverName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ import lombok.experimental.SuperBuilder;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to render the paginator used to display all the warnings of a user or all users. The template is: "warnings_response_paginator"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class WarningsModel extends UserInitiatedServerContext {
|
public class WarningsModel extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* A collection of {@link dev.sheldan.abstracto.moderation.models.database.Warning}s being rendered, might be all warnings of the server, or only the warnings of a specific user
|
||||||
|
*/
|
||||||
private List<WarnEntry> warnings;
|
private List<WarnEntry> warnings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ import lombok.experimental.SuperBuilder;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when rendering the log message when warnings were decayed. The template is: "warn_decay_log_embed"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class WarnDecayLogModel extends ServerContext {
|
public class WarnDecayLogModel extends ServerContext {
|
||||||
|
/**
|
||||||
|
* The warnings which were decayed
|
||||||
|
*/
|
||||||
private List<WarnDecayWarning> warnings;
|
private List<WarnDecayWarning> warnings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,24 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single warning containing the full user instead of only the warning object when logging the decayed warnings
|
||||||
|
* The template is: "warnDecay_log_warn_entry_en_US.ftl"
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Builder
|
@Builder
|
||||||
public class WarnDecayWarning {
|
public class WarnDecayWarning {
|
||||||
|
/**
|
||||||
|
* The persisted {@link Warning} object from the database containing the information about the warning
|
||||||
|
*/
|
||||||
private Warning warning;
|
private Warning warning;
|
||||||
|
/**
|
||||||
|
* The member which was warned, is null if the user left the server
|
||||||
|
*/
|
||||||
private Member warnedMember;
|
private Member warnedMember;
|
||||||
|
/**
|
||||||
|
* The user which casted the warn, is null if the user left the server
|
||||||
|
*/
|
||||||
private Member warningMember;
|
private Member warningMember;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,20 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
@Getter @Setter @SuperBuilder
|
/**
|
||||||
|
* Used when rendering the attachment message, when the message contained multiple attachments.
|
||||||
|
* The template is: "message_deleted_attachment_embed"
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
public class MessageDeletedAttachmentLog extends UserInitiatedServerContext {
|
public class MessageDeletedAttachmentLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The proxy URL to the attachment which was deleted.
|
||||||
|
*/
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
|
/**
|
||||||
|
* The index of this attachment in the deleted message.
|
||||||
|
*/
|
||||||
private Integer counter;
|
private Integer counter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,15 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
@Getter @Setter @SuperBuilder
|
/**
|
||||||
|
* Used when rendering the log message when a message was deleted. The template is: "message_deleted_embed"
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
public class MessageDeletedLog extends UserInitiatedServerContext {
|
public class MessageDeletedLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* A {@link CachedMessage} representing the deleted message
|
||||||
|
*/
|
||||||
private CachedMessage message;
|
private CachedMessage message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,20 @@ import lombok.Setter;
|
|||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
|
||||||
@Getter @Setter @SuperBuilder
|
/**
|
||||||
|
* Used when rendering the log message when a message was edited. The template is: "message_edited_embed"
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
public class MessageEditedLog extends UserInitiatedServerContext {
|
public class MessageEditedLog extends UserInitiatedServerContext {
|
||||||
|
/**
|
||||||
|
* The {@link Message} instance which contains the new content of the message
|
||||||
|
*/
|
||||||
private Message messageAfter;
|
private Message messageAfter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link CachedMessage} which contains the message before the edit was made
|
||||||
|
*/
|
||||||
private CachedMessage messageBefore;
|
private CachedMessage messageBefore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,60 @@ import net.dv8tion.jda.api.entities.Member;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responsible for creating/updating/retrieving mutes in the database.
|
||||||
|
*/
|
||||||
public interface MuteManagementService {
|
public interface MuteManagementService {
|
||||||
Mute createMute(AUserInAServer aUserInAServer, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage creation);
|
/**
|
||||||
|
* Creates a mute object with the given parameters. The only parameter set by this method is that, the mute is not ended yet.
|
||||||
|
* @param mutedUser The member which is being muted
|
||||||
|
* @param mutingUser The member which mutes
|
||||||
|
* @param reason The reason why this user is getting muted
|
||||||
|
* @param unmuteDate The date at which the mute should end
|
||||||
|
* @param muteMessage The message containing the command which caused the mute
|
||||||
|
* @return The created mute object containing the mute ID
|
||||||
|
*/
|
||||||
|
Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage muteMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the mute from the database by the given ID.
|
||||||
|
* @param muteId The id of the mute to search for
|
||||||
|
* @return The found {@link Mute}, the first access fails, if the entity was not found
|
||||||
|
*/
|
||||||
Mute findMute(Long muteId);
|
Mute findMute(Long muteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the given mute to the database.
|
||||||
|
* @param mute The {@link Mute} to save
|
||||||
|
* @return The (maybe) updated {@link Mute} object
|
||||||
|
*/
|
||||||
Mute saveMute(Mute mute);
|
Mute saveMute(Mute mute);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the given {@link AUserInAServer} has an active mute which has not yet been ended yet.
|
||||||
|
* @param userInAServer The {@link AUserInAServer} to check for
|
||||||
|
* @return Whether or not the userInAServer has an active mute
|
||||||
|
*/
|
||||||
boolean hasActiveMute(AUserInAServer userInAServer);
|
boolean hasActiveMute(AUserInAServer userInAServer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns any active {@link Mute} of this {@link AUserInAServer} in the database
|
||||||
|
* @param userInAServer The {@link AUserInAServer} to search a mute for
|
||||||
|
* @return The found {@link Mute}, and null if none was found
|
||||||
|
*/
|
||||||
Mute getAMuteOf(AUserInAServer userInAServer);
|
Mute getAMuteOf(AUserInAServer userInAServer);
|
||||||
Mute getAMuteOf(Member userInAServer);
|
|
||||||
|
/**
|
||||||
|
* Returns any active {@link Mute} of this {@link Member} in the databaes
|
||||||
|
* @param member The {@link Member} to search a mute for
|
||||||
|
* @return The found {@link Mute}, and null if none was found
|
||||||
|
*/
|
||||||
|
Mute getAMuteOf(Member member);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all active mutes of the given {@link AUserInAServer} in a collection
|
||||||
|
* @param aUserInAServer The {@link AUserInAServer} to search the actie mutes for
|
||||||
|
* @return A collection of {@link Mute} objects of the user which are active
|
||||||
|
*/
|
||||||
List<Mute> getAllMutesOf(AUserInAServer aUserInAServer);
|
List<Mute> getAllMutesOf(AUserInAServer aUserInAServer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,6 +249,11 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
|||||||
if(textChannelFromServer.isPresent()) {
|
if(textChannelFromServer.isPresent()) {
|
||||||
TextChannel textChannel = textChannelFromServer.get();
|
TextChannel textChannel = textChannelFromServer.get();
|
||||||
self.sendUserReply(textChannel, modMailThread, message);
|
self.sendUserReply(textChannel, modMailThread, message);
|
||||||
|
} else {
|
||||||
|
// in this case there was no text channel on the server associated with the mod mail thread
|
||||||
|
// close the existing one, so the user can start a new one
|
||||||
|
message.getChannel().sendMessage(templateService.renderTemplate("modmail_failed_to_forward_message", new Object())).queue();
|
||||||
|
self.closeModMailThreadInDb(modMailThread.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,13 @@ public class MessageCacheBean implements MessageCache {
|
|||||||
TextChannel textChannel = textChannelByIdOptional.get();
|
TextChannel textChannel = textChannelByIdOptional.get();
|
||||||
textChannel.retrieveMessageById(messageId).queue(message ->
|
textChannel.retrieveMessageById(messageId).queue(message ->
|
||||||
{
|
{
|
||||||
buildCachedMessageFromMessage(message).thenAccept(future::complete);
|
buildCachedMessageFromMessage(message)
|
||||||
|
.thenAccept(future::complete)
|
||||||
|
.exceptionally(throwable -> {
|
||||||
|
log.error("Failed to load message for caching.", throwable);
|
||||||
|
future.completeExceptionally(throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class AFeature implements SnowFlake {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "module")
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "feature")
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||||
private List<ACommand> commands;
|
private List<ACommand> commands;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Failed to forward message. Existing mod mail thread has been deleted. Send another message to start a new one.
|
||||||
@@ -10,11 +10,11 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
public class EmbedField {
|
public class EmbedField {
|
||||||
/**
|
/**
|
||||||
* The name of the field to be set, must not be null or empty
|
* The name of the field to be set
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
/**
|
/**
|
||||||
* The value of the field to be set, must not be null or empty
|
* The value of the field to be set
|
||||||
*/
|
*/
|
||||||
private String value;
|
private String value;
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user