Skip to content

Commit 702e6de

Browse files
committed
Split up interaction metadata types.
See discord/discord-api-docs#71781.
1 parent 26dc5e4 commit 702e6de

28 files changed

+614
-23
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// IApplicationCommandInteractionMetadata.cs
3+
//
4+
// Author:
5+
// Jarl Gullberg <[email protected]>
6+
//
7+
// Copyright (c) Jarl Gullberg
8+
//
9+
// This program is free software: you can redistribute it and/or modify
10+
// it under the terms of the GNU Lesser General Public License as published by
11+
// the Free Software Foundation, either version 3 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// This program is distributed in the hope that it will be useful,
15+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU Lesser General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU Lesser General Public License
20+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
//
22+
23+
using JetBrains.Annotations;
24+
using Remora.Rest.Core;
25+
26+
namespace Remora.Discord.API.Abstractions.Objects;
27+
28+
/// <summary>
29+
/// Represents the metadata of an application command interaction.
30+
/// </summary>
31+
[PublicAPI]
32+
public interface IApplicationCommandInteractionMetadata : IMessageInteractionMetadata
33+
{
34+
/// <inheritdoc/>
35+
InteractionType IMessageInteractionMetadata.Type => InteractionType.ApplicationCommand;
36+
37+
/// <summary>
38+
/// Gets the user the command was run on.
39+
/// </summary>
40+
Optional<IUser> TargetUser { get; }
41+
42+
/// <summary>
43+
/// Gets the ID of the message the command was run on.
44+
/// </summary>
45+
Optional<Snowflake> TargetMessageID { get; }
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// IMessageComponentInteractionMetadata.cs
3+
//
4+
// Author:
5+
// Jarl Gullberg <[email protected]>
6+
//
7+
// Copyright (c) Jarl Gullberg
8+
//
9+
// This program is free software: you can redistribute it and/or modify
10+
// it under the terms of the GNU Lesser General Public License as published by
11+
// the Free Software Foundation, either version 3 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// This program is distributed in the hope that it will be useful,
15+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU Lesser General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU Lesser General Public License
20+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
//
22+
23+
using JetBrains.Annotations;
24+
using Remora.Rest.Core;
25+
26+
namespace Remora.Discord.API.Abstractions.Objects;
27+
28+
/// <summary>
29+
/// Represents the metadata of a message component interaction.
30+
/// </summary>
31+
[PublicAPI]
32+
public interface IMessageComponentInteractionMetadata : IMessageInteractionMetadata
33+
{
34+
/// <inheritdoc/>
35+
InteractionType IMessageInteractionMetadata.Type => InteractionType.MessageComponent;
36+
37+
/// <summary>
38+
/// Gets the ID of the message containing the interactive component.
39+
/// </summary>
40+
Optional<Snowflake> InteractedMessageID { get; }
41+
}

Backend/Remora.Discord.API.Abstractions/API/Objects/Interactions/IMessageInteractionMetadata.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
namespace Remora.Discord.API.Abstractions.Objects;
2828

2929
/// <summary>
30-
/// Represents the metadata of an application command interaction.
30+
/// Represents generic information about a message interaction. Cast this to its relevant subtype based on
31+
/// <see cref="Type"/> to access type-specific fields.
3132
/// </summary>
3233
[PublicAPI]
3334
public interface IMessageInteractionMetadata
@@ -37,25 +38,15 @@ public interface IMessageInteractionMetadata
3738
/// </summary>
3839
Snowflake ID { get; }
3940

40-
/// <summary>
41-
/// Gets the ID of the user who triggered the interaction.
42-
/// </summary>
43-
IUser User { get; }
44-
4541
/// <summary>
4642
/// Gets the type of the interaction.
4743
/// </summary>
4844
InteractionType Type { get; }
4945

5046
/// <summary>
51-
/// Gets the ID of the original response message. Only applicable to followup messages.
52-
/// </summary>
53-
Optional<Snowflake> OriginalResponseMessageID { get; }
54-
55-
/// <summary>
56-
/// Gets the ID of the message containing the interactive component; only applicable to component interactions.
47+
/// Gets the ID of the user who triggered the interaction.
5748
/// </summary>
58-
Optional<Snowflake> InteractedMessageID { get; }
49+
IUser User { get; }
5950

6051
/// <summary>
6152
/// Gets the integrations that authorized the interaction.
@@ -72,7 +63,7 @@ public interface IMessageInteractionMetadata
7263
IReadOnlyDictionary<ApplicationIntegrationType, Snowflake> AuthorizingIntegrationOwners { get; }
7364

7465
/// <summary>
75-
/// Gets the interaction metadata responsible, if this is a response to a modal.
66+
/// Gets the ID of the original response message. Only applicable to followup messages.
7667
/// </summary>
77-
Optional<IMessageInteractionMetadata> TriggeringInteractionMetadata { get; }
68+
Optional<Snowflake> OriginalResponseMessageID { get; }
7869
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// IModalSubmitInteractionMetadata.cs
3+
//
4+
// Author:
5+
// Jarl Gullberg <[email protected]>
6+
//
7+
// Copyright (c) Jarl Gullberg
8+
//
9+
// This program is free software: you can redistribute it and/or modify
10+
// it under the terms of the GNU Lesser General Public License as published by
11+
// the Free Software Foundation, either version 3 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// This program is distributed in the hope that it will be useful,
15+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU Lesser General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU Lesser General Public License
20+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
//
22+
23+
using JetBrains.Annotations;
24+
using Remora.Rest.Core;
25+
26+
namespace Remora.Discord.API.Abstractions.Objects;
27+
28+
/// <summary>
29+
/// Represents the metadata of a modal submission interaction.
30+
/// </summary>
31+
[PublicAPI]
32+
public interface IModalSubmitInteractionMetadata : IMessageInteractionMetadata
33+
{
34+
/// <inheritdoc/>
35+
InteractionType IMessageInteractionMetadata.Type => InteractionType.ModalSubmit;
36+
37+
/// <summary>
38+
/// Gets the metadata for the interaction that was used to open the modal.
39+
/// </summary>
40+
Optional<IMessageInteractionMetadata> TriggeringInteractionMetadata { get; }
41+
}

Backend/Remora.Discord.API.Abstractions/API/Objects/Messages/IMessage.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ public interface IMessage : IPartialMessage
208208
/// </summary>
209209
new Optional<IPoll> Poll { get; }
210210

211+
/// <summary>
212+
/// Gets the call associated with the message, if any.
213+
/// </summary>
214+
new Optional<IMessageCall> Call { get; }
215+
211216
/// <inheritdoc/>
212217
Optional<Snowflake> IPartialMessage.ID => this.ID;
213218

@@ -306,4 +311,7 @@ public interface IMessage : IPartialMessage
306311

307312
/// <inheritdoc/>
308313
Optional<IPoll> IPartialMessage.Poll => this.Poll;
314+
315+
/// <inheritdoc/>
316+
Optional<IMessageCall> IPartialMessage.Call => this.Call;
309317
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// IMessageCall.cs
3+
//
4+
// Author:
5+
// Jarl Gullberg <[email protected]>
6+
//
7+
// Copyright (c) Jarl Gullberg
8+
//
9+
// This program is free software: you can redistribute it and/or modify
10+
// it under the terms of the GNU Lesser General Public License as published by
11+
// the Free Software Foundation, either version 3 of the License, or
12+
// (at your option) any later version.
13+
//
14+
// This program is distributed in the hope that it will be useful,
15+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
// GNU Lesser General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU Lesser General Public License
20+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
//
22+
23+
using System;
24+
using System.Collections.Generic;
25+
using JetBrains.Annotations;
26+
using Remora.Rest.Core;
27+
28+
namespace Remora.Discord.API.Abstractions.Objects;
29+
30+
/// <summary>
31+
/// Represents information about a call in a private channel.
32+
/// </summary>
33+
[PublicAPI]
34+
public interface IMessageCall
35+
{
36+
/// <summary>
37+
/// Gets the IDs of the participants of the call.
38+
/// </summary>
39+
IReadOnlyList<Snowflake> Participants { get; }
40+
41+
/// <summary>
42+
/// Gets the time when the call ended.
43+
/// </summary>
44+
Optional<DateTimeOffset?> EndedTimestamp { get; }
45+
}

Backend/Remora.Discord.API.Abstractions/API/Objects/Messages/IPartialMessage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@ public interface IPartialMessage
131131

132132
/// <inheritdoc cref="IMessage.Poll"/>
133133
Optional<IPoll> Poll { get; }
134+
135+
/// <inheritdoc cref="IMessage.Call"/>
136+
Optional<IMessageCall> Call { get; }
134137
}

Backend/Remora.Discord.API.Abstractions/Remora.Discord.API.Abstractions.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@
125125
<Compile Update="API\Rest\IListGuildSoundboardSoundsResponse.cs">
126126
<DependentUpon>IDiscordRestSoundboardAPI.cs</DependentUpon>
127127
</Compile>
128+
<Compile Update="API\Objects\Interactions\IMessageComponentInteractionMetadata.cs">
129+
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
130+
</Compile>
131+
<Compile Update="API\Objects\Interactions\IModalSubmitInteractionMetadata.cs">
132+
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
133+
</Compile>
134+
<Compile Update="API\Objects\Interactions\IApplicationCommandInteractionMetadata.cs">
135+
<DependentUpon>IMessageInteractionMetadata.cs</DependentUpon>
136+
</Compile>
128137
</ItemGroup>
129138

130139
</Project>

Backend/Remora.Discord.API/API/Gateway/Events/Messages/MessageCreate.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ public record MessageCreate
6767
Optional<int> Position = default,
6868
Optional<IApplicationCommandInteractionDataResolved> Resolved = default,
6969
Optional<IMessageInteractionMetadata> InteractionMetadata = default,
70-
Optional<IPoll> Poll = default
70+
Optional<IPoll> Poll = default,
71+
Optional<IMessageCall> Call = default
7172
) : IMessageCreate;

Backend/Remora.Discord.API/API/Gateway/Events/Messages/MessageUpdate.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ public record MessageUpdate
6767
Optional<int> Position = default,
6868
Optional<IApplicationCommandInteractionDataResolved> Resolved = default,
6969
Optional<IMessageInteractionMetadata> InteractionMetadata = default,
70-
Optional<IPoll> Poll = default
70+
Optional<IPoll> Poll = default,
71+
Optional<IMessageCall> Call = default
7172
) : IMessageUpdate;

0 commit comments

Comments
 (0)