fix: Grab correct Uses value for vanity urls (#1832)

This commit is contained in:
Evan Raffel
2021-05-26 17:46:14 -04:00
committed by GitHub
parent 70aab6c4f6
commit 8ed8714375
2 changed files with 3 additions and 0 deletions

View File

@@ -6,5 +6,7 @@ namespace Discord.API
{ {
[JsonProperty("code")] [JsonProperty("code")]
public string Code { get; set; } public string Code { get; set; }
[JsonProperty("uses")]
public int Uses { get; set; }
} }
} }

View File

@@ -283,6 +283,7 @@ namespace Discord.Rest
var vanityModel = await client.ApiClient.GetVanityInviteAsync(guild.Id, options).ConfigureAwait(false); var vanityModel = await client.ApiClient.GetVanityInviteAsync(guild.Id, options).ConfigureAwait(false);
if (vanityModel == null) throw new InvalidOperationException("This guild does not have a vanity URL."); if (vanityModel == null) throw new InvalidOperationException("This guild does not have a vanity URL.");
var inviteModel = await client.ApiClient.GetInviteAsync(vanityModel.Code, options).ConfigureAwait(false); var inviteModel = await client.ApiClient.GetInviteAsync(vanityModel.Code, options).ConfigureAwait(false);
inviteModel.Uses = vanityModel.Uses;
return RestInviteMetadata.Create(client, guild, null, inviteModel); return RestInviteMetadata.Create(client, guild, null, inviteModel);
} }