| @@ -729,16 +729,14 @@ namespace Discord | |||
| Task<IReadOnlyCollection<IIntegration>> GetIntegrationsAsync(RequestOptions options = null); | |||
| /// <summary> | |||
| /// Creates a new integration. | |||
| /// Deletes an integration. | |||
| /// </summary> | |||
| /// <param name="id">The id for the integration.</param> | |||
| /// <param name="type">The type of integration.</param> | |||
| /// <param name="options">The options to be used when sending the request.</param> | |||
| /// <returns> | |||
| /// A task that represents the asynchronous creation operation. The task result contains the newly created | |||
| /// integration. | |||
| /// A task that represents the asynchronous removal operation. | |||
| /// </returns> | |||
| Task<IIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null); | |||
| Task DeleteIntegrationAsync(ulong id, RequestOptions options = null); | |||
| /// <summary> | |||
| /// Gets a collection of all invites in this guild. | |||
| @@ -4,27 +4,53 @@ namespace Discord | |||
| { | |||
| public interface IConnection | |||
| { | |||
| /// <summary> Gets the ID of the connection account. </summary> | |||
| /// <returns> A <see cref="string"/> representing the unique identifier value of this connection. </returns> | |||
| /// <summary> | |||
| /// Gets the ID of the connection account. | |||
| /// </summary> | |||
| /// <returns> | |||
| /// A <see cref="string"/> representing the unique identifier value of this connection. | |||
| /// </returns> | |||
| string Id { get; } | |||
| /// <summary> Gets the username of the connection account. </summary> | |||
| /// <returns> A string containing the name of this connection. </returns> | |||
| /// <summary> | |||
| /// Gets the username of the connection account. | |||
| /// </summary> | |||
| /// <returns> | |||
| /// A string containing the name of this connection. | |||
| /// </returns> | |||
| string Name { get; } | |||
| /// <summary> Gets the service of the connection (twitch, youtube). </summary> | |||
| /// <returns> A string containing the name of this type of connection. </returns> | |||
| /// <summary> | |||
| /// Gets the service of the connection (twitch, youtube). | |||
| /// </summary> | |||
| /// <returns> | |||
| /// A string containing the name of this type of connection. | |||
| /// </returns> | |||
| string Type { get; } | |||
| /// <summary> Gets whether the connection is revoked. </summary> | |||
| /// <returns> A value which if true indicates that this connection has been revoked, otherwise false. </returns> | |||
| /// <summary> | |||
| /// Gets whether the connection is revoked. | |||
| /// </summary> | |||
| /// <returns> | |||
| /// A value which if true indicates that this connection has been revoked, otherwise false. | |||
| /// </returns> | |||
| bool? IsRevoked { get; } | |||
| /// <summary> Gets a <see cref="IReadOnlyCollection{T}"/> of integration parials. </summary> | |||
| /// <summary> | |||
| /// Gets a <see cref="IReadOnlyCollection{T}"/> of integration parials. | |||
| /// </summary> | |||
| IReadOnlyCollection<IIntegration> Integrations { get; } | |||
| /// <summary> Gets whether the connection is verified. </summary> | |||
| /// <summary> | |||
| /// Gets whether the connection is verified. | |||
| /// </summary> | |||
| bool Verified { get; } | |||
| /// <summary> Gets whether friend sync is enabled for this connection. </summary> | |||
| /// <summary> | |||
| /// Gets whether friend sync is enabled for this connection. | |||
| /// </summary> | |||
| bool FriendSync { get; } | |||
| /// <summary> Gets whether activities related to this connection will be shown in presence updates. </summary> | |||
| /// <summary> | |||
| /// Gets whether activities related to this connection will be shown in presence updates. | |||
| /// </summary> | |||
| bool ShowActivity { get; } | |||
| /// <summary> Visibility of this connection. </summary> | |||
| /// <summary> | |||
| /// Visibility of this connection. | |||
| /// </summary> | |||
| ConnectionVisibility Visibility { get; } | |||
| } | |||
| } | |||
| @@ -1626,7 +1626,7 @@ namespace Discord.API | |||
| #region Guild Integrations | |||
| /// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception> | |||
| public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) | |||
| public async Task<IReadOnlyCollection<Integration>> GetIntegrationsAsync(ulong guildId, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| @@ -1634,47 +1634,14 @@ namespace Discord.API | |||
| var ids = new BucketIds(guildId: guildId); | |||
| return await SendAsync<IReadOnlyCollection<Integration>>("GET", () => $"guilds/{guildId}/integrations", ids, options: options).ConfigureAwait(false); | |||
| } | |||
| /// <exception cref="ArgumentException"><paramref name="guildId"/> and <paramref name="args.Id"/> must not be equal to zero.</exception> | |||
| /// <exception cref="ArgumentNullException"><paramref name="args"/> must not be <see langword="null"/>.</exception> | |||
| public async Task<Integration> CreateGuildIntegrationAsync(ulong guildId, CreateGuildIntegrationParams args, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
| Preconditions.NotNull(args, nameof(args)); | |||
| Preconditions.NotEqual(args.Id, 0, nameof(args.Id)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| var ids = new BucketIds(guildId: guildId); | |||
| return await SendAsync<Integration>("POST", () => $"guilds/{guildId}/integrations", ids, options: options).ConfigureAwait(false); | |||
| } | |||
| public async Task<Integration> DeleteGuildIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
| Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| var ids = new BucketIds(guildId: guildId); | |||
| return await SendAsync<Integration>("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false); | |||
| } | |||
| public async Task<Integration> ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, Rest.ModifyGuildIntegrationParams args, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
| Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); | |||
| Preconditions.NotNull(args, nameof(args)); | |||
| Preconditions.AtLeast(args.ExpireBehavior, 0, nameof(args.ExpireBehavior)); | |||
| Preconditions.AtLeast(args.ExpireGracePeriod, 0, nameof(args.ExpireGracePeriod)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| var ids = new BucketIds(guildId: guildId); | |||
| return await SendJsonAsync<Integration>("PATCH", () => $"guilds/{guildId}/integrations/{integrationId}", args, ids, options: options).ConfigureAwait(false); | |||
| } | |||
| public async Task<Integration> SyncGuildIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null) | |||
| public async Task DeleteIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null) | |||
| { | |||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
| Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); | |||
| options = RequestOptions.CreateOrClone(options); | |||
| var ids = new BucketIds(guildId: guildId); | |||
| return await SendAsync<Integration>("POST", () => $"guilds/{guildId}/integrations/{integrationId}/sync", ids, options: options).ConfigureAwait(false); | |||
| await SendAsync("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false); | |||
| } | |||
| #endregion | |||
| @@ -308,16 +308,12 @@ namespace Discord.Rest | |||
| public static async Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(IGuild guild, BaseDiscordClient client, | |||
| RequestOptions options) | |||
| { | |||
| var models = await client.ApiClient.GetGuildIntegrationsAsync(guild.Id, options).ConfigureAwait(false); | |||
| var models = await client.ApiClient.GetIntegrationsAsync(guild.Id, options).ConfigureAwait(false); | |||
| return models.Select(x => RestIntegration.Create(client, guild, x)).ToImmutableArray(); | |||
| } | |||
| public static async Task<RestIntegration> CreateIntegrationAsync(IGuild guild, BaseDiscordClient client, | |||
| ulong id, string type, RequestOptions options) | |||
| { | |||
| var args = new CreateGuildIntegrationParams(id, type); | |||
| var model = await client.ApiClient.CreateGuildIntegrationAsync(guild.Id, args, options).ConfigureAwait(false); | |||
| return RestIntegration.Create(client, guild, model); | |||
| } | |||
| public static async Task DeleteIntegrationAsync(IGuild guild, BaseDiscordClient client, ulong id, | |||
| RequestOptions options) => | |||
| await client.ApiClient.DeleteIntegrationAsync(guild.Id, id, options).ConfigureAwait(false); | |||
| #endregion | |||
| #region Interactions | |||
| @@ -722,8 +722,8 @@ namespace Discord.Rest | |||
| #region Integrations | |||
| public Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(RequestOptions options = null) | |||
| => GuildHelper.GetIntegrationsAsync(this, Discord, options); | |||
| public Task<RestIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) | |||
| => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options); | |||
| public Task DeleteIntegrationAsync(ulong id, RequestOptions options = null) | |||
| => GuildHelper.DeleteIntegrationAsync(this, Discord, id, options); | |||
| #endregion | |||
| #region Invites | |||
| @@ -1378,8 +1378,8 @@ namespace Discord.Rest | |||
| async Task<IReadOnlyCollection<IIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) | |||
| => await GetIntegrationsAsync(options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) | |||
| => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | |||
| async Task IGuild.DeleteIntegrationAsync(ulong id, RequestOptions options) | |||
| => await DeleteIntegrationAsync(id, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | |||
| @@ -76,12 +76,7 @@ namespace Discord.Rest | |||
| public async Task DeleteAsync() | |||
| { | |||
| await Discord.ApiClient.DeleteGuildIntegrationAsync(GuildId, Id).ConfigureAwait(false); | |||
| } | |||
| public async Task SyncAsync() | |||
| { | |||
| await Discord.ApiClient.SyncGuildIntegrationAsync(GuildId, Id).ConfigureAwait(false); | |||
| await Discord.ApiClient.DeleteIntegrationAsync(GuildId, Id).ConfigureAwait(false); | |||
| } | |||
| public override string ToString() => Name; | |||
| @@ -849,8 +849,8 @@ namespace Discord.WebSocket | |||
| #region Integrations | |||
| public Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(RequestOptions options = null) | |||
| => GuildHelper.GetIntegrationsAsync(this, Discord, options); | |||
| public Task<RestIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) | |||
| => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options); | |||
| public Task DeleteIntegrationAsync(ulong id, RequestOptions options = null) | |||
| => GuildHelper.DeleteIntegrationAsync(this, Discord, id, options); | |||
| #endregion | |||
| #region Interactions | |||
| @@ -1895,8 +1895,8 @@ namespace Discord.WebSocket | |||
| async Task<IReadOnlyCollection<IIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options) | |||
| => await GetIntegrationsAsync(options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options) | |||
| => await CreateIntegrationAsync(id, type, options).ConfigureAwait(false); | |||
| async Task IGuild.DeleteIntegrationAsync(ulong id, RequestOptions options) | |||
| => await DeleteIntegrationAsync(id, options).ConfigureAwait(false); | |||
| /// <inheritdoc /> | |||
| async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options) | |||