|
|
@@ -294,6 +294,34 @@ namespace Discord.Rest |
|
|
|
|
|
|
|
return model is null ? null : RestGuildUser.Create(client, guild, model); |
|
|
|
} |
|
|
|
|
|
|
|
public static async Task AddGuildUserAsync(ulong guildId, BaseDiscordClient client, ulong userId, string accessToken, |
|
|
|
Action<AddGuildUserProperties> func, RequestOptions options) |
|
|
|
{ |
|
|
|
var args = new AddGuildUserProperties(); |
|
|
|
func?.Invoke(args); |
|
|
|
|
|
|
|
if (args.Roles.IsSpecified) |
|
|
|
{ |
|
|
|
var ids = args.Roles.Value.Select(r => r.Id); |
|
|
|
|
|
|
|
if (args.RoleIds.IsSpecified) |
|
|
|
args.RoleIds.Value.Concat(ids); |
|
|
|
else |
|
|
|
args.RoleIds = Optional.Create(ids); |
|
|
|
} |
|
|
|
var apiArgs = new AddGuildMemberParams |
|
|
|
{ |
|
|
|
AccessToken = accessToken, |
|
|
|
Nickname = args.Nickname, |
|
|
|
IsDeafened = args.Deaf, |
|
|
|
IsMuted = args.Mute, |
|
|
|
RoleIds = args.RoleIds.IsSpecified ? args.RoleIds.Value.Distinct().ToArray() : Optional.Create<ulong[]>() |
|
|
|
}; |
|
|
|
|
|
|
|
await client.ApiClient.AddGuildMemberAsync(guildId, userId, apiArgs, options); |
|
|
|
} |
|
|
|
|
|
|
|
public static async Task<RestGuildUser> GetUserAsync(IGuild guild, BaseDiscordClient client, |
|
|
|
ulong id, RequestOptions options) |
|
|
|
{ |
|
|
|