Fix/Implement various invite-related behaviors (#1023)
* Initial support for invite member count arg * Fix IDiscordClient#GetInviteAsync behavior - Previously, the GetInviteAsync method would return null since it couldn't be parsed as a simple RestInvite object. The object should be a RestInviteMetadata instead. * Fix methods that didn't comply with the interface * Change with_counts REST behaviour * Remove unnecessary JSON prop * Remove AcceptAsync
This commit is contained in:
@@ -897,7 +897,7 @@ namespace Discord.API
|
||||
}
|
||||
|
||||
//Guild Invites
|
||||
public async Task<Invite> GetInviteAsync(string inviteId, RequestOptions options = null)
|
||||
public async Task<InviteMetadata> GetInviteAsync(string inviteId, GetInviteParams args, RequestOptions options = null)
|
||||
{
|
||||
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId));
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
@@ -910,9 +910,11 @@ namespace Discord.API
|
||||
if (index >= 0)
|
||||
inviteId = inviteId.Substring(index + 1);
|
||||
|
||||
var withCounts = args.WithCounts.GetValueOrDefault(false);
|
||||
|
||||
try
|
||||
{
|
||||
return await SendAsync<Invite>("GET", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false);
|
||||
return await SendAsync<InviteMetadata>("GET", () => $"invites/{inviteId}?with_counts={withCounts}", new BucketIds(), options: options).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
|
||||
}
|
||||
@@ -950,13 +952,6 @@ namespace Discord.API
|
||||
|
||||
return await SendAsync<Invite>("DELETE", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false);
|
||||
}
|
||||
public async Task AcceptInviteAsync(string inviteId, RequestOptions options = null)
|
||||
{
|
||||
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId));
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
|
||||
await SendAsync("POST", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
//Guild Members
|
||||
public async Task<GuildMember> GetGuildMemberAsync(ulong guildId, ulong userId, RequestOptions options = null)
|
||||
|
||||
Reference in New Issue
Block a user