@@ -21,7 +21,9 @@ import net.cakeyfox.serializable.data.utils.DiscordImageBody
2121import net.cakeyfox.serializable.data.utils.DiscordMessageBody
2222import net.dv8tion.jda.api.entities.User
2323import net.dv8tion.jda.api.entities.UserSnowflake
24+ import net.dv8tion.jda.api.exceptions.ErrorResponseException
2425import net.dv8tion.jda.api.exceptions.RateLimitedException
26+ import net.dv8tion.jda.api.requests.ErrorResponse
2527
2628object AdminUtils {
2729 private val logger = KotlinLogging .logger {}
@@ -91,11 +93,9 @@ object AdminUtils {
9193 val guildData = foxy.database.guild.getGuild(guildId)
9294
9395 try {
94- try {
95- guild.ban(userAsSnowflakes, null )
96- .reason(reason + " - ${staff.name} (${staff.id} )" )
97- .await()
98- } catch (e: Exception ) { }
96+ guild.ban(userAsSnowflakes, null )
97+ .reason(reason + " - ${staff.name} (${staff.id} )" )
98+ .await()
9999
100100 val durationInstant =
101101 if (durationInMs > 0 ) Instant .fromEpochMilliseconds(
@@ -132,6 +132,19 @@ object AdminUtils {
132132 sendMessage(foxy, guildData, placeholders, guild)
133133 }
134134
135+ } catch (e: ErrorResponseException ) {
136+ when (e.errorResponse) {
137+ ErrorResponse .FAILED_TO_BAN_USERS ,
138+ ErrorResponse .UNKNOWN_BAN -> {
139+ // Already banned users can catch at this
140+ }
141+
142+ else -> {
143+ logger.error(e) {
144+ " Mass ban failed | guild=${guild.id} | users=${userAsSnowflakes.size} | staff=${staff.id} "
145+ }
146+ }
147+ }
135148 } catch (e: Exception ) {
136149 logger.error(e) { " Failed to ban users on guild $guildId " }
137150 }
0 commit comments