@@ -93,6 +93,9 @@ public void warn(User user, WarnSeverity severity, String reason, Member warnedB
9393 if (!quiet && channel .getIdLong () != moderationConfig .getLogChannelId ()) {
9494 channel .sendMessageEmbeds (warnEmbed ).queue ();
9595 }
96+ if (totalSeverity > moderationConfig .getTimeoutSeverity () && totalSeverity -severity .getWeight () <= moderationConfig .getTimeoutSeverity ()) {
97+ timeout (user , "Too many warns" , warnedBy , Duration .ofHours (moderationConfig .getWarnTimeoutHours ()), channel , quiet );
98+ }
9699 if (totalSeverity > moderationConfig .getMaxWarnSeverity ()) {
97100 ban (user , "Too many warns" , warnedBy , channel , quiet );
98101 }
@@ -179,18 +182,18 @@ public List<Warn> getAllWarns(long userId) {
179182 /**
180183 * Adds a Timeout to the member.
181184 *
182- * @param member The member to time out.
185+ * @param user The user to time out.
183186 * @param reason The reason for adding this Timeout.
184187 * @param timedOutBy The member who is responsible for adding this Timeout.
185188 * @param duration How long the Timeout should last.
186189 * @param channel The channel in which the Timeout was issued.
187190 * @param quiet If true, don't send a message in the channel.
188191 */
189- public void timeout (@ Nonnull Member member , @ Nonnull String reason , @ Nonnull Member timedOutBy , @ Nonnull Duration duration , @ Nonnull MessageChannel channel , boolean quiet ) {
190- MessageEmbed timeoutEmbed = buildTimeoutEmbed (member , timedOutBy , reason , duration );
191- member .getGuild ().timeoutFor (member , duration ).queue (s -> {
192- notificationService .withUser (member . getUser () , timedOutBy .getGuild ()).sendDirectMessage (c -> c .sendMessageEmbeds (timeoutEmbed ));
193- notificationService .withGuild (member .getGuild ()).sendToModerationLog (c -> c .sendMessageEmbeds (timeoutEmbed ));
192+ public void timeout (@ Nonnull User user , @ Nonnull String reason , @ Nonnull Member timedOutBy , @ Nonnull Duration duration , @ Nonnull MessageChannel channel , boolean quiet ) {
193+ MessageEmbed timeoutEmbed = buildTimeoutEmbed (user , timedOutBy , reason , duration );
194+ timedOutBy .getGuild ().timeoutFor (user , duration ).queue (s -> {
195+ notificationService .withUser (user , timedOutBy .getGuild ()).sendDirectMessage (c -> c .sendMessageEmbeds (timeoutEmbed ));
196+ notificationService .withGuild (timedOutBy .getGuild ()).sendToModerationLog (c -> c .sendMessageEmbeds (timeoutEmbed ));
194197 if (!quiet ) channel .sendMessageEmbeds (timeoutEmbed ).queue ();
195198 }, ExceptionLogger ::capture );
196199 }
@@ -359,8 +362,8 @@ public void kick(User user, String reason, Member kickedBy, MessageChannel chann
359362 .build ();
360363 }
361364
362- private @ NotNull MessageEmbed buildTimeoutEmbed (@ NotNull Member member , Member timedOutBy , String reason , Duration duration ) {
363- return buildModerationEmbed (member . getUser () , timedOutBy , reason )
365+ private @ NotNull MessageEmbed buildTimeoutEmbed (@ NotNull User user , Member timedOutBy , String reason , Duration duration ) {
366+ return buildModerationEmbed (user , timedOutBy , reason )
364367 .setTitle ("Timeout" )
365368 .setColor (Responses .Type .ERROR .getColor ())
366369 .addField ("Ends" , String .format ("<t:%d:R>" , Instant .now ().plus (duration ).getEpochSecond ()), true )
0 commit comments