Initial fix (#1160)
This commit is contained in:
10
src/Discord.Net.Rest/API/Common/InviteVanity.cs
Normal file
10
src/Discord.Net.Rest/API/Common/InviteVanity.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
public class InviteVanity
|
||||
{
|
||||
[JsonProperty("code")]
|
||||
public string Code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -929,13 +929,13 @@ namespace Discord.API
|
||||
}
|
||||
catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; }
|
||||
}
|
||||
public async Task<InviteMetadata> GetVanityInviteAsync(ulong guildId, RequestOptions options = null)
|
||||
public async Task<InviteVanity> GetVanityInviteAsync(ulong guildId, RequestOptions options = null)
|
||||
{
|
||||
Preconditions.NotEqual(guildId, 0, nameof(guildId));
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
|
||||
var ids = new BucketIds(guildId: guildId);
|
||||
return await SendAsync<InviteMetadata>("GET", () => $"guilds/{guildId}/vanity-url", ids, options: options).ConfigureAwait(false);
|
||||
return await SendAsync<InviteVanity>("GET", () => $"guilds/{guildId}/vanity-url", ids, options: options).ConfigureAwait(false);
|
||||
}
|
||||
public async Task<IReadOnlyCollection<InviteMetadata>> GetGuildInvitesAsync(ulong guildId, RequestOptions options = null)
|
||||
{
|
||||
|
||||
@@ -213,8 +213,10 @@ namespace Discord.Rest
|
||||
public static async Task<RestInviteMetadata> GetVanityInviteAsync(IGuild guild, BaseDiscordClient client,
|
||||
RequestOptions options)
|
||||
{
|
||||
var model = await client.ApiClient.GetVanityInviteAsync(guild.Id, options).ConfigureAwait(false);
|
||||
return RestInviteMetadata.Create(client, guild, null, model);
|
||||
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.");
|
||||
var inviteModel = await client.ApiClient.GetInviteAsync(vanityModel.Code, options).ConfigureAwait(false);
|
||||
return RestInviteMetadata.Create(client, guild, null, inviteModel);
|
||||
}
|
||||
|
||||
//Roles
|
||||
|
||||
Reference in New Issue
Block a user