Skip to content

Commit

Permalink
Fix ban and kick not sending messages all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Mar 15, 2024
1 parent ae2435a commit 4ff2217
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2020-2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -174,13 +174,22 @@ private MessageEmbed handle(Member member, Member moderator, Guild guild, int da
embedBuilder.addField("Additional Info", punishmentMessage, false);
}

channel.sendMessageEmbeds(embedBuilder.build()).queue(message -> {}, throwable -> {});
}, throwable -> {});
channel.sendMessageEmbeds(embedBuilder.build()).queue(message -> {
// Ban user
guild.ban(user, days, TimeUnit.DAYS).reason(reason).queue();
}, throwable -> {
// Ban user
guild.ban(user, days, TimeUnit.DAYS).reason(reason).queue();
});
}, throwable -> {
// Ban user
guild.ban(user, days, TimeUnit.DAYS).reason(reason).queue();
});
} else {
// Ban user
guild.ban(user, days, TimeUnit.DAYS).reason(reason).queue();
}

// Ban user
guild.ban(user, days, TimeUnit.DAYS).reason(reason).queue();

// Log the change
int id = GeyserBot.storageManager.addLog(moderator, "ban", user, reason);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2020-2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -163,17 +163,26 @@ private MessageEmbed handle(Member member, Member moderator, Guild guild, boolea
.setColor(BotColors.FAILURE.getColor());

String punishmentMessage = GeyserBot.storageManager.getServerPreference(guild.getIdLong(), "punishment-message");
if (!punishmentMessage.isEmpty()) {
if (punishmentMessage != null && !punishmentMessage.isEmpty()) {
embedBuilder.addField("Additional Info", punishmentMessage, false);
}

channel.sendMessageEmbeds(embedBuilder.build()).queue(message -> {}, throwable -> {});
}, throwable -> {});
channel.sendMessageEmbeds(embedBuilder.build()).queue(message -> {
// Kick user
guild.kick(user).reason(reason).queue();
}, throwable -> {
// Kick user
guild.kick(user).reason(reason).queue();
});
}, throwable -> {
// Kick user
guild.kick(user).reason(reason).queue();
});
} else {
// Kick user
guild.kick(user).reason(reason).queue();
}

// Kick user
guild.kick(user).reason(reason).queue();

// Log the change
int id = GeyserBot.storageManager.addLog(moderator, "kick", user, reason);

Expand Down

0 comments on commit 4ff2217

Please sign in to comment.