Browse Source

Remove GetInviteParams

* It was kinda stupid in the first place, might as well always get the count instead of having to ask the user whether they want the two fields filled or not.
pull/1094/head
Still Hsu 7 years ago
parent
commit
5c11ac5174
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
6 changed files with 7 additions and 23 deletions
  1. +0
    -7
      src/Discord.Net.Rest/API/Rest/GetInviteParams.cs
  2. +2
    -6
      src/Discord.Net.Rest/ClientHelper.cs
  3. +2
    -4
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  4. +1
    -1
      src/Discord.Net.Rest/DiscordRestClient.cs
  5. +1
    -4
      src/Discord.Net.Rest/Entities/Invites/RestInvite.cs
  6. +1
    -1
      src/Discord.Net.WebSocket/BaseSocketClient.cs

+ 0
- 7
src/Discord.Net.Rest/API/Rest/GetInviteParams.cs View File

@@ -1,7 +0,0 @@
namespace Discord.API.Rest
{
internal class GetInviteParams
{
public Optional<bool?> WithCounts { get; set; }
}
}

+ 2
- 6
src/Discord.Net.Rest/ClientHelper.cs View File

@@ -51,13 +51,9 @@ namespace Discord.Rest
} }
public static async Task<RestInviteMetadata> GetInviteAsync(BaseDiscordClient client, public static async Task<RestInviteMetadata> GetInviteAsync(BaseDiscordClient client,
string inviteId, bool withCount, RequestOptions options)
string inviteId, RequestOptions options)
{ {
var args = new GetInviteParams
{
WithCounts = withCount
};
var model = await client.ApiClient.GetInviteAsync(inviteId, args, options).ConfigureAwait(false);
var model = await client.ApiClient.GetInviteAsync(inviteId, options).ConfigureAwait(false);
if (model != null) if (model != null)
return RestInviteMetadata.Create(client, null, null, model); return RestInviteMetadata.Create(client, null, null, model);
return null; return null;


+ 2
- 4
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -906,7 +906,7 @@ namespace Discord.API
} }


//Guild Invites //Guild Invites
public async Task<InviteMetadata> GetInviteAsync(string inviteId, GetInviteParams args, RequestOptions options = null)
public async Task<InviteMetadata> GetInviteAsync(string inviteId, RequestOptions options = null)
{ {
Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId)); Preconditions.NotNullOrEmpty(inviteId, nameof(inviteId));
options = RequestOptions.CreateOrClone(options); options = RequestOptions.CreateOrClone(options);
@@ -919,11 +919,9 @@ namespace Discord.API
if (index >= 0) if (index >= 0)
inviteId = inviteId.Substring(index + 1); inviteId = inviteId.Substring(index + 1);


var withCounts = args.WithCounts.GetValueOrDefault(false);

try try
{ {
return await SendAsync<InviteMetadata>("GET", () => $"invites/{inviteId}?with_counts={withCounts}", new BucketIds(), options: options).ConfigureAwait(false);
return await SendAsync<InviteMetadata>("GET", () => $"invites/{inviteId}?with_counts=true", new BucketIds(), options: options).ConfigureAwait(false);
} }
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
} }


+ 1
- 1
src/Discord.Net.Rest/DiscordRestClient.cs View File

@@ -57,7 +57,7 @@ namespace Discord.Rest


/// <inheritdoc /> /// <inheritdoc />
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, bool withCount = false, RequestOptions options = null) public Task<RestInviteMetadata> GetInviteAsync(string inviteId, bool withCount = false, RequestOptions options = null)
=> ClientHelper.GetInviteAsync(this, inviteId, withCount, options);
=> ClientHelper.GetInviteAsync(this, inviteId, options);


/// <inheritdoc /> /// <inheritdoc />
public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null) public Task<RestGuild> GetGuildAsync(ulong id, RequestOptions options = null)


+ 1
- 4
src/Discord.Net.Rest/Entities/Invites/RestInvite.cs View File

@@ -45,10 +45,7 @@ namespace Discord.Rest
public async Task UpdateAsync(RequestOptions options = null) public async Task UpdateAsync(RequestOptions options = null)
{ {
var args = new GetInviteParams();
if (MemberCount != null || PresenceCount != null)
args.WithCounts = true;
var model = await Discord.ApiClient.GetInviteAsync(Code, args, options).ConfigureAwait(false);
var model = await Discord.ApiClient.GetInviteAsync(Code, options).ConfigureAwait(false);
Update(model); Update(model);
} }
public Task DeleteAsync(RequestOptions options = null) public Task DeleteAsync(RequestOptions options = null)


+ 1
- 1
src/Discord.Net.WebSocket/BaseSocketClient.cs View File

@@ -56,7 +56,7 @@ namespace Discord.WebSocket
=> ClientHelper.GetConnectionsAsync(this, options ?? RequestOptions.Default); => ClientHelper.GetConnectionsAsync(this, options ?? RequestOptions.Default);
/// <inheritdoc /> /// <inheritdoc />
public Task<RestInviteMetadata> GetInviteAsync(string inviteId, bool withCount = false, RequestOptions options = null) public Task<RestInviteMetadata> GetInviteAsync(string inviteId, bool withCount = false, RequestOptions options = null)
=> ClientHelper.GetInviteAsync(this, inviteId, withCount, options ?? RequestOptions.Default);
=> ClientHelper.GetInviteAsync(this, inviteId, options ?? RequestOptions.Default);
// IDiscordClient // IDiscordClient
async Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options) async Task<IApplication> IDiscordClient.GetApplicationInfoAsync(RequestOptions options)


Loading…
Cancel
Save