Skip to content

Commit b6792fe

Browse files
committed
fix direct message when banning user
1 parent a5e899f commit b6792fe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/net/javadiscord/javabot/Bot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class Bot {
5151
private final DIH4JDA dih4jda;
5252
private final BotConfig config;
5353
private final List<SlashCommand> commands;
54-
private final List<ContextCommand> contextCommands;
54+
private final List<ContextCommand<?>> contextCommands;
5555
private final List<ListenerAdapter> listeners;
5656
private final ApplicationContext ctx;
5757

src/main/java/net/javadiscord/javabot/systems/moderation/ModerationService.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)