Skip to content

Commit

Permalink
Merge pull request #336 from VelvetToroyashi/fix/user-apps
Browse files Browse the repository at this point in the history
Fix/user apps
  • Loading branch information
Nihlus authored May 17, 2024
2 parents d3f21d4 + 4a47b28 commit 7ef0cc5
Show file tree
Hide file tree
Showing 31 changed files with 322 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//

using JetBrains.Annotations;
using Remora.Rest.Core;

namespace Remora.Discord.API.Abstractions.Objects;

Expand All @@ -33,5 +34,5 @@ public interface IApplicationIntegrationTypeConfig
/// <summary>
/// Gets the OAuth2 install parameters for the integration type.
/// </summary>
public IApplicationOAuth2InstallParams OAuth2InstallParams { get; }
public Optional<IApplicationOAuth2InstallParams> OAuth2InstallParams { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ public interface IApplicationCommand
/// <summary>
/// Gets a value indicating the contexts in which this command can be invoked.
/// </summary>
Optional<IReadOnlyList<InteractionContextType>> Contexts { get; }
Optional<IReadOnlyList<InteractionContextType>?> Contexts { get; }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface IMessageInteractionMetadata
/// <summary>
/// Gets the ID of the user who triggered the interaction.
/// </summary>
Snowflake UserID { get; }
IUser User { get; }

/// <summary>
/// Gets the type of the interaction.
Expand All @@ -52,6 +52,11 @@ public interface IMessageInteractionMetadata
/// </summary>
Optional<Snowflake> OriginalResponseMessageID { get; }

/// <summary>
/// Gets the ID of the message containing the interactive component; only applicable to component interactions.
/// </summary>
Optional<Snowflake> InteractedMessageID { get; }

/// <summary>
/// Gets the integrations that authorized the interaction.
/// </summary>
Expand All @@ -65,4 +70,9 @@ public interface IMessageInteractionMetadata
/// </para>
/// </remarks>
IReadOnlyDictionary<ApplicationIntegrationType, Snowflake> AuthorizingIntegrationOwners { get; }

/// <summary>
/// Gets the interaction metadata responsible, if this is a response to a modal.
/// </summary>
Optional<IMessageInteractionMetadata> TriggeringInteractionMetadata { get; }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public interface IMessage : IPartialMessage
/// <summary>
/// Gets the metadata of the interaction, if any.
/// </summary>
new Optional<OneOf<IApplicationCommandInteractionMetadata, IMessageComponentInteractionMetadata, IModalSubmitInteractionMetadata>> InteractionMetadata { get; }
new Optional<IMessageInteractionMetadata> InteractionMetadata { get; }

/// <summary>
/// Gets the poll sent with the message, if any.
Expand Down Expand Up @@ -295,7 +295,7 @@ public interface IMessage : IPartialMessage
Optional<IApplicationCommandInteractionDataResolved> IPartialMessage.Resolved => this.Resolved;

/// <inheritdoc/>
Optional<OneOf<IApplicationCommandInteractionMetadata, IMessageComponentInteractionMetadata, IModalSubmitInteractionMetadata>> IPartialMessage.InteractionMetadata => this.InteractionMetadata;
Optional<IMessageInteractionMetadata> IPartialMessage.InteractionMetadata => this.InteractionMetadata;

/// <inheritdoc/>
Optional<IPoll> IPartialMessage.Poll => this.Poll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public interface IPartialMessage
Optional<IApplicationCommandInteractionDataResolved> Resolved { get; }

/// <inheritdoc cref="IMessage.InteractionMetadata"/>
Optional<OneOf<IApplicationCommandInteractionMetadata, IMessageComponentInteractionMetadata, IModalSubmitInteractionMetadata>> InteractionMetadata { get; }
Optional<IMessageInteractionMetadata> InteractionMetadata { get; }

/// <inheritdoc cref="IMessage.Poll"/>
Optional<IPoll> Poll { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Task<Result<IReadOnlyList<IApplicationCommand>>> GetGlobalApplicationCommandsAsy
/// <param name="defaultMemberPermissions">The permissions required to execute the command.</param>
/// <param name="dmPermission">Whether this command is executable in DMs.</param>
/// <param name="isNsfw">Whether the command is age-restricted.</param>
/// <param name="allowedIntegrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="integrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="allowedContextTypes">The contexts in which the command is allowed to be run in.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A creation result which may or may not have succeeded.</returns>
Expand All @@ -88,7 +88,7 @@ Task<Result<IApplicationCommand>> CreateGlobalApplicationCommandAsync
Optional<IDiscordPermissionSet?> defaultMemberPermissions = default,
Optional<bool?> dmPermission = default,
Optional<bool> isNsfw = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> allowedIntegrationTypes = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> integrationTypes = default,
Optional<IReadOnlyList<InteractionContextType>> allowedContextTypes = default,
CancellationToken ct = default
);
Expand Down Expand Up @@ -134,7 +134,7 @@ Task<Result<IApplicationCommand>> GetGlobalApplicationCommandAsync
/// <param name="defaultMemberPermissions">The permissions required to execute the command.</param>
/// <param name="dmPermission">Whether this command is executable in DMs.</param>
/// <param name="isNsfw">Whether this command is age-restricted.</param>
/// <param name="allowedIntegrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="integrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="allowedContextTypes">The contexts in which the command is allowed to be run in.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A creation result which may or may not have succeeded.</returns>
Expand All @@ -150,7 +150,7 @@ Task<Result<IApplicationCommand>> EditGlobalApplicationCommandAsync
Optional<IDiscordPermissionSet?> defaultMemberPermissions = default,
Optional<bool?> dmPermission = default,
Optional<bool> isNsfw = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> allowedIntegrationTypes = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> integrationTypes = default,
Optional<IReadOnlyList<InteractionContextType>> allowedContextTypes = default,
CancellationToken ct = default
);
Expand Down Expand Up @@ -205,7 +205,7 @@ Task<Result<IReadOnlyList<IApplicationCommand>>> GetGuildApplicationCommandsAsyn
/// <param name="descriptionLocalizations">The localized descriptions of the command.</param>
/// <param name="defaultMemberPermissions">The permissions required to execute the command.</param>
/// <param name="isNsfw">Whether the command is age-restricted.</param>
/// <param name="allowedIntegrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="integrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="allowedContextTypes">The contexts in which the command is allowed to be run in.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A creation result which may or may not have succeeded.</returns>
Expand All @@ -221,7 +221,7 @@ Task<Result<IApplicationCommand>> CreateGuildApplicationCommandAsync
Optional<IReadOnlyDictionary<string, string>?> descriptionLocalizations = default,
Optional<IDiscordPermissionSet?> defaultMemberPermissions = default,
Optional<bool> isNsfw = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> allowedIntegrationTypes = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> integrationTypes = default,
Optional<IReadOnlyList<InteractionContextType>> allowedContextTypes = default,
CancellationToken ct = default
);
Expand Down Expand Up @@ -271,7 +271,7 @@ Task<Result<IApplicationCommand>> GetGuildApplicationCommandAsync
/// <param name="descriptionLocalizations">The localized descriptions of the command.</param>
/// <param name="defaultMemberPermissions">The permissions required to execute the command.</param>
/// <param name="isNsfw">Whether this command is age-restricted.</param>
/// <param name="allowedIntegrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="integrationTypes">The installation contexts the command can be installed to.</param>
/// <param name="allowedContextTypes">The contexts in which the command is allowed to be run in.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>A creation result which may or may not have succeeded.</returns>
Expand All @@ -290,7 +290,7 @@ Task<Result<IApplicationCommand>> EditGuildApplicationCommandAsync
Optional<IReadOnlyDictionary<string, string>?> descriptionLocalizations = default,
Optional<IDiscordPermissionSet?> defaultMemberPermissions = default,
Optional<bool> isNsfw = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> allowedIntegrationTypes = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> integrationTypes = default,
Optional<IReadOnlyList<InteractionContextType>> allowedContextTypes = default,
CancellationToken ct = default
);
Expand Down Expand Up @@ -410,7 +410,7 @@ Task<Result<IReadOnlyList<IApplicationRoleConnectionMetadata>>> UpdateApplicatio
/// <param name="coverImage">The new cover image.</param>
/// <param name="interactionsEndpointUrl">The new interactions endpoint URL.</param>
/// <param name="tags">The new tags.</param>
/// <param name="integrationTypes">The new integration types.</param>
/// <param name="integrationTypesConfig">The new integration types.</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>The updated application.</returns>
Task<Result<IApplication>> EditCurrentApplicationAsync
Expand All @@ -424,7 +424,7 @@ Task<Result<IApplication>> EditCurrentApplicationAsync
Optional<Stream> coverImage = default,
Optional<Uri> interactionsEndpointUrl = default,
Optional<IReadOnlyList<string>> tags = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> integrationTypes = default,
Optional<IReadOnlyDictionary<ApplicationIntegrationType, IApplicationIntegrationTypeConfig>> integrationTypesConfig = default,
CancellationToken ct = default
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@
<Compile Update="API\Rest\IChannelPositionModification.cs">
<DependentUpon>IDiscordRestGuildAPI.cs</DependentUpon>
</Compile>
<Compile Update="API\Objects\Interactions\IMessageComponentInteractionMetadata.cs">
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
</Compile>
<Compile Update="API\Objects\Interactions\IApplicationCommandInteractionMetadata.cs">
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
</Compile>
<Compile Update="API\Objects\Interactions\IModalSubmitInteractionMetadata.cs">
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
</Compile>
<Compile Update="API\Rest\IBulkBanResponse.cs">
<DependentUpon>IDiscordRestGuildAPI.cs</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public record MessageCreate
Optional<IReadOnlyList<IStickerItem>> StickerItems = default,
Optional<int> Position = default,
Optional<IApplicationCommandInteractionDataResolved> Resolved = default,
Optional<OneOf<IApplicationCommandInteractionMetadata, IMessageComponentInteractionMetadata, IModalSubmitInteractionMetadata>> InteractionMetadata = default,
Optional<IMessageInteractionMetadata> InteractionMetadata = default,
Optional<IPoll> Poll = default
) : IMessageCreate;
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public record MessageUpdate
Optional<IReadOnlyList<IStickerItem>> StickerItems = default,
Optional<int> Position = default,
Optional<IApplicationCommandInteractionDataResolved> Resolved = default,
Optional<OneOf<IApplicationCommandInteractionMetadata, IMessageComponentInteractionMetadata, IModalSubmitInteractionMetadata>> InteractionMetadata = default,
Optional<IMessageInteractionMetadata> InteractionMetadata = default,
Optional<IPoll> Poll = default
) : IMessageUpdate;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ public record ApplicationCommand
Optional<bool> DMPermission = default,
Optional<bool> IsNsfw = default,
Optional<IReadOnlyList<ApplicationIntegrationType>> IntegrationTypes = default,
Optional<IReadOnlyList<InteractionContextType>> Contexts = default
Optional<IReadOnlyList<InteractionContextType>?> Contexts = default
) : IApplicationCommand;
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@

