@@ -208,8 +208,17 @@ public void removeTimeout(Member member, String reason, Member removedBy, Messag
208208 */
209209 public void ban (User user , String reason , Member bannedBy , MessageChannel channel , boolean quiet ) {
210210 MessageEmbed banEmbed = buildBanEmbed (user , bannedBy , reason );
211+ user .openPrivateChannel ().flatMap (privateChannel -> privateChannel .sendMessageEmbeds (banEmbed )).queue (success -> {
212+ banAndSendGuildNotifications (user , reason , bannedBy , channel , quiet , banEmbed );
213+ }, err -> {
214+ banAndSendGuildNotifications (user , reason , bannedBy , channel , quiet , banEmbed );
215+ ExceptionLogger .capture (err , ModerationService .class .getName ());
216+ });
217+ }
218+
219+ private void banAndSendGuildNotifications (User user , String reason , Member bannedBy , MessageChannel channel , boolean quiet ,
220+ MessageEmbed banEmbed ) {
211221 bannedBy .getGuild ().ban (user , BAN_DELETE_DAYS , TimeUnit .DAYS ).reason (reason ).queue (s -> {
212- notificationService .withUser (user ).sendDirectMessage (c -> c .sendMessageEmbeds (banEmbed ));
213222 notificationService .withGuild (bannedBy .getGuild ()).sendToModerationLog (c -> c .sendMessageEmbeds (banEmbed ));
214223 if (!quiet ) channel .sendMessageEmbeds (banEmbed ).queue ();
215224 }, ExceptionLogger ::capture );
0 commit comments