diff --git a/src/Discord.Net.Core/DiscordConfig.cs b/src/Discord.Net.Core/DiscordConfig.cs
index ac703a0015..869d113d15 100644
--- a/src/Discord.Net.Core/DiscordConfig.cs
+++ b/src/Discord.Net.Core/DiscordConfig.cs
@@ -256,5 +256,10 @@ public class DiscordConfig
/// Returns the maximum number of entitlements that can be gotten per-batch.
///
public const int MaxEntitlementsPerBatch = 100;
+
+ ///
+ /// Returns the maximum number of bans that can be banned in a single bulk request.
+ ///
+ public const int MaxBansPerBulkBatch = 200;
}
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index 2dae8fc518..6245d20c9b 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -251,9 +251,20 @@ public static Task RemoveBanAsync(IGuild guild, BaseDiscordClient client, ulong
public static async Task BulkBanAsync(IGuild guild, BaseDiscordClient client, ulong[] userIds, int? deleteMessageSeconds, RequestOptions options)
{
- var model = await client.ApiClient.BulkBanAsync(guild.Id, userIds, deleteMessageSeconds, options);
- return new(model.BannedUsers?.ToImmutableArray() ?? ImmutableArray.Empty,
- model.FailedUsers?.ToImmutableArray() ?? ImmutableArray.Empty);
+ var pos = 0;
+ var banned = new List(userIds.Length);
+ var failed = new List();
+ while (pos * DiscordConfig.MaxBansPerBulkBatch < userIds.Length)
+ {
+ var toBan = userIds
+ .Skip(pos * DiscordConfig.MaxBansPerBulkBatch)
+ .Take(DiscordConfig.MaxBansPerBulkBatch);
+ pos++;
+ var model = await client.ApiClient.BulkBanAsync(guild.Id, toBan.ToArray(), deleteMessageSeconds, options);
+ banned.AddRange(model.BannedUsers ?? []);
+ failed.AddRange(model.FailedUsers ?? []);
+ }
+ return new(banned.ToImmutableArray(), failed.ToImmutableArray());
}
#endregion
@@ -620,7 +631,7 @@ public static async Task CreateRoleAsync(IGuild guild, BaseDiscordClie
var createGuildRoleParams = new API.Rest.ModifyGuildRoleParams
{
- Color = color?.RawValue ?? Optional.Create(),
+ Color = color?.RawValue ?? Optional.Create(),
Hoist = isHoisted,
Mentionable = isMentionable,
Name = name,