| @@ -120,6 +120,15 @@ namespace Discord | |||||
| /// <summary> Gets a collection of all invites to this guild. </summary> | /// <summary> Gets a collection of all invites to this guild. </summary> | ||||
| Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null); | Task<IReadOnlyCollection<IInviteMetadata>> GetInvitesAsync(RequestOptions options = null); | ||||
| /// <summary> | |||||
| /// Gets the vanity invite URL of this guild. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// An awaitable <see cref="Task"/> containing the partial metadata of the vanity invite found within | |||||
| /// this guild. | |||||
| /// </returns> | |||||
| Task<IInviteMetadata> GetVanityInviteAsync(RequestOptions options = null); | |||||
| /// <summary> Gets the role in this guild with the provided id, or null if not found. </summary> | /// <summary> Gets the role in this guild with the provided id, or null if not found. </summary> | ||||
| IRole GetRole(ulong id); | IRole GetRole(ulong id); | ||||
| @@ -925,6 +925,14 @@ namespace Discord.API | |||||
| } | } | ||||
| catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } | ||||
| } | } | ||||
| public async Task<InviteMetadata> 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); | |||||
| } | |||||
| public async Task<IReadOnlyCollection<InviteMetadata>> GetGuildInvitesAsync(ulong guildId, RequestOptions options = null) | public async Task<IReadOnlyCollection<InviteMetadata>> GetGuildInvitesAsync(ulong guildId, RequestOptions options = null) | ||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| @@ -210,6 +210,12 @@ namespace Discord.Rest | |||||
| var models = await client.ApiClient.GetGuildInvitesAsync(guild.Id, options).ConfigureAwait(false); | var models = await client.ApiClient.GetGuildInvitesAsync(guild.Id, options).ConfigureAwait(false); | ||||
| return models.Select(x => RestInviteMetadata.Create(client, guild, null, x)).ToImmutableArray(); | return models.Select(x => RestInviteMetadata.Create(client, guild, null, x)).ToImmutableArray(); | ||||
| } | } | ||||
| 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); | |||||
| } | |||||
| //Roles | //Roles | ||||
| public static async Task<RestRole> CreateRoleAsync(IGuild guild, BaseDiscordClient client, | public static async Task<RestRole> CreateRoleAsync(IGuild guild, BaseDiscordClient client, | ||||
| @@ -238,6 +238,15 @@ namespace Discord.Rest | |||||
| //Invites | //Invites | ||||
| public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetInvitesAsync(this, Discord, options); | => GuildHelper.GetInvitesAsync(this, Discord, options); | ||||
| /// <summary> | |||||
| /// Gets the vanity invite URL of this guild. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A partial metadata of the vanity invite found within this guild. | |||||
| /// </returns> | |||||
| public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | |||||
| => GuildHelper.GetVanityInviteAsync(this, Discord, options); | |||||
| //Roles | //Roles | ||||
| public RestRole GetRole(ulong id) | public RestRole GetRole(ulong id) | ||||
| @@ -397,6 +406,9 @@ namespace Discord.Rest | |||||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | ||||
| => await GetInvitesAsync(options).ConfigureAwait(false); | => await GetInvitesAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task<IInviteMetadata> IGuild.GetVanityInviteAsync(RequestOptions options) | |||||
| => await GetVanityInviteAsync(options).ConfigureAwait(false); | |||||
| IRole IGuild.GetRole(ulong id) | IRole IGuild.GetRole(ulong id) | ||||
| => GetRole(id); | => GetRole(id); | ||||
| @@ -345,6 +345,15 @@ namespace Discord.WebSocket | |||||
| //Invites | //Invites | ||||
| public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | public Task<IReadOnlyCollection<RestInviteMetadata>> GetInvitesAsync(RequestOptions options = null) | ||||
| => GuildHelper.GetInvitesAsync(this, Discord, options); | => GuildHelper.GetInvitesAsync(this, Discord, options); | ||||
| /// <summary> | |||||
| /// Gets the vanity invite URL of this guild. | |||||
| /// </summary> | |||||
| /// <param name="options">The options to be used when sending the request.</param> | |||||
| /// <returns> | |||||
| /// A partial metadata of the vanity invite found within this guild. | |||||
| /// </returns> | |||||
| public Task<RestInviteMetadata> GetVanityInviteAsync(RequestOptions options = null) | |||||
| => GuildHelper.GetVanityInviteAsync(this, Discord, options); | |||||
| //Roles | //Roles | ||||
| public SocketRole GetRole(ulong id) | public SocketRole GetRole(ulong id) | ||||
| @@ -700,6 +709,9 @@ namespace Discord.WebSocket | |||||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | ||||
| => await GetInvitesAsync(options).ConfigureAwait(false); | => await GetInvitesAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | |||||
| async Task<IInviteMetadata> IGuild.GetVanityInviteAsync(RequestOptions options) | |||||
| => await GetVanityInviteAsync(options).ConfigureAwait(false); | |||||
| IRole IGuild.GetRole(ulong id) | IRole IGuild.GetRole(ulong id) | ||||
| => GetRole(id); | => GetRole(id); | ||||