Skip to content

Commit 277c7af

Browse files
authored
Revert "Optimize Add/RemoveRolesAsync methods (#2614)" (#2680)
This reverts commit 11481a1.
1 parent a41fa62 commit 277c7af

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Discord.Net.Rest/Entities/Users/UserHelper.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,14 @@ public static async Task<RestDMChannel> CreateDMChannelAsync(IUser user, BaseDis
8181

8282
public static async Task AddRolesAsync(IGuildUser user, BaseDiscordClient client, IEnumerable<ulong> roleIds, RequestOptions options)
8383
{
84-
await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args: new()
85-
{
86-
RoleIds = user.RoleIds.Except(new[] { user.Guild.Id }).Concat(roleIds).Distinct().ToArray()
87-
}, options);
84+
foreach (var roleId in roleIds)
85+
await client.ApiClient.AddRoleAsync(user.Guild.Id, user.Id, roleId, options).ConfigureAwait(false);
8886
}
8987

9088
public static async Task RemoveRolesAsync(IGuildUser user, BaseDiscordClient client, IEnumerable<ulong> roleIds, RequestOptions options)
9189
{
92-
await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args: new()
93-
{
94-
RoleIds = user.RoleIds.Except(new[] { user.Guild.Id }).Except(roleIds).ToArray()
95-
}, options);
90+
foreach (var roleId in roleIds)
91+
await client.ApiClient.RemoveRoleAsync(user.Guild.Id, user.Id, roleId, options).ConfigureAwait(false);
9692
}
9793

9894
public static async Task SetTimeoutAsync(IGuildUser user, BaseDiscordClient client, TimeSpan span, RequestOptions options)

0 commit comments

Comments
 (0)