diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index 81b5e8dd9..8392bcd58 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -705,11 +705,12 @@ namespace Discord
/// The number of days required for the users to be kicked.
/// Whether this prune action is a simulation.
/// The options to be used when sending the request.
+ /// An array of role IDs to be included in the prune of users who do not have any additional roles.
///
/// A task that represents the asynchronous prune operation. The task result contains the number of users to
/// be or has been removed from this guild.
///
- Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null);
+ Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null, IEnumerable includeRoleIds = null);
///
/// Gets a collection of users in this guild that the name or nickname starts with the
/// provided at .
diff --git a/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs b/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs
index 6a98d3758..e4c9192ad 100644
--- a/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs
@@ -9,9 +9,13 @@ namespace Discord.API.Rest
[JsonProperty("days")]
public int Days { get; }
- public GuildPruneParams(int days)
+ [JsonProperty("include_roles")]
+ public ulong[] IncludeRoleIds { get; }
+
+ public GuildPruneParams(int days, ulong[] includeRoleIds)
{
Days = days;
+ IncludeRoleIds = includeRoleIds;
}
}
}
diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs
index 83aa6c751..27658e7ac 100644
--- a/src/Discord.Net.Rest/DiscordRestApiClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs
@@ -853,10 +853,11 @@ namespace Discord.API
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotNull(args, nameof(args));
Preconditions.AtLeast(args.Days, 1, nameof(args.Days));
+ string endpointRoleIds = args.IncludeRoleIds?.Length > 0 ? $"&include_roles={string.Join(",", args.IncludeRoleIds)}" : "";
options = RequestOptions.CreateOrClone(options);
var ids = new BucketIds(guildId: guildId);
- return await SendAsync("GET", () => $"guilds/{guildId}/prune?days={args.Days}", ids, options: options).ConfigureAwait(false);
+ return await SendAsync("GET", () => $"guilds/{guildId}/prune?days={args.Days}{endpointRoleIds}", ids, options: options).ConfigureAwait(false);
}
//Guild Bans
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index ecb45fd07..225c53edf 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -404,9 +404,9 @@ namespace Discord.Rest
);
}
public static async Task PruneUsersAsync(IGuild guild, BaseDiscordClient client,
- int days, bool simulate, RequestOptions options)
+ int days, bool simulate, RequestOptions options, IEnumerable includeRoleIds)
{
- var args = new GuildPruneParams(days);
+ var args = new GuildPruneParams(days, includeRoleIds?.ToArray());
GetGuildPruneCountResponse model;
if (simulate)
model = await client.ApiClient.GetGuildPruneCountAsync(guild.Id, args, options).ConfigureAwait(false);
@@ -479,7 +479,7 @@ namespace Discord.Rest
var emote = await client.ApiClient.GetGuildEmoteAsync(guild.Id, id, options).ConfigureAwait(false);
return emote.ToEntity();
}
- public static async Task CreateEmoteAsync(IGuild guild, BaseDiscordClient client, string name, Image image, Optional> roles,
+ public static async Task CreateEmoteAsync(IGuild guild, BaseDiscordClient client, string name, Image image, Optional> roles,
RequestOptions options)
{
var apiargs = new CreateGuildEmoteParams
@@ -494,7 +494,7 @@ namespace Discord.Rest
return emote.ToEntity();
}
/// is null.
- public static async Task ModifyEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, Action func,
+ public static async Task ModifyEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, Action func,
RequestOptions options)
{
if (func == null) throw new ArgumentNullException(paramName: nameof(func));
@@ -512,7 +512,7 @@ namespace Discord.Rest
var emote = await client.ApiClient.ModifyGuildEmoteAsync(guild.Id, id, apiargs, options).ConfigureAwait(false);
return emote.ToEntity();
}
- public static Task DeleteEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options)
+ public static Task DeleteEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options)
=> client.ApiClient.DeleteGuildEmoteAsync(guild.Id, id, options);
}
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index f0b5be0f7..482eaf556 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -205,7 +205,7 @@ namespace Discord.Rest
role?.Update(model);
}
}
-
+
///
public Task LeaveAsync(RequestOptions options = null)
=> GuildHelper.LeaveAsync(this, Discord, options);
@@ -631,8 +631,8 @@ namespace Discord.Rest
/// A task that represents the asynchronous prune operation. The task result contains the number of users to
/// be or has been removed from this guild.
///
- public Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null)
- => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options);
+ public Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null, IEnumerable includeRoleIds = null)
+ => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options, includeRoleIds);
///
/// Gets a collection of users in this guild that the name or nickname starts with the
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 160b91526..a08ba06ef 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -746,8 +746,8 @@ namespace Discord.WebSocket
return null;
}
///
- public Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null)
- => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options);
+ public Task PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null, IEnumerable includeRoleIds = null)
+ => GuildHelper.PruneUsersAsync(this, Discord, days, simulate, options, includeRoleIds);
internal SocketGuildUser AddOrUpdateUser(UserModel model)
{