using JetBrains.Annotations;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Rest.Core;

namespace Remora.Discord.API.Objects;

/// <inheritdoc cref="IApplicationIntegrationTypeConfig"/>
[PublicAPI]
public record ApplicationIntegrationTypeConfig(IApplicationOAuth2InstallParams OAuth2InstallParams) : IApplicationIntegrationTypeConfig;
public record ApplicationIntegrationTypeConfig
(
Optional<IApplicationOAuth2InstallParams> OAuth2InstallParams
) : IApplicationIntegrationTypeConfig;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MessageComponentInteractionMetadata.cs
// MessageInteractionMetadata.cs
//
// Author:
// Jarl Gullberg <[email protected]>
Expand Down Expand Up @@ -27,14 +27,15 @@

namespace Remora.Discord.API.Objects;

/// <inheritdoc cref="IMessageComponentInteractionMetadata"/>
/// <inheritdoc cref="IMessageInteractionMetadata"/>
[PublicAPI]
public record MessageComponentInteractionMetadata
public record MessageInteractionMetadata
(
Snowflake ID,
Snowflake UserID,
InteractionType Type,
IUser User,
Optional<Snowflake> OriginalResponseMessageID,
Optional<Snowflake> InteractedMessageID,
InteractionType Type,
IReadOnlyDictionary<ApplicationIntegrationType, Snowflake> AuthorizingIntegrationOwners,
Snowflake InteractedMessageID
) : IMessageComponentInteractionMetadata;
Optional<IMessageInteractionMetadata> TriggeringInteractionMetadata
) : IMessageInteractionMetadata;
Loading

0 comments on commit 7ef0cc5

Please sign in to comment.