Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/user apps #336

Merged
merged 26 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ab32b1
fix(api): Register converters for metadata
VelvetToroyashi Apr 29, 2024
b924cd0
fix(api): Change UserID to User in accordance to Discord's new update
VelvetToroyashi Apr 29, 2024
29a4922
fix: Update nullability of integration types
VelvetToroyashi Apr 29, 2024
ef632cb
fix: Fix application edit endpoint
VelvetToroyashi Apr 29, 2024
7bdac3c
fix: Fix tests and json for sending
VelvetToroyashi Apr 29, 2024
70f13d1
refactor(api): Merge metadata into single class
VelvetToroyashi May 3, 2024
9e027f5
test: Add json payloads
VelvetToroyashi May 4, 2024
3ea760b
Merge branch 'main' into fix/user-apps
VelvetToroyashi May 4, 2024
c784a72
Merge remote-tracking branch 'upstream/main' into fix/user-apps
VelvetToroyashi May 4, 2024
7288f91
test: Add test for IMessageInteractionMetadata
VelvetToroyashi May 7, 2024
061cfd4
fix: Remove erroneous converter & add missing json
VelvetToroyashi May 9, 2024
2086a42
fix(tests): Fix broken JSON tests
VelvetToroyashi May 9, 2024
6539aaf
fix: Make ApplicationIntegrationType#OAuth2InstallParams `Optional<T>`
VelvetToroyashi May 10, 2024
cac68b4
fix: Fix tests, add enum dictionary converter
VelvetToroyashi May 11, 2024
4e6114f
feat(samples): Add user-app slash command sample
VelvetToroyashi May 11, 2024
4b880e8
fix: Add converter for integration types config when writing manually
VelvetToroyashi May 11, 2024
5b0a641
Update Backend/Remora.Discord.API/API/Objects/Interactions/Applicatio…
VelvetToroyashi May 11, 2024
4e06346
Update Backend/Remora.Discord.API/Json/Converters/Internal/EnumKeyDic…
VelvetToroyashi May 11, 2024
42b7edf
refactor: Apply PR feedback
VelvetToroyashi May 11, 2024
49f09d5
Revert "refactor: Apply PR feedback"
VelvetToroyashi May 11, 2024
bff3f43
Merge remote-tracking branch 'upstream/main' into fix/user-apps
VelvetToroyashi May 11, 2024
bf34c18
refactor!: Remove name from interaction metadata
VelvetToroyashi May 11, 2024
6f1bb43
chore: Address PR comments again
VelvetToroyashi May 11, 2024
e1ae761
fix: Apply correct naming to integration_types
VelvetToroyashi May 11, 2024
9cca677
Merge branch 'main' into fix/user-apps
VelvetToroyashi May 17, 2024
4a47b28
chore: Remove unused imports
VelvetToroyashi May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading