feature: add Add Guild Member endpoint (#1183)

* Add AddGuildMember Oauth endpoint support

* Concat RoleIds if already exists.

* Use local ids variable.
This commit is contained in:
Alex Gravely
2018-11-05 18:34:09 -05:00
committed by Christopher F
parent 7dd2268982
commit 8ef5f8120f
7 changed files with 156 additions and 0 deletions

View File

@@ -994,6 +994,25 @@ namespace Discord.API
}
//Guild Members
public async Task<GuildMember> AddGuildMemberAsync(ulong guildId, ulong userId, AddGuildMemberParams args, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotEqual(userId, 0, nameof(userId));
Preconditions.NotNull(args, nameof(args));
Preconditions.NotNullOrWhitespace(args.AccessToken, nameof(args.AccessToken));
if (args.RoleIds.IsSpecified)
{
foreach (var roleId in args.RoleIds.Value)
Preconditions.NotEqual(roleId, 0, nameof(roleId));
}
options = RequestOptions.CreateOrClone(options);
var ids = new BucketIds(guildId: guildId);
return await SendJsonAsync<GuildMember>("PUT", () => $"guilds/{guildId}/members/{userId}", args, ids, options: options);
}
public async Task<GuildMember> GetGuildMemberAsync(ulong guildId, ulong userId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));