Revert "Optimize Add/RemoveRolesAsync methods (#2614)" (#2680)

This reverts commit 11481a159e.
This commit is contained in:
Misha133
2023-05-22 23:36:20 +03:00
committed by GitHub
parent a41fa62124
commit 277c7af3be

View File

@@ -81,18 +81,14 @@ namespace Discord.Rest
public static async Task AddRolesAsync(IGuildUser user, BaseDiscordClient client, IEnumerable<ulong> roleIds, RequestOptions options)
{
await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args: new()
{
RoleIds = user.RoleIds.Except(new[] { user.Guild.Id }).Concat(roleIds).Distinct().ToArray()
}, options);
foreach (var roleId in roleIds)
await client.ApiClient.AddRoleAsync(user.Guild.Id, user.Id, roleId, options).ConfigureAwait(false);
}
public static async Task RemoveRolesAsync(IGuildUser user, BaseDiscordClient client, IEnumerable<ulong> roleIds, RequestOptions options)
{
await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args: new()
{
RoleIds = user.RoleIds.Except(new[] { user.Guild.Id }).Except(roleIds).ToArray()
}, options);
foreach (var roleId in roleIds)
await client.ApiClient.RemoveRoleAsync(user.Guild.Id, user.Id, roleId, options).ConfigureAwait(false);
}
public static async Task SetTimeoutAsync(IGuildUser user, BaseDiscordClient client, TimeSpan span, RequestOptions options